Validator Vesting gRPC Endpoints (#1832)

* Add validator-vesting grpc

* Update validator REST API endpoints to use grpc

* Update validator-vesting cli to use grpc

* Update changelog for added grpc changes

* Add grpc query tests
This commit is contained in:
Draco 2024-02-27 14:40:52 -05:00 committed by GitHub
parent 11d3ba3466
commit 1d944d5219
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 3932 additions and 258 deletions

View File

@ -42,6 +42,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- (cdp) [#1818] Add module param and logic for running x/cdp begin blocker every `n` blocks
- (cli) [#1804] Add `rocksdb compact` command for manual DB compaction of state or blockstore.
- (cosmos-sdk) [#1811] Upgrades app to cosmos-sdk v0.47.7
- (validator-vesting) [#1832] Add grpc query service to replace removed legacy querier.
## [v0.25.0]
@ -324,6 +325,7 @@ the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.38.4/CHANGELOG.md).
- [#257](https://github.com/Kava-Labs/kava/pulls/257) Include scripts to run
large-scale simulations remotely using aws-batch
[#1832]: https://github.com/Kava-Labs/kava/pull/1832
[#1811]: https://github.com/Kava-Labs/kava/pull/1811
[#1804]: https://github.com/Kava-Labs/kava/pull/1804
[#1785]: https://github.com/Kava-Labs/kava/pull/1785

View File

@ -580,6 +580,24 @@
- [Msg](#kava.swap.v1beta1.Msg)
- [kava/validatorvesting/v1beta1/query.proto](#kava/validatorvesting/v1beta1/query.proto)
- [QueryCirculatingSupplyHARDRequest](#kava.validatorvesting.v1beta1.QueryCirculatingSupplyHARDRequest)
- [QueryCirculatingSupplyHARDResponse](#kava.validatorvesting.v1beta1.QueryCirculatingSupplyHARDResponse)
- [QueryCirculatingSupplyRequest](#kava.validatorvesting.v1beta1.QueryCirculatingSupplyRequest)
- [QueryCirculatingSupplyResponse](#kava.validatorvesting.v1beta1.QueryCirculatingSupplyResponse)
- [QueryCirculatingSupplySWPRequest](#kava.validatorvesting.v1beta1.QueryCirculatingSupplySWPRequest)
- [QueryCirculatingSupplySWPResponse](#kava.validatorvesting.v1beta1.QueryCirculatingSupplySWPResponse)
- [QueryCirculatingSupplyUSDXRequest](#kava.validatorvesting.v1beta1.QueryCirculatingSupplyUSDXRequest)
- [QueryCirculatingSupplyUSDXResponse](#kava.validatorvesting.v1beta1.QueryCirculatingSupplyUSDXResponse)
- [QueryTotalSupplyHARDRequest](#kava.validatorvesting.v1beta1.QueryTotalSupplyHARDRequest)
- [QueryTotalSupplyHARDResponse](#kava.validatorvesting.v1beta1.QueryTotalSupplyHARDResponse)
- [QueryTotalSupplyRequest](#kava.validatorvesting.v1beta1.QueryTotalSupplyRequest)
- [QueryTotalSupplyResponse](#kava.validatorvesting.v1beta1.QueryTotalSupplyResponse)
- [QueryTotalSupplyUSDXRequest](#kava.validatorvesting.v1beta1.QueryTotalSupplyUSDXRequest)
- [QueryTotalSupplyUSDXResponse](#kava.validatorvesting.v1beta1.QueryTotalSupplyUSDXResponse)
- [Query](#kava.validatorvesting.v1beta1.Query)
- [Scalar Value Types](#scalar-value-types)
@ -7861,6 +7879,213 @@ Msg defines the swap Msg service.
<a name="kava/validatorvesting/v1beta1/query.proto"></a>
<p align="right"><a href="#top">Top</a></p>
## kava/validatorvesting/v1beta1/query.proto
<a name="kava.validatorvesting.v1beta1.QueryCirculatingSupplyHARDRequest"></a>
### QueryCirculatingSupplyHARDRequest
QueryCirculatingSupplyHARDRequest is the request type for the Query/CirculatingSupplyHARD RPC method
<a name="kava.validatorvesting.v1beta1.QueryCirculatingSupplyHARDResponse"></a>
### QueryCirculatingSupplyHARDResponse
QueryCirculatingSupplyHARDResponse is the response type for the Query/CirculatingSupplyHARD RPC method
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `amount` | [string](#string) | | |
<a name="kava.validatorvesting.v1beta1.QueryCirculatingSupplyRequest"></a>
### QueryCirculatingSupplyRequest
QueryCirculatingSupplyRequest is the request type for the Query/CirculatingSupply RPC method
<a name="kava.validatorvesting.v1beta1.QueryCirculatingSupplyResponse"></a>
### QueryCirculatingSupplyResponse
QueryCirculatingSupplyResponse is the response type for the Query/CirculatingSupply RPC method
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `amount` | [string](#string) | | |
<a name="kava.validatorvesting.v1beta1.QueryCirculatingSupplySWPRequest"></a>
### QueryCirculatingSupplySWPRequest
QueryCirculatingSupplySWPRequest is the request type for the Query/CirculatingSupplySWP RPC method
<a name="kava.validatorvesting.v1beta1.QueryCirculatingSupplySWPResponse"></a>
### QueryCirculatingSupplySWPResponse
QueryCirculatingSupplySWPResponse is the response type for the Query/CirculatingSupplySWP RPC method
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `amount` | [string](#string) | | |
<a name="kava.validatorvesting.v1beta1.QueryCirculatingSupplyUSDXRequest"></a>
### QueryCirculatingSupplyUSDXRequest
QueryCirculatingSupplyUSDXRequest is the request type for the Query/CirculatingSupplyUSDX RPC method
<a name="kava.validatorvesting.v1beta1.QueryCirculatingSupplyUSDXResponse"></a>
### QueryCirculatingSupplyUSDXResponse
QueryCirculatingSupplyUSDXResponse is the response type for the Query/CirculatingSupplyUSDX RPC method
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `amount` | [string](#string) | | |
<a name="kava.validatorvesting.v1beta1.QueryTotalSupplyHARDRequest"></a>
### QueryTotalSupplyHARDRequest
QueryTotalSupplyHARDRequest is the request type for the Query/TotalSupplyHARD RPC method
<a name="kava.validatorvesting.v1beta1.QueryTotalSupplyHARDResponse"></a>
### QueryTotalSupplyHARDResponse
QueryTotalSupplyHARDResponse is the response type for the Query/TotalSupplyHARD RPC method
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `amount` | [string](#string) | | |
<a name="kava.validatorvesting.v1beta1.QueryTotalSupplyRequest"></a>
### QueryTotalSupplyRequest
QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC method
<a name="kava.validatorvesting.v1beta1.QueryTotalSupplyResponse"></a>
### QueryTotalSupplyResponse
QueryTotalSupplyResponse is the response type for the Query/TotalSupply RPC method
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `amount` | [string](#string) | | |
<a name="kava.validatorvesting.v1beta1.QueryTotalSupplyUSDXRequest"></a>
### QueryTotalSupplyUSDXRequest
QueryTotalSupplyUSDXRequest is the request type for the Query/TotalSupplyUSDX RPC method
<a name="kava.validatorvesting.v1beta1.QueryTotalSupplyUSDXResponse"></a>
### QueryTotalSupplyUSDXResponse
QueryTotalSupplyUSDXResponse is the response type for the Query/TotalSupplyUSDX RPC method
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `amount` | [string](#string) | | |
<!-- end messages -->
<!-- end enums -->
<!-- end HasExtensions -->
<a name="kava.validatorvesting.v1beta1.Query"></a>
### Query
Query defines the gRPC querier service for validator-vesting module
| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `CirculatingSupply` | [QueryCirculatingSupplyRequest](#kava.validatorvesting.v1beta1.QueryCirculatingSupplyRequest) | [QueryCirculatingSupplyResponse](#kava.validatorvesting.v1beta1.QueryCirculatingSupplyResponse) | CirculatingSupply returns the total amount of kava tokens in circulation | GET|/kava/validator-vesting/v1beta1/circulating_supply|
| `TotalSupply` | [QueryTotalSupplyRequest](#kava.validatorvesting.v1beta1.QueryTotalSupplyRequest) | [QueryTotalSupplyResponse](#kava.validatorvesting.v1beta1.QueryTotalSupplyResponse) | TotalSupply returns the total amount of kava tokens | GET|/kava/validator-vesting/v1beta1/total_supply|
| `CirculatingSupplyHARD` | [QueryCirculatingSupplyHARDRequest](#kava.validatorvesting.v1beta1.QueryCirculatingSupplyHARDRequest) | [QueryCirculatingSupplyHARDResponse](#kava.validatorvesting.v1beta1.QueryCirculatingSupplyHARDResponse) | CirculatingSupplyHARD returns the total amount of hard tokens in circulation | GET|/kava/validator-vesting/v1beta1/circulating_supply_hard|
| `CirculatingSupplyUSDX` | [QueryCirculatingSupplyUSDXRequest](#kava.validatorvesting.v1beta1.QueryCirculatingSupplyUSDXRequest) | [QueryCirculatingSupplyUSDXResponse](#kava.validatorvesting.v1beta1.QueryCirculatingSupplyUSDXResponse) | CirculatingSupplyUSDX returns the total amount of usdx tokens in circulation | GET|/kava/validator-vesting/v1beta1/circulating_supply_usdx|
| `CirculatingSupplySWP` | [QueryCirculatingSupplySWPRequest](#kava.validatorvesting.v1beta1.QueryCirculatingSupplySWPRequest) | [QueryCirculatingSupplySWPResponse](#kava.validatorvesting.v1beta1.QueryCirculatingSupplySWPResponse) | CirculatingSupplySWP returns the total amount of swp tokens in circulation | GET|/kava/validator-vesting/v1beta1/circulating_supply_swp|
| `TotalSupplyHARD` | [QueryTotalSupplyHARDRequest](#kava.validatorvesting.v1beta1.QueryTotalSupplyHARDRequest) | [QueryTotalSupplyHARDResponse](#kava.validatorvesting.v1beta1.QueryTotalSupplyHARDResponse) | TotalSupplyHARD returns the total amount of hard tokens | GET|/kava/validator-vesting/v1beta1/total_supply_hard|
| `TotalSupplyUSDX` | [QueryTotalSupplyUSDXRequest](#kava.validatorvesting.v1beta1.QueryTotalSupplyUSDXRequest) | [QueryTotalSupplyUSDXResponse](#kava.validatorvesting.v1beta1.QueryTotalSupplyUSDXResponse) | TotalSupplyUSDX returns the total amount of usdx tokens | GET|/kava/validator-vesting/v1beta1/total_supply_usdx|
<!-- end services -->
## Scalar Value Types
| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby |

View File

@ -0,0 +1,131 @@
syntax = "proto3";
package kava.validatorvesting.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
option go_package = "github.com/kava-labs/kava/x/validator-vesting/types";
option (gogoproto.goproto_getters_all) = false;
// Query defines the gRPC querier service for validator-vesting module
service Query {
// CirculatingSupply returns the total amount of kava tokens in circulation
rpc CirculatingSupply(QueryCirculatingSupplyRequest) returns (QueryCirculatingSupplyResponse) {
option (google.api.http).get = "/kava/validator-vesting/v1beta1/circulating_supply";
}
// TotalSupply returns the total amount of kava tokens
rpc TotalSupply(QueryTotalSupplyRequest) returns (QueryTotalSupplyResponse) {
option (google.api.http).get = "/kava/validator-vesting/v1beta1/total_supply";
}
// CirculatingSupplyHARD returns the total amount of hard tokens in circulation
rpc CirculatingSupplyHARD(QueryCirculatingSupplyHARDRequest) returns (QueryCirculatingSupplyHARDResponse) {
option (google.api.http).get = "/kava/validator-vesting/v1beta1/circulating_supply_hard";
}
// CirculatingSupplyUSDX returns the total amount of usdx tokens in circulation
rpc CirculatingSupplyUSDX(QueryCirculatingSupplyUSDXRequest) returns (QueryCirculatingSupplyUSDXResponse) {
option (google.api.http).get = "/kava/validator-vesting/v1beta1/circulating_supply_usdx";
}
// CirculatingSupplySWP returns the total amount of swp tokens in circulation
rpc CirculatingSupplySWP(QueryCirculatingSupplySWPRequest) returns (QueryCirculatingSupplySWPResponse) {
option (google.api.http).get = "/kava/validator-vesting/v1beta1/circulating_supply_swp";
}
// TotalSupplyHARD returns the total amount of hard tokens
rpc TotalSupplyHARD(QueryTotalSupplyHARDRequest) returns (QueryTotalSupplyHARDResponse) {
option (google.api.http).get = "/kava/validator-vesting/v1beta1/total_supply_hard";
}
// TotalSupplyUSDX returns the total amount of usdx tokens
rpc TotalSupplyUSDX(QueryTotalSupplyUSDXRequest) returns (QueryTotalSupplyUSDXResponse) {
option (google.api.http).get = "/kava/validator-vesting/v1beta1/total_supply_usdx";
}
}
// QueryCirculatingSupplyRequest is the request type for the Query/CirculatingSupply RPC method
message QueryCirculatingSupplyRequest {}
// QueryCirculatingSupplyResponse is the response type for the Query/CirculatingSupply RPC method
message QueryCirculatingSupplyResponse {
string amount = 1 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
// QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC method
message QueryTotalSupplyRequest {}
// QueryTotalSupplyResponse is the response type for the Query/TotalSupply RPC method
message QueryTotalSupplyResponse {
string amount = 1 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
// QueryCirculatingSupplyHARDRequest is the request type for the Query/CirculatingSupplyHARD RPC method
message QueryCirculatingSupplyHARDRequest {}
// QueryCirculatingSupplyHARDResponse is the response type for the Query/CirculatingSupplyHARD RPC method
message QueryCirculatingSupplyHARDResponse {
string amount = 1 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
// QueryCirculatingSupplyUSDXRequest is the request type for the Query/CirculatingSupplyUSDX RPC method
message QueryCirculatingSupplyUSDXRequest {}
// QueryCirculatingSupplyUSDXResponse is the response type for the Query/CirculatingSupplyUSDX RPC method
message QueryCirculatingSupplyUSDXResponse {
string amount = 1 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
// QueryCirculatingSupplySWPRequest is the request type for the Query/CirculatingSupplySWP RPC method
message QueryCirculatingSupplySWPRequest {}
// QueryCirculatingSupplySWPResponse is the response type for the Query/CirculatingSupplySWP RPC method
message QueryCirculatingSupplySWPResponse {
string amount = 1 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
// QueryTotalSupplyHARDRequest is the request type for the Query/TotalSupplyHARD RPC method
message QueryTotalSupplyHARDRequest {}
// QueryTotalSupplyHARDResponse is the response type for the Query/TotalSupplyHARD RPC method
message QueryTotalSupplyHARDResponse {
string amount = 1 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
// QueryTotalSupplyUSDXRequest is the request type for the Query/TotalSupplyUSDX RPC method
message QueryTotalSupplyUSDXRequest {}
// QueryTotalSupplyUSDXResponse is the response type for the Query/TotalSupplyUSDX RPC method
message QueryTotalSupplyUSDXResponse {
string amount = 1 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

View File

@ -1,7 +1,7 @@
package cli
import (
"fmt"
"context"
"github.com/spf13/cobra"
@ -48,19 +48,12 @@ func queryCirculatingSupply() *cobra.Command {
return err
}
// Query
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupply), nil)
queryClient := types.NewQueryClient(cliCtx)
res, err := queryClient.CirculatingSupply(context.Background(), &types.QueryCirculatingSupplyRequest{})
if err != nil {
return err
}
cliCtx = cliCtx.WithHeight(height)
// Decode and print results
var out int64
if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &out); err != nil {
return fmt.Errorf("failed to unmarshal supply: %w", err)
}
return cliCtx.PrintObjectLegacy(out)
return cliCtx.PrintString(res.Amount.String())
},
}
}
@ -76,20 +69,12 @@ func queryTotalSupply() *cobra.Command {
if err != nil {
return err
}
// Query
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalSupply), nil)
queryClient := types.NewQueryClient(cliCtx)
res, err := queryClient.TotalSupply(context.Background(), &types.QueryTotalSupplyRequest{})
if err != nil {
return err
}
cliCtx = cliCtx.WithHeight(height)
// Decode and print results
var out int64
if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &out); err != nil {
return fmt.Errorf("failed to unmarshal supply: %w", err)
}
return cliCtx.PrintObjectLegacy(out)
return cliCtx.PrintString(res.Amount.String())
},
}
}
@ -106,19 +91,12 @@ func queryCirculatingSupplyHARD() *cobra.Command {
return err
}
// Query
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupplyHARD), nil)
queryClient := types.NewQueryClient(cliCtx)
res, err := queryClient.CirculatingSupplyHARD(context.Background(), &types.QueryCirculatingSupplyHARDRequest{})
if err != nil {
return err
}
cliCtx = cliCtx.WithHeight(height)
// Decode and print results
var out int64
if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &out); err != nil {
return fmt.Errorf("failed to unmarshal supply: %w", err)
}
return cliCtx.PrintObjectLegacy(out)
return cliCtx.PrintString(res.Amount.String())
},
}
}
@ -135,19 +113,12 @@ func queryCirculatingSupplyUSDX() *cobra.Command {
return err
}
// Query
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupplyUSDX), nil)
queryClient := types.NewQueryClient(cliCtx)
res, err := queryClient.CirculatingSupplyUSDX(context.Background(), &types.QueryCirculatingSupplyUSDXRequest{})
if err != nil {
return err
}
cliCtx = cliCtx.WithHeight(height)
// Decode and print results
var out int64
if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &out); err != nil {
return fmt.Errorf("failed to unmarshal supply: %w", err)
}
return cliCtx.PrintObjectLegacy(out)
return cliCtx.PrintString(res.Amount.String())
},
}
}
@ -164,19 +135,12 @@ func queryCirculatingSupplySWP() *cobra.Command {
return err
}
// Query
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupplySWP), nil)
queryClient := types.NewQueryClient(cliCtx)
res, err := queryClient.CirculatingSupplySWP(context.Background(), &types.QueryCirculatingSupplySWPRequest{})
if err != nil {
return err
}
cliCtx = cliCtx.WithHeight(height)
// Decode and print results
var out int64
if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &out); err != nil {
return fmt.Errorf("failed to unmarshal supply: %w", err)
}
return cliCtx.PrintObjectLegacy(out)
return cliCtx.PrintString(res.Amount.String())
},
}
}
@ -193,19 +157,12 @@ func queryTotalSupplyHARD() *cobra.Command {
return err
}
// Query
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalSupplyHARD), nil)
queryClient := types.NewQueryClient(cliCtx)
res, err := queryClient.TotalSupplyHARD(context.Background(), &types.QueryTotalSupplyHARDRequest{})
if err != nil {
return err
}
cliCtx = cliCtx.WithHeight(height)
// Decode and print results
var out int64
if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &out); err != nil {
return fmt.Errorf("failed to unmarshal supply: %w", err)
}
return cliCtx.PrintObjectLegacy(out)
return cliCtx.PrintString(res.Amount.String())
},
}
}
@ -222,19 +179,12 @@ func queryTotalSupplyUSDX() *cobra.Command {
return err
}
// Query
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalSupplyUSDX), nil)
queryClient := types.NewQueryClient(cliCtx)
res, err := queryClient.TotalSupplyUSDX(context.Background(), &types.QueryTotalSupplyUSDXRequest{})
if err != nil {
return err
}
cliCtx = cliCtx.WithHeight(height)
// Decode and print results
var out int64
if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &out); err != nil {
return fmt.Errorf("failed to unmarshal supply: %w", err)
}
return cliCtx.PrintObjectLegacy(out)
return cliCtx.PrintString(res.Amount.String())
},
}
}

View File

@ -1,6 +1,7 @@
package rest
import (
"context"
"encoding/json"
"fmt"
"net/http"
@ -25,37 +26,18 @@ func registerQueryRoutes(cliCtx client.Context, r *mux.Router) {
func getTotalSupplyHandlerFn(cliCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
}
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
if !ok {
return
}
params := types.NewBaseQueryParams(page, limit)
bz, err := cliCtx.LegacyAmino.MarshalJSON(params)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
return
}
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalSupply)
res, _, err := cliCtx.QueryWithData(route, bz)
queryClient := types.NewQueryClient(cliCtx)
res, err := queryClient.TotalSupply(context.Background(), &types.QueryTotalSupplyRequest{})
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
var totalSupply int64
err = cliCtx.LegacyAmino.UnmarshalJSON(res, &totalSupply)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
resBytes, err := json.Marshal(totalSupply)
resBytes, err := json.Marshal(res.Amount.Int64())
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -66,38 +48,18 @@ func getTotalSupplyHandlerFn(cliCtx client.Context) http.HandlerFunc {
func getCirculatingSupplyHandlerFn(cliCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
}
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
if !ok {
return
}
params := types.NewBaseQueryParams(page, limit)
bz, err := cliCtx.LegacyAmino.MarshalJSON(params)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
return
}
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupply)
res, _, err := cliCtx.QueryWithData(route, bz)
queryClient := types.NewQueryClient(cliCtx)
res, err := queryClient.CirculatingSupply(context.Background(), &types.QueryCirculatingSupplyRequest{})
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
var circSupply int64
err = cliCtx.LegacyAmino.UnmarshalJSON(res, &circSupply)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
resBytes, err := json.Marshal(circSupply)
resBytes, err := json.Marshal(res.Amount.Int64())
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -108,38 +70,18 @@ func getCirculatingSupplyHandlerFn(cliCtx client.Context) http.HandlerFunc {
func getCirculatingSupplyHARDHandlerFn(cliCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
}
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
if !ok {
return
}
params := types.NewBaseQueryParams(page, limit)
bz, err := cliCtx.LegacyAmino.MarshalJSON(params)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
return
}
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupplyHARD)
res, _, err := cliCtx.QueryWithData(route, bz)
queryClient := types.NewQueryClient(cliCtx)
res, err := queryClient.CirculatingSupplyHARD(context.Background(), &types.QueryCirculatingSupplyHARDRequest{})
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
var circSupply int64
err = cliCtx.LegacyAmino.UnmarshalJSON(res, &circSupply)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
resBytes, err := json.Marshal(circSupply)
resBytes, err := json.Marshal(res.Amount.Int64())
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -150,38 +92,18 @@ func getCirculatingSupplyHARDHandlerFn(cliCtx client.Context) http.HandlerFunc {
func getCirculatingSupplyUSDXHandlerFn(cliCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
}
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
if !ok {
return
}
params := types.NewBaseQueryParams(page, limit)
bz, err := cliCtx.LegacyAmino.MarshalJSON(params)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
return
}
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupplyUSDX)
res, _, err := cliCtx.QueryWithData(route, bz)
queryClient := types.NewQueryClient(cliCtx)
res, err := queryClient.CirculatingSupplyUSDX(context.Background(), &types.QueryCirculatingSupplyUSDXRequest{})
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
var circSupply int64
err = cliCtx.LegacyAmino.UnmarshalJSON(res, &circSupply)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
resBytes, err := json.Marshal(circSupply)
resBytes, err := json.Marshal(res.Amount.Int64())
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -192,38 +114,18 @@ func getCirculatingSupplyUSDXHandlerFn(cliCtx client.Context) http.HandlerFunc {
func getCirculatingSupplySWPHandlerFn(cliCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
}
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
if !ok {
return
}
params := types.NewBaseQueryParams(page, limit)
bz, err := cliCtx.LegacyAmino.MarshalJSON(params)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
return
}
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryCirculatingSupplySWP)
res, _, err := cliCtx.QueryWithData(route, bz)
queryClient := types.NewQueryClient(cliCtx)
res, err := queryClient.CirculatingSupplySWP(context.Background(), &types.QueryCirculatingSupplySWPRequest{})
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
var circSupply int64
err = cliCtx.LegacyAmino.UnmarshalJSON(res, &circSupply)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
resBytes, err := json.Marshal(circSupply)
resBytes, err := json.Marshal(res.Amount.Int64())
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -234,37 +136,18 @@ func getCirculatingSupplySWPHandlerFn(cliCtx client.Context) http.HandlerFunc {
func getTotalSupplyHARDHandlerFn(cliCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
}
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
if !ok {
return
}
params := types.NewBaseQueryParams(page, limit)
bz, err := cliCtx.LegacyAmino.MarshalJSON(params)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
return
}
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalSupplyHARD)
res, _, err := cliCtx.QueryWithData(route, bz)
queryClient := types.NewQueryClient(cliCtx)
res, err := queryClient.TotalSupplyHARD(context.Background(), &types.QueryTotalSupplyHARDRequest{})
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
var totalSupply int64
err = cliCtx.LegacyAmino.UnmarshalJSON(res, &totalSupply)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
resBytes, err := json.Marshal(totalSupply)
resBytes, err := json.Marshal(res.Amount.Int64())
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -275,37 +158,18 @@ func getTotalSupplyHARDHandlerFn(cliCtx client.Context) http.HandlerFunc {
func getTotalSupplyUSDXHandlerFn(cliCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
}
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
if !ok {
return
}
params := types.NewBaseQueryParams(page, limit)
bz, err := cliCtx.LegacyAmino.MarshalJSON(params)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))
return
}
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalSupplyUSDX)
res, _, err := cliCtx.QueryWithData(route, bz)
queryClient := types.NewQueryClient(cliCtx)
res, err := queryClient.TotalSupplyUSDX(context.Background(), &types.QueryTotalSupplyUSDXRequest{})
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
var totalSupply int64
err = cliCtx.LegacyAmino.UnmarshalJSON(res, &totalSupply)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
resBytes, err := json.Marshal(totalSupply)
resBytes, err := json.Marshal(res.Amount.Int64())
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return

View File

@ -0,0 +1,358 @@
package keeper
import (
"context"
"time"
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/validator-vesting/types"
)
type queryServer struct {
bk types.BankKeeper
}
var _ types.QueryServer = queryServer{}
// NewQueryServerImpl creates a new server for handling gRPC queries.
func NewQueryServerImpl(bk types.BankKeeper) types.QueryServer {
return &queryServer{bk: bk}
}
// CirculatingSupply implements the gRPC service handler for querying the circulating supply of the kava token.
func (s queryServer) CirculatingSupply(c context.Context, req *types.QueryCirculatingSupplyRequest) (*types.
QueryCirculatingSupplyResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
totalSupply := s.bk.GetSupply(ctx, "ukava").Amount
supplyInt := getCirculatingSupply(ctx.BlockTime(), totalSupply)
return &types.QueryCirculatingSupplyResponse{
Amount: supplyInt,
}, nil
}
// TotalSupply returns the total amount of ukava tokens
func (s queryServer) TotalSupply(c context.Context, req *types.QueryTotalSupplyRequest) (*types.QueryTotalSupplyResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
totalSupply := s.bk.GetSupply(ctx, "ukava").Amount
supplyInt := sdk.NewDecFromInt(totalSupply).Mul(sdk.MustNewDecFromStr("0.000001")).TruncateInt()
return &types.QueryTotalSupplyResponse{
Amount: supplyInt,
}, nil
}
// CirculatingSupplyHARD returns the total amount of hard tokens in circulation
func (s queryServer) CirculatingSupplyHARD(c context.Context, req *types.QueryCirculatingSupplyHARDRequest) (*types.QueryCirculatingSupplyHARDResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
supplyIncreaseDates := []time.Time{
time.Date(2020, 10, 15, 14, 0, 0, 0, time.UTC), // + 30,000,000 *** Year ONE ***
time.Date(2020, 11, 15, 14, 0, 0, 0, time.UTC), // + 5,000,000
time.Date(2020, 12, 15, 14, 0, 0, 0, time.UTC), // + 5,000,000
time.Date(2021, 1, 15, 14, 0, 0, 0, time.UTC), // + 7,708,334
time.Date(2021, 2, 15, 14, 0, 0, 0, time.UTC), // + 3,333,333
time.Date(2021, 3, 15, 14, 0, 0, 0, time.UTC), // + 3,333,333
time.Date(2021, 4, 15, 14, 0, 0, 0, time.UTC), // + 6,875,000
time.Date(2021, 5, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2021, 6, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2021, 7, 15, 14, 0, 0, 0, time.UTC), // + 6,875,000
time.Date(2021, 8, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2021, 9, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000 *** Year ONE ***
time.Date(2021, 10, 15, 14, 0, 0, 0, time.UTC), // + 13,541,667 *** Year TWO ***
time.Date(2021, 11, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2021, 12, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2022, 1, 15, 14, 0, 0, 0, time.UTC), // + 8,541,667
time.Date(2022, 2, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2022, 3, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2022, 4, 15, 14, 0, 0, 0, time.UTC), // + 8,541,667
time.Date(2022, 5, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2022, 6, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2022, 7, 15, 14, 0, 0, 0, time.UTC), // + 8,541,667
time.Date(2022, 8, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2022, 9, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000 *** Year TWO ***
time.Date(2022, 10, 15, 14, 0, 0, 0, time.UTC), // + 8,541,667 *** Year THREE ***
time.Date(2022, 11, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2022, 12, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2023, 1, 15, 14, 0, 0, 0, time.UTC), // + 4,166,667
time.Date(2023, 2, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2023, 3, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2023, 4, 15, 14, 0, 0, 0, time.UTC), // + 4,166,667
time.Date(2023, 5, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2023, 6, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2023, 7, 15, 14, 0, 0, 0, time.UTC), // + 4,166,667
time.Date(2023, 8, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000
time.Date(2023, 9, 15, 14, 0, 0, 0, time.UTC), // + 2,500,000 *** Year THREE ***
time.Date(2023, 10, 15, 14, 0, 0, 0, time.UTC), // + 3,333,334 *** Year FOUR ***
time.Date(2023, 11, 15, 14, 0, 0, 0, time.UTC), // + 1,666,667
time.Date(2023, 12, 15, 14, 0, 0, 0, time.UTC), // + 1,666,667
time.Date(2024, 1, 15, 14, 0, 0, 0, time.UTC), // + 1,666,667
time.Date(2024, 2, 15, 14, 0, 0, 0, time.UTC), // + 1,666,667
time.Date(2024, 3, 15, 14, 0, 0, 0, time.UTC), // + 1,666,667
time.Date(2024, 4, 15, 14, 0, 0, 0, time.UTC), // + 1,666,667
time.Date(2024, 5, 15, 14, 0, 0, 0, time.UTC), // + 1,666,667
time.Date(2024, 6, 15, 14, 0, 0, 0, time.UTC), // + 1,666,667
time.Date(2024, 7, 15, 14, 0, 0, 0, time.UTC), // + 1,666,667
time.Date(2024, 8, 15, 14, 0, 0, 0, time.UTC), // + 1,666,667
time.Date(2024, 9, 15, 14, 0, 0, 0, time.UTC), // + 1,666,667 *** Year FOUR ***
}
circSupply := sdk.ZeroInt()
blockTime := ctx.BlockTime()
switch {
case blockTime.Before(supplyIncreaseDates[0]):
circSupply = sdkmath.NewInt(0)
case blockTime.After(supplyIncreaseDates[0]) && blockTime.Before(supplyIncreaseDates[1]) || blockTime.Equal(supplyIncreaseDates[0]):
circSupply = sdkmath.NewInt(30000000) // Start year ONE
case blockTime.After(supplyIncreaseDates[1]) && blockTime.Before(supplyIncreaseDates[2]) || blockTime.Equal(supplyIncreaseDates[1]):
circSupply = sdkmath.NewInt(35000000)
case blockTime.After(supplyIncreaseDates[2]) && blockTime.Before(supplyIncreaseDates[3]) || blockTime.Equal(supplyIncreaseDates[2]):
circSupply = sdkmath.NewInt(40000000)
case blockTime.After(supplyIncreaseDates[3]) && blockTime.Before(supplyIncreaseDates[4]) || blockTime.Equal(supplyIncreaseDates[3]):
circSupply = sdkmath.NewInt(47708334)
case blockTime.After(supplyIncreaseDates[4]) && blockTime.Before(supplyIncreaseDates[5]) || blockTime.Equal(supplyIncreaseDates[4]):
circSupply = sdkmath.NewInt(51041667)
case blockTime.After(supplyIncreaseDates[5]) && blockTime.Before(supplyIncreaseDates[6]) || blockTime.Equal(supplyIncreaseDates[5]):
circSupply = sdkmath.NewInt(54375000)
case blockTime.After(supplyIncreaseDates[6]) && blockTime.Before(supplyIncreaseDates[7]) || blockTime.Equal(supplyIncreaseDates[6]):
circSupply = sdkmath.NewInt(61250000)
case blockTime.After(supplyIncreaseDates[7]) && blockTime.Before(supplyIncreaseDates[8]) || blockTime.Equal(supplyIncreaseDates[7]):
circSupply = sdkmath.NewInt(63750000)
case blockTime.After(supplyIncreaseDates[8]) && blockTime.Before(supplyIncreaseDates[9]) || blockTime.Equal(supplyIncreaseDates[8]):
circSupply = sdkmath.NewInt(66250000)
case blockTime.After(supplyIncreaseDates[9]) && blockTime.Before(supplyIncreaseDates[10]) || blockTime.Equal(supplyIncreaseDates[9]):
circSupply = sdkmath.NewInt(73125000)
case blockTime.After(supplyIncreaseDates[10]) && blockTime.Before(supplyIncreaseDates[11]) || blockTime.Equal(supplyIncreaseDates[10]):
circSupply = sdkmath.NewInt(75625000)
case blockTime.After(supplyIncreaseDates[11]) && blockTime.Before(supplyIncreaseDates[12]) || blockTime.Equal(supplyIncreaseDates[11]):
circSupply = sdkmath.NewInt(78125000) // End year ONE
case blockTime.After(supplyIncreaseDates[12]) && blockTime.Before(supplyIncreaseDates[13]) || blockTime.Equal(supplyIncreaseDates[12]):
circSupply = sdkmath.NewInt(91666667) // Start year TWO
case blockTime.After(supplyIncreaseDates[13]) && blockTime.Before(supplyIncreaseDates[14]) || blockTime.Equal(supplyIncreaseDates[13]):
circSupply = sdkmath.NewInt(94166667)
case blockTime.After(supplyIncreaseDates[14]) && blockTime.Before(supplyIncreaseDates[15]) || blockTime.Equal(supplyIncreaseDates[14]):
circSupply = sdkmath.NewInt(96666667)
case blockTime.After(supplyIncreaseDates[15]) && blockTime.Before(supplyIncreaseDates[16]) || blockTime.Equal(supplyIncreaseDates[15]):
circSupply = sdkmath.NewInt(105208334)
case blockTime.After(supplyIncreaseDates[16]) && blockTime.Before(supplyIncreaseDates[17]) || blockTime.Equal(supplyIncreaseDates[16]):
circSupply = sdkmath.NewInt(107708334)
case blockTime.After(supplyIncreaseDates[17]) && blockTime.Before(supplyIncreaseDates[18]) || blockTime.Equal(supplyIncreaseDates[17]):
circSupply = sdkmath.NewInt(110208334)
case blockTime.After(supplyIncreaseDates[18]) && blockTime.Before(supplyIncreaseDates[19]) || blockTime.Equal(supplyIncreaseDates[18]):
circSupply = sdkmath.NewInt(118750000)
case blockTime.After(supplyIncreaseDates[19]) && blockTime.Before(supplyIncreaseDates[20]) || blockTime.Equal(supplyIncreaseDates[19]):
circSupply = sdkmath.NewInt(121250000)
case blockTime.After(supplyIncreaseDates[20]) && blockTime.Before(supplyIncreaseDates[21]) || blockTime.Equal(supplyIncreaseDates[20]):
circSupply = sdkmath.NewInt(123750000)
case blockTime.After(supplyIncreaseDates[21]) && blockTime.Before(supplyIncreaseDates[22]) || blockTime.Equal(supplyIncreaseDates[21]):
circSupply = sdkmath.NewInt(132291668)
case blockTime.After(supplyIncreaseDates[22]) && blockTime.Before(supplyIncreaseDates[23]) || blockTime.Equal(supplyIncreaseDates[22]):
circSupply = sdkmath.NewInt(134791668)
case blockTime.After(supplyIncreaseDates[23]) && blockTime.Before(supplyIncreaseDates[24]) || blockTime.Equal(supplyIncreaseDates[23]):
circSupply = sdkmath.NewInt(137291668) // End year TWO
case blockTime.After(supplyIncreaseDates[24]) && blockTime.Before(supplyIncreaseDates[25]) || blockTime.Equal(supplyIncreaseDates[24]):
circSupply = sdkmath.NewInt(145833335) // Start year THREE
case blockTime.After(supplyIncreaseDates[25]) && blockTime.Before(supplyIncreaseDates[26]) || blockTime.Equal(supplyIncreaseDates[25]):
circSupply = sdkmath.NewInt(148333335)
case blockTime.After(supplyIncreaseDates[26]) && blockTime.Before(supplyIncreaseDates[27]) || blockTime.Equal(supplyIncreaseDates[26]):
circSupply = sdkmath.NewInt(150833335)
case blockTime.After(supplyIncreaseDates[27]) && blockTime.Before(supplyIncreaseDates[28]) || blockTime.Equal(supplyIncreaseDates[27]):
circSupply = sdkmath.NewInt(155000000)
case blockTime.After(supplyIncreaseDates[28]) && blockTime.Before(supplyIncreaseDates[29]) || blockTime.Equal(supplyIncreaseDates[28]):
circSupply = sdkmath.NewInt(157500000)
case blockTime.After(supplyIncreaseDates[29]) && blockTime.Before(supplyIncreaseDates[30]) || blockTime.Equal(supplyIncreaseDates[29]):
circSupply = sdkmath.NewInt(160000000)
case blockTime.After(supplyIncreaseDates[30]) && blockTime.Before(supplyIncreaseDates[31]) || blockTime.Equal(supplyIncreaseDates[30]):
circSupply = sdkmath.NewInt(164166669)
case blockTime.After(supplyIncreaseDates[31]) && blockTime.Before(supplyIncreaseDates[32]) || blockTime.Equal(supplyIncreaseDates[31]):
circSupply = sdkmath.NewInt(166666669)
case blockTime.After(supplyIncreaseDates[32]) && blockTime.Before(supplyIncreaseDates[33]) || blockTime.Equal(supplyIncreaseDates[32]):
circSupply = sdkmath.NewInt(169166669)
case blockTime.After(supplyIncreaseDates[33]) && blockTime.Before(supplyIncreaseDates[34]) || blockTime.Equal(supplyIncreaseDates[33]):
circSupply = sdkmath.NewInt(173333336)
case blockTime.After(supplyIncreaseDates[34]) && blockTime.Before(supplyIncreaseDates[35]) || blockTime.Equal(supplyIncreaseDates[34]):
circSupply = sdkmath.NewInt(175833336)
case blockTime.After(supplyIncreaseDates[35]) && blockTime.Before(supplyIncreaseDates[36]) || blockTime.Equal(supplyIncreaseDates[35]):
circSupply = sdkmath.NewInt(178333336) // End year THREE
case blockTime.After(supplyIncreaseDates[36]) && blockTime.Before(supplyIncreaseDates[37]) || blockTime.Equal(supplyIncreaseDates[36]):
circSupply = sdkmath.NewInt(181666670) // Start year FOUR
case blockTime.After(supplyIncreaseDates[37]) && blockTime.Before(supplyIncreaseDates[38]) || blockTime.Equal(supplyIncreaseDates[37]):
circSupply = sdkmath.NewInt(183333337)
case blockTime.After(supplyIncreaseDates[38]) && blockTime.Before(supplyIncreaseDates[39]) || blockTime.Equal(supplyIncreaseDates[38]):
circSupply = sdkmath.NewInt(185000000)
case blockTime.After(supplyIncreaseDates[39]) && blockTime.Before(supplyIncreaseDates[40]) || blockTime.Equal(supplyIncreaseDates[39]):
circSupply = sdkmath.NewInt(186666670)
case blockTime.After(supplyIncreaseDates[40]) && blockTime.Before(supplyIncreaseDates[41]) || blockTime.Equal(supplyIncreaseDates[40]):
circSupply = sdkmath.NewInt(188333338)
case blockTime.After(supplyIncreaseDates[41]) && blockTime.Before(supplyIncreaseDates[42]) || blockTime.Equal(supplyIncreaseDates[41]):
circSupply = sdkmath.NewInt(190000000)
case blockTime.After(supplyIncreaseDates[42]) && blockTime.Before(supplyIncreaseDates[43]) || blockTime.Equal(supplyIncreaseDates[42]):
circSupply = sdkmath.NewInt(191666670)
case blockTime.After(supplyIncreaseDates[43]) && blockTime.Before(supplyIncreaseDates[44]) || blockTime.Equal(supplyIncreaseDates[43]):
circSupply = sdkmath.NewInt(193333339)
case blockTime.After(supplyIncreaseDates[44]) && blockTime.Before(supplyIncreaseDates[45]) || blockTime.Equal(supplyIncreaseDates[44]):
circSupply = sdkmath.NewInt(195000000)
case blockTime.After(supplyIncreaseDates[45]) && blockTime.Before(supplyIncreaseDates[46]) || blockTime.Equal(supplyIncreaseDates[45]):
circSupply = sdkmath.NewInt(196666670)
case blockTime.After(supplyIncreaseDates[46]) && blockTime.Before(supplyIncreaseDates[47]) || blockTime.Equal(supplyIncreaseDates[46]):
circSupply = sdkmath.NewInt(198333340)
case blockTime.After(supplyIncreaseDates[47]) && blockTime.Before(supplyIncreaseDates[48]) || blockTime.Equal(supplyIncreaseDates[47]):
circSupply = sdkmath.NewInt(200000000) // End year FOUR
default:
circSupply = sdkmath.NewInt(200000000)
}
return &types.QueryCirculatingSupplyHARDResponse{
Amount: circSupply,
}, nil
}
// CirculatingSupplyUSDX returns the total amount of usdx tokens in circulation
func (s queryServer) CirculatingSupplyUSDX(c context.Context, req *types.QueryCirculatingSupplyUSDXRequest) (*types.QueryCirculatingSupplyUSDXResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
totalSupply := s.bk.GetSupply(ctx, "usdx").Amount
supplyInt := sdk.NewDecFromInt(totalSupply).Mul(sdk.MustNewDecFromStr("0.000001")).TruncateInt()
return &types.QueryCirculatingSupplyUSDXResponse{
Amount: supplyInt,
}, nil
}
// CirculatingSupplySWP returns the total amount of swp tokens in circulation
func (s queryServer) CirculatingSupplySWP(c context.Context, req *types.QueryCirculatingSupplySWPRequest) (*types.QueryCirculatingSupplySWPResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
// Start values
year := 2021
month := 8
var supplyIncreaseDates []time.Time
// Add month times for 4 years
for i := 0; i < 12*4; i++ {
// Always day 30 unless it's Feb
day := 30
if month == 2 {
day = 28
}
date := time.Date(year, time.Month(month), day, 15 /* hour */, 0, 0, 0, time.UTC)
supplyIncreaseDates = append(supplyIncreaseDates, date)
// Update year and month
if month == 12 {
month = 1
year += 1
} else {
month += 1
}
}
// Repeated tokens released
teamSwp := int64(4_687_500)
treasurySwp := int64(5_859_375)
monthlyStakersSwp := int64(520_833)
monthlyLPIncentivesSwp := int64(2_343_750)
// []{Ecosystem, Team, Treasury, Kava Stakers, LP Incentives}
scheduleAmounts := [][]int64{
{12_500_000, 0, 15_625_000, monthlyStakersSwp, monthlyLPIncentivesSwp}, // *** Year ONE ***
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 1
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 2
{0, 0, treasurySwp, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 3
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 4
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 5
{0, 0, treasurySwp, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 6
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 7
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 8
{0, 0, treasurySwp, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 9
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 10
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 11
{0, 18_750_000, treasurySwp, monthlyStakersSwp, monthlyLPIncentivesSwp}, // *** Year TWO ***
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 13
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 14
{0, teamSwp, treasurySwp, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 15
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 16
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 17
{0, teamSwp, treasurySwp, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 18
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 19
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 20
{0, teamSwp, treasurySwp, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 21
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 22
{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp}, // 23
{0, teamSwp, treasurySwp, monthlyStakersSwp, monthlyLPIncentivesSwp}, // *** Year THREE ***
}
// Months 25-47 are the same
for i := 0; i < 23; i++ {
scheduleAmounts = append(scheduleAmounts, []int64{0, 0, 0, monthlyStakersSwp, monthlyLPIncentivesSwp})
}
circSupply := sdk.ZeroInt()
blockTime := ctx.BlockTime()
for i := 0; i < len(scheduleAmounts); i++ {
if blockTime.Before(supplyIncreaseDates[i]) {
break
}
// Sum up each category of token release
monthTotal := int64(0)
for _, val := range scheduleAmounts[i] {
monthTotal += val
}
circSupply = circSupply.Add(sdkmath.NewInt(monthTotal))
}
return &types.QueryCirculatingSupplySWPResponse{
Amount: circSupply,
}, nil
}
// TotalSupplyHARD returns the total amount of hard tokens
func (s queryServer) TotalSupplyHARD(c context.Context, req *types.QueryTotalSupplyHARDRequest) (*types.QueryTotalSupplyHARDResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
totalSupply := s.bk.GetSupply(ctx, "hard").Amount
supplyInt := sdk.NewDecFromInt(totalSupply).Mul(sdk.MustNewDecFromStr("0.000001")).TruncateInt()
return &types.QueryTotalSupplyHARDResponse{
Amount: supplyInt,
}, nil
}
// TotalSupplyUSDX returns the total amount of usdx tokens
func (s queryServer) TotalSupplyUSDX(c context.Context, req *types.QueryTotalSupplyUSDXRequest) (*types.QueryTotalSupplyUSDXResponse, error) {
// USDX total supply is the circulating supply
rsp, err := s.CirculatingSupplyUSDX(c, &types.QueryCirculatingSupplyUSDXRequest{})
if err != nil {
return nil, err
}
return &types.QueryTotalSupplyUSDXResponse{
Amount: rsp.Amount,
}, nil
}
func getCirculatingSupply(blockTime time.Time, totalSupply sdkmath.Int) sdkmath.Int {
vestingDates := []time.Time{
time.Date(2022, 2, 5, 14, 0, 0, 0, time.UTC),
time.Date(2022, 5, 5, 14, 0, 0, 0, time.UTC),
time.Date(2022, 8, 5, 14, 0, 0, 0, time.UTC),
time.Date(2022, 11, 5, 14, 0, 0, 0, time.UTC),
}
switch {
case blockTime.Before(vestingDates[0]):
return sdk.NewDecFromInt(totalSupply.Sub(sdkmath.NewInt(9937500000000))).Mul(sdk.MustNewDecFromStr("0.000001")).RoundInt()
case blockTime.After(vestingDates[0]) && blockTime.Before(vestingDates[1]) || blockTime.Equal(vestingDates[0]):
return sdk.NewDecFromInt(totalSupply.Sub(sdkmath.NewInt(7453125000000))).Mul(sdk.MustNewDecFromStr("0.000001")).RoundInt()
case blockTime.After(vestingDates[1]) && blockTime.Before(vestingDates[2]) || blockTime.Equal(vestingDates[1]):
return sdk.NewDecFromInt(totalSupply.Sub(sdkmath.NewInt(4968750000000))).Mul(sdk.MustNewDecFromStr("0.000001")).RoundInt()
case blockTime.After(vestingDates[2]) && blockTime.Before(vestingDates[3]) || blockTime.Equal(vestingDates[2]):
return sdk.NewDecFromInt(totalSupply.Sub(sdkmath.NewInt(2484375000000))).Mul(sdk.MustNewDecFromStr("0.000001")).RoundInt()
default:
// align with total supply calculation and truncate int here instead of round
return sdk.NewDecFromInt(totalSupply).Mul(sdk.MustNewDecFromStr("0.000001")).TruncateInt()
}
}

View File

@ -0,0 +1,116 @@
package keeper_test
import (
"context"
"testing"
"time"
sdkmath "cosmossdk.io/math"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtime "github.com/cometbft/cometbft/types/time"
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/suite"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/validator-vesting/keeper"
"github.com/kava-labs/kava/x/validator-vesting/types"
)
type grpcQueryTestSuite struct {
suite.Suite
app app.TestApp
ctx sdk.Context
queryClient types.QueryClient
bk *mockBankKeeper
}
type mockBankKeeper struct {
supply sdk.Coin
}
func (m *mockBankKeeper) SetSupply(ctx sdk.Context, denom string, amt sdkmath.Int) {
m.supply = sdk.NewCoin(denom, amt)
}
func (m *mockBankKeeper) GetSupply(ctx sdk.Context, denom string) sdk.Coin {
return m.supply
}
func (suite *grpcQueryTestSuite) SetupTest() {
tApp := app.NewTestApp()
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
suite.app = tApp
suite.ctx = ctx
suite.bk = &mockBankKeeper{}
suite.queryClient = suite.queryClientWithBlockTime(tmtime.Now())
}
func TestGrpcQueryTestSuite(t *testing.T) {
suite.Run(t, new(grpcQueryTestSuite))
}
func (suite *grpcQueryTestSuite) TestCirculatingSupply() {
suite.Run("vesting period supply", func() {
suite.bk.SetSupply(suite.ctx, "ukava", sdkmath.NewInt(2_500_000_000_000))
lastVestingPeriod := time.Date(2022, 8, 5, 24, 0, 0, 0, time.UTC)
queryClient := suite.queryClientWithBlockTime(lastVestingPeriod)
res, err := queryClient.CirculatingSupply(context.Background(), &types.QueryCirculatingSupplyRequest{})
suite.Require().NoError(err)
suite.Require().Equal(sdkmath.NewInt(15_625), res.Amount)
})
suite.Run("supply after last vesting period", func() {
suite.bk.SetSupply(suite.ctx, "ukava", sdkmath.NewInt(100_000_000))
res, err := suite.queryClient.CirculatingSupply(context.Background(), &types.QueryCirculatingSupplyRequest{})
suite.Require().NoError(err)
suite.Require().Equal(sdkmath.NewInt(100), res.Amount)
})
}
func (suite *grpcQueryTestSuite) TestTotalSupply() {
suite.bk.SetSupply(suite.ctx, "ukava", sdkmath.NewInt(100_000_000))
res, err := suite.queryClient.TotalSupply(context.Background(), &types.QueryTotalSupplyRequest{})
suite.Require().NoError(err)
suite.Require().Equal(sdkmath.NewInt(100), res.Amount)
}
func (suite *grpcQueryTestSuite) TestCirculatingSupplyHARD() {
res, err := suite.queryClient.CirculatingSupplyHARD(context.Background(), &types.QueryCirculatingSupplyHARDRequest{})
suite.Require().NoError(err)
suite.Require().Equal(sdkmath.NewInt(188333338), res.Amount)
}
func (suite *grpcQueryTestSuite) TestCirculatingSupplyUSDX() {
suite.bk.SetSupply(suite.ctx, "usdx", sdkmath.NewInt(150_000_000))
res, err := suite.queryClient.CirculatingSupplyUSDX(context.Background(), &types.QueryCirculatingSupplyUSDXRequest{})
suite.Require().NoError(err)
suite.Require().Equal(sdkmath.NewInt(150), res.Amount)
}
func (suite *grpcQueryTestSuite) TestCirculatingSupplySWP() {
res, err := suite.queryClient.CirculatingSupplySWP(context.Background(), &types.QueryCirculatingSupplySWPRequest{})
suite.Require().NoError(err)
suite.Require().Equal(sdkmath.NewInt(198437490), res.Amount)
}
func (suite *grpcQueryTestSuite) TestTotalSupplyHARD() {
suite.bk.SetSupply(suite.ctx, "hard", sdkmath.NewInt(150_000_000))
res, err := suite.queryClient.TotalSupplyHARD(context.Background(), &types.QueryTotalSupplyHARDRequest{})
suite.Require().NoError(err)
suite.Require().Equal(sdkmath.NewInt(150), res.Amount)
}
func (suite *grpcQueryTestSuite) TestTotalSupplyUSDX() {
suite.bk.SetSupply(suite.ctx, "usdx", sdkmath.NewInt(150_000_000))
res, err := suite.queryClient.TotalSupplyUSDX(context.Background(), &types.QueryTotalSupplyUSDXRequest{})
suite.Require().NoError(err)
suite.Require().Equal(sdkmath.NewInt(150), res.Amount)
}
func (suite *grpcQueryTestSuite) queryClientWithBlockTime(blockTime time.Time) types.QueryClient {
ctx := suite.ctx.WithBlockTime(blockTime)
queryHelper := baseapp.NewQueryServerTestHelper(ctx, suite.app.InterfaceRegistry())
types.RegisterQueryServer(queryHelper, keeper.NewQueryServerImpl(suite.bk))
return types.NewQueryClient(queryHelper)
}

View File

@ -1,6 +1,7 @@
package validator_vesting
import (
"context"
"encoding/json"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
@ -15,6 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/kava-labs/kava/x/validator-vesting/client/cli"
"github.com/kava-labs/kava/x/validator-vesting/keeper"
"github.com/kava-labs/kava/x/validator-vesting/types"
)
@ -54,7 +56,11 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
}
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for validator-vesting module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {}
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil {
panic(err)
}
}
// GetTxCmd returns validator-vesting module's root tx command.
func (a AppModuleBasic) GetTxCmd() *cobra.Command { return nil }
@ -90,7 +96,9 @@ func (am AppModule) Name() string {
// RegisterServices registers a GRPC query service to respond to the
// module-specific GRPC queries.
func (am AppModule) RegisterServices(cfg module.Configurator) {}
func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.bankKeeper))
}
// RegisterInvariants registers validator-vesting module's invariants.
func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}

View File

@ -1,26 +0,0 @@
package types
// Querier routes for the validator vesting module
const (
QueryCirculatingSupply = "circulating-supply"
QueryTotalSupply = "total-supply"
QueryCirculatingSupplyHARD = "circulating-supply-hard"
QueryCirculatingSupplyUSDX = "circulating-supply-usdx"
QueryCirculatingSupplySWP = "circulating-supply-swp"
QueryTotalSupplyHARD = "total-supply-hard"
QueryTotalSupplyUSDX = "total-supply-usdx"
)
// BaseQueryParams defines the parameters necessary for querying for all Evidence.
type BaseQueryParams struct {
Page int `json:"page" yaml:"page"`
Limit int `json:"limit" yaml:"limit"`
}
// NewBaseQueryParams returns a new BaseQueryParams
func NewBaseQueryParams(page, limit int) BaseQueryParams {
return BaseQueryParams{
Page: page,
Limit: limit,
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,543 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: kava/validatorvesting/v1beta1/query.proto
/*
Package types is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package types
import (
"context"
"io"
"net/http"
"github.com/golang/protobuf/descriptor"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)
// Suppress "imported and not used" errors
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = descriptor.ForMessage
var _ = metadata.Join
func request_Query_CirculatingSupply_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryCirculatingSupplyRequest
var metadata runtime.ServerMetadata
msg, err := client.CirculatingSupply(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_CirculatingSupply_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryCirculatingSupplyRequest
var metadata runtime.ServerMetadata
msg, err := server.CirculatingSupply(ctx, &protoReq)
return msg, metadata, err
}
func request_Query_TotalSupply_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryTotalSupplyRequest
var metadata runtime.ServerMetadata
msg, err := client.TotalSupply(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_TotalSupply_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryTotalSupplyRequest
var metadata runtime.ServerMetadata
msg, err := server.TotalSupply(ctx, &protoReq)
return msg, metadata, err
}
func request_Query_CirculatingSupplyHARD_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryCirculatingSupplyHARDRequest
var metadata runtime.ServerMetadata
msg, err := client.CirculatingSupplyHARD(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_CirculatingSupplyHARD_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryCirculatingSupplyHARDRequest
var metadata runtime.ServerMetadata
msg, err := server.CirculatingSupplyHARD(ctx, &protoReq)
return msg, metadata, err
}
func request_Query_CirculatingSupplyUSDX_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryCirculatingSupplyUSDXRequest
var metadata runtime.ServerMetadata
msg, err := client.CirculatingSupplyUSDX(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_CirculatingSupplyUSDX_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryCirculatingSupplyUSDXRequest
var metadata runtime.ServerMetadata
msg, err := server.CirculatingSupplyUSDX(ctx, &protoReq)
return msg, metadata, err
}
func request_Query_CirculatingSupplySWP_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryCirculatingSupplySWPRequest
var metadata runtime.ServerMetadata
msg, err := client.CirculatingSupplySWP(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_CirculatingSupplySWP_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryCirculatingSupplySWPRequest
var metadata runtime.ServerMetadata
msg, err := server.CirculatingSupplySWP(ctx, &protoReq)
return msg, metadata, err
}
func request_Query_TotalSupplyHARD_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryTotalSupplyHARDRequest
var metadata runtime.ServerMetadata
msg, err := client.TotalSupplyHARD(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_TotalSupplyHARD_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryTotalSupplyHARDRequest
var metadata runtime.ServerMetadata
msg, err := server.TotalSupplyHARD(ctx, &protoReq)
return msg, metadata, err
}
func request_Query_TotalSupplyUSDX_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryTotalSupplyUSDXRequest
var metadata runtime.ServerMetadata
msg, err := client.TotalSupplyUSDX(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_TotalSupplyUSDX_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryTotalSupplyUSDXRequest
var metadata runtime.ServerMetadata
msg, err := server.TotalSupplyUSDX(ctx, &protoReq)
return msg, metadata, err
}
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
// UnaryRPC :call QueryServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
mux.Handle("GET", pattern_Query_CirculatingSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_CirculatingSupply_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_CirculatingSupply_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_TotalSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_TotalSupply_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_TotalSupply_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_CirculatingSupplyHARD_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_CirculatingSupplyHARD_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_CirculatingSupplyHARD_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_CirculatingSupplyUSDX_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_CirculatingSupplyUSDX_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_CirculatingSupplyUSDX_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_CirculatingSupplySWP_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_CirculatingSupplySWP_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_CirculatingSupplySWP_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_TotalSupplyHARD_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_TotalSupplyHARD_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_TotalSupplyHARD_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_TotalSupplyUSDX_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_TotalSupplyUSDX_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_TotalSupplyUSDX_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.Dial(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterQueryHandler(ctx, mux, conn)
}
// RegisterQueryHandler registers the http handlers for service Query to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
}
// RegisterQueryHandlerClient registers the http handlers for service Query
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "QueryClient" to call the correct interceptors.
func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
mux.Handle("GET", pattern_Query_CirculatingSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_CirculatingSupply_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_CirculatingSupply_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_TotalSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_TotalSupply_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_TotalSupply_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_CirculatingSupplyHARD_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_CirculatingSupplyHARD_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_CirculatingSupplyHARD_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_CirculatingSupplyUSDX_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_CirculatingSupplyUSDX_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_CirculatingSupplyUSDX_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_CirculatingSupplySWP_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_CirculatingSupplySWP_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_CirculatingSupplySWP_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_TotalSupplyHARD_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_TotalSupplyHARD_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_TotalSupplyHARD_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_TotalSupplyUSDX_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_TotalSupplyUSDX_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_TotalSupplyUSDX_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Query_CirculatingSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "validator-vesting", "v1beta1", "circulating_supply"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_TotalSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "validator-vesting", "v1beta1", "total_supply"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_CirculatingSupplyHARD_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "validator-vesting", "v1beta1", "circulating_supply_hard"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_CirculatingSupplyUSDX_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "validator-vesting", "v1beta1", "circulating_supply_usdx"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_CirculatingSupplySWP_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "validator-vesting", "v1beta1", "circulating_supply_swp"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_TotalSupplyHARD_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "validator-vesting", "v1beta1", "total_supply_hard"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_TotalSupplyUSDX_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "validator-vesting", "v1beta1", "total_supply_usdx"}, "", runtime.AssumeColonVerbOpt(false)))
)
var (
forward_Query_CirculatingSupply_0 = runtime.ForwardResponseMessage
forward_Query_TotalSupply_0 = runtime.ForwardResponseMessage
forward_Query_CirculatingSupplyHARD_0 = runtime.ForwardResponseMessage
forward_Query_CirculatingSupplyUSDX_0 = runtime.ForwardResponseMessage
forward_Query_CirculatingSupplySWP_0 = runtime.ForwardResponseMessage
forward_Query_TotalSupplyHARD_0 = runtime.ForwardResponseMessage
forward_Query_TotalSupplyUSDX_0 = runtime.ForwardResponseMessage
)