Skip to content

Commit

Permalink
added initial q generation
Browse files Browse the repository at this point in the history
Signed-off-by: Jürgen Eckel <[email protected]>
  • Loading branch information
eckelj committed Nov 28, 2024
1 parent 75cb64d commit 2a7e82b
Show file tree
Hide file tree
Showing 7 changed files with 933 additions and 76 deletions.
226 changes: 226 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47499,6 +47499,162 @@ paths:
descending order.


Since: cosmos-sdk 0.43
in: query
required: false
type: boolean
tags:
- Query
/planetmint/planetmint-go/dao/distributions:
get:
summary: Queries a list of Distributions items.
operationId: PlanetmintgoDaoDistributions
responses:
'200':
description: A successful response.
schema:
type: object
properties:
distributions:
type: object
properties:
daoAddr:
type: string
daoAmount:
type: string
daoTxID:
type: string
investorAddr:
type: string
investorAmount:
type: string
investorTxID:
type: string
popAddr:
type: string
popAmount:
type: string
popTxID:
type: string
firstPop:
type: string
format: int64
lastPop:
type: string
format: int64
proposer:
type: string
earlyInvAddr:
type: string
earlyInvAmount:
type: string
earlyInvTxID:
type: string
strategicAddr:
type: string
strategicAmount:
type: string
strategicTxID:
type: string
pagination:
type: object
properties:
next_key:
type: string
format: byte
description: |-
next_key is the key to be passed to PageRequest.key to
query the next page most efficiently. It will be empty if
there are no more results.
total:
type: string
format: uint64
title: >-
total is total number of results available if
PageRequest.count_total

was set, its value is undefined otherwise
description: >-
PageResponse is to be embedded in gRPC response messages where
the

corresponding request message has used PageRequest.

message SomeResponse {
repeated Bar results = 1;
PageResponse page = 2;
}
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
parameters:
- name: pagination.key
description: |-
key is a value returned in PageResponse.next_key to begin
querying the next page most efficiently. Only one of offset or key
should be set.
in: query
required: false
type: string
format: byte
- name: pagination.offset
description: >-
offset is a numeric offset that can be used when key is unavailable.

It is less efficient than using key. Only one of offset or key
should

be set.
in: query
required: false
type: string
format: uint64
- name: pagination.limit
description: >-
limit is the total number of results to be returned in the result
page.

If left empty it will default to a value to be set by each app.
in: query
required: false
type: string
format: uint64
- name: pagination.count_total
description: >-
count_total is set to true to indicate that the result set should
include

a count of the total number of items available for pagination in
UIs.

count_total is only respected when offset is used. It is ignored
when key

is set.
in: query
required: false
type: boolean
- name: pagination.reverse
description: >-
reverse is set to true if results are to be returned in the
descending order.


Since: cosmos-sdk 0.43
in: query
required: false
Expand Down Expand Up @@ -76890,6 +77046,76 @@ definitions:
repeated Bar results = 1;
PageResponse page = 2;
}
planetmintgo.dao.QueryDistributionsResponse:
type: object
properties:
distributions:
type: object
properties:
daoAddr:
type: string
daoAmount:
type: string
daoTxID:
type: string
investorAddr:
type: string
investorAmount:
type: string
investorTxID:
type: string
popAddr:
type: string
popAmount:
type: string
popTxID:
type: string
firstPop:
type: string
format: int64
lastPop:
type: string
format: int64
proposer:
type: string
earlyInvAddr:
type: string
earlyInvAmount:
type: string
earlyInvTxID:
type: string
strategicAddr:
type: string
strategicAmount:
type: string
strategicTxID:
type: string
pagination:
type: object
properties:
next_key:
type: string
format: byte
description: |-
next_key is the key to be passed to PageRequest.key to
query the next page most efficiently. It will be empty if
there are no more results.
total:
type: string
format: uint64
title: >-
total is total number of results available if
PageRequest.count_total

was set, its value is undefined otherwise
description: |-
PageResponse is to be embedded in gRPC response messages where the
corresponding request message has used PageRequest.

message SomeResponse {
repeated Bar results = 1;
PageResponse page = 2;
}
planetmintgo.dao.QueryGetChallengeResponse:
type: object
properties:
Expand Down
15 changes: 15 additions & 0 deletions proto/planetmintgo/dao/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ service Query {
option (google.api.http).get = "/planetmint/dao/redeem_claim_by_liquid_tx_hash/{liquidTxHash}";

}

// Queries a list of Distributions items.
rpc Distributions (QueryDistributionsRequest) returns (QueryDistributionsResponse) {
option (google.api.http).get = "/planetmint/planetmint-go/dao/distributions";

}
}
// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}
Expand Down Expand Up @@ -177,3 +183,12 @@ message QueryRedeemClaimByLiquidTxHashResponse {
RedeemClaim redeemClaim = 1;
}

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

message QueryDistributionsResponse {
DistributionOrder distributions = 1;
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

2 changes: 2 additions & 0 deletions x/dao/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func GetQueryCmd(_ string) *cobra.Command {
GetCmdShowRedeemClaim(),
)

cmd.AddCommand(CmdDistributions())

// this line is used by starport scaffolding # 1

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

import (
"strconv"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/planetmint/planetmint-go/x/dao/types"
"github.com/spf13/cobra"
)

var _ = strconv.Itoa(0)

func CmdDistributions() *cobra.Command {
cmd := &cobra.Command{
Use: "distributions",
Short: "Query distributions",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) (err error) {

clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)

params := &types.QueryDistributionsRequest{}

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

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

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
23 changes: 23 additions & 0 deletions x/dao/keeper/query_distributions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package keeper

import (
"context"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/planetmint/planetmint-go/x/dao/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

func (k Keeper) Distributions(goCtx context.Context, req *types.QueryDistributionsRequest) (*types.QueryDistributionsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}

ctx := sdk.UnwrapSDKContext(goCtx)

// TODO: Process the query
_ = ctx

return &types.QueryDistributionsResponse{}, nil
}
Loading

0 comments on commit 2a7e82b

Please sign in to comment.