Skip to content

Commit

Permalink
adding denomOwners to v6.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gsk967 committed Apr 29, 2024
1 parent 269f3b8 commit 9f9072e
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 54 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ func New(
app.UIbcQuotaKeeperB = uibcquota.NewKeeperBuilder(
appCodec, keys[uibc.StoreKey],
app.LeverageKeeper, uibcoracle.FromUmeeAvgPriceOracle(app.OracleKeeper), app.UGovKeeperB.EmergencyGroup,
app.BankKeeper,
)

/**********
Expand Down
10 changes: 10 additions & 0 deletions proto/umee/uibc/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "cosmos/bank/v1beta1/query.proto";

import "umee/uibc/v1/quota.proto";
import "umee/uibc/v1/uibc.proto";

Expand Down Expand Up @@ -40,6 +42,14 @@ service Query {
rpc QuotaExpires(QueryQuotaExpires) returns (QueryQuotaExpiresResponse) {
option (google.api.http).get = "/umee/uibc/v1/quota_expires";
}

// DenomOwners queries for all account addresses that own a particular token
// denomination.
// For historical state data, height have to pass as a grpc headers request here
// check here: https://docs.cosmos.network/v0.50/user/run-node/interact-node#query-for-historical-state-using-grpcurl
rpc DenomOwners(cosmos.bank.v1beta1.QueryDenomOwnersRequest) returns (cosmos.bank.v1beta1.QueryDenomOwnersResponse){
option (google.api.http).get = "/umee/uibc/v1/denom_owners";
}
}

// QueryAllInflows defines request type for query the inflow quota of registered denoms.
Expand Down
33 changes: 33 additions & 0 deletions x/uibc/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/spf13/cobra"

"github.com/umee-network/umee/v6/util/cli"
"github.com/umee-network/umee/v6/x/uibc"
)
Expand All @@ -25,6 +27,7 @@ func GetQueryCmd() *cobra.Command {
GetOutflows(),
GetInflows(),
GetQuotaExpireTime(),
QueryDenomOwners(),
)

return cmd
Expand Down Expand Up @@ -130,3 +133,33 @@ func GetOutflows() *cobra.Command {
flags.AddQueryFlagsToCmd(cmd)
return cmd
}

// QueryDenomOwners creates the Query/DenomOwners CLI.
func QueryDenomOwners() *cobra.Command {
cmd := &cobra.Command{
Use: "denom-owners [denom]",
Args: cobra.ExactArgs(1),
Short: "Queries for all account addresses that own a particular token denomination.",
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 := uibc.NewQueryClient(clientCtx)
resp, err := queryClient.DenomOwners(cmd.Context(), &banktypes.QueryDenomOwnersRequest{
Denom: args[0],
Pagination: pageReq,
})
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)
flags.AddPaginationFlagsToCmd(cmd, "denom-owners")

return cmd
}
6 changes: 6 additions & 0 deletions x/uibc/expected_keepers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package uibc

import (
context "context"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank/types"

Expand All @@ -12,6 +14,10 @@ type BankKeeper interface {
GetDenomMetaData(ctx sdk.Context, denom string) (types.Metadata, bool)
SetDenomMetaData(ctx sdk.Context, denomMetaData types.Metadata)
IterateAllDenomMetaData(ctx sdk.Context, cb func(types.Metadata) bool)
DenomOwners(
goCtx context.Context,
req *types.QueryDenomOwnersRequest,
) (*types.QueryDenomOwnersResponse, error)
}

type Leverage interface {
Expand Down
137 changes: 93 additions & 44 deletions x/uibc/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9f9072e

Please sign in to comment.