Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: adding denomOwners to v6.4.0 #2512

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 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
2 changes: 1 addition & 1 deletion x/oracle/keeper/historic_price.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

median, err := decmath.Median(historicPrices)
if err != nil {
return errors.Wrap(err, "denom: "+denom) //nolint: goconst
return errors.Wrap(err, "denom: "+denom)

Check warning on line 48 in x/oracle/keeper/historic_price.go

View check run for this annotation

Codecov / codecov/patch

x/oracle/keeper/historic_price.go#L48

Added line #L48 was not covered by tests
}

block := uint64(ctx.BlockHeight())
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
Loading