Skip to content

Commit

Permalink
feat: add support for spendable balances gRPC query (backport cosmos#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored and Eengineer1 committed Aug 26, 2022
1 parent 187c014 commit eb21bbf
Show file tree
Hide file tree
Showing 7 changed files with 648 additions and 666 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features

* (x/bank) [\#11417](https://github.com/cosmos/cosmos-sdk/pull/11417) Introduce a new `SpendableBalances` gRPC query that retrieves an account's total (paginated) spendable balances.
* (x/bank) [\#10771](https://github.com/cosmos/cosmos-sdk/pull/10771) Add safety check on bank module perms to allow module-specific mint restrictions (e.g. only minting a certain denom).
* (x/bank) [\#10771](https://github.com/cosmos/cosmos-sdk/pull/10771) Add `bank.BankKeeper.WithMintCoinsRestriction` function to restrict use of bank `MintCoins` usage. This function is not on the bank `Keeper` interface, so it's not API-breaking, but only additive on the keeper implementation.
* [\#11124](https://github.com/cosmos/cosmos-sdk/pull/11124) Add `GetAllVersions` to application store
Expand Down
90 changes: 5 additions & 85 deletions proto/cosmos/bank/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/bank/v1beta1/bank.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types";

Expand All @@ -24,8 +23,6 @@ service Query {

// SpendableBalances queries the spenable balance of all coins for a single
// account.
//
// Since: cosmos-sdk 0.46
rpc SpendableBalances(QuerySpendableBalancesRequest) returns (QuerySpendableBalancesResponse) {
option (google.api.http).get = "/cosmos/bank/v1beta1/spendable_balances/{address}";
}
Expand All @@ -37,7 +34,7 @@ service Query {

// SupplyOf queries the supply of a single coin.
rpc SupplyOf(QuerySupplyOfRequest) returns (QuerySupplyOfResponse) {
option (google.api.http).get = "/cosmos/bank/v1beta1/supply/by_denom";
option (google.api.http).get = "/cosmos/bank/v1beta1/supply/{denom}";
}

// Params queries the parameters of x/bank module.
Expand All @@ -50,30 +47,10 @@ service Query {
option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata/{denom}";
}

// DenomsMetadata queries the client metadata for all registered coin
// denominations.
// DenomsMetadata queries the client metadata for all registered coin denominations.
rpc DenomsMetadata(QueryDenomsMetadataRequest) returns (QueryDenomsMetadataResponse) {
option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata";
}

// DenomOwners queries for all account addresses that own a particular token
// denomination.
//
// Since: cosmos-sdk 0.46
rpc DenomOwners(QueryDenomOwnersRequest) returns (QueryDenomOwnersResponse) {
option (google.api.http).get = "/cosmos/bank/v1beta1/denom_owners/{denom}";
}

// SendEnabled queries for SendEnabled entries.
//
// This query only returns denominations that have specific SendEnabled settings.
// Any denomination that does not have a specific setting will use the default
// params.default_send_enabled, and will not be returned by this query.
//
// Since: cosmos-sdk 0.47
rpc SendEnabled(QuerySendEnabledRequest) returns (QuerySendEnabledResponse) {
option (google.api.http).get = "/cosmos/bank/v1beta1/send_enabled";
}
}

// QueryBalanceRequest is the request type for the Query/Balance RPC method.
Expand All @@ -82,7 +59,7 @@ message QueryBalanceRequest {
option (gogoproto.goproto_getters) = false;

// address is the address to query balances for.
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string address = 1;

// denom is the coin denom to query balances for.
string denom = 2;
Expand All @@ -100,7 +77,7 @@ message QueryAllBalancesRequest {
option (gogoproto.goproto_getters) = false;

// address is the address to query balances for.
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string address = 1;

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
Expand All @@ -119,23 +96,19 @@ message QueryAllBalancesResponse {

// QuerySpendableBalancesRequest defines the gRPC request structure for querying
// an account's spendable balances.
//
// Since: cosmos-sdk 0.46
message QuerySpendableBalancesRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// address is the address to query spendable balances for.
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string address = 1;

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QuerySpendableBalancesResponse defines the gRPC response structure for querying
// an account's spendable balances.
//
// Since: cosmos-sdk 0.46
message QuerySpendableBalancesResponse {
// balances is the spendable balances of all the coins.
repeated cosmos.base.v1beta1.Coin balances = 1
Expand Down Expand Up @@ -218,56 +191,3 @@ message QueryDenomMetadataResponse {
// metadata describes and provides all the client information for the requested token.
Metadata metadata = 1 [(gogoproto.nullable) = false];
}

// QueryDenomOwnersRequest defines the request type for the DenomOwners RPC query,
// which queries for a paginated set of all account holders of a particular
// denomination.
message QueryDenomOwnersRequest {
// denom defines the coin denomination to query all account holders for.
string denom = 1;

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// DenomOwner defines structure representing an account that owns or holds a
// particular denominated token. It contains the account address and account
// balance of the denominated token.
//
// Since: cosmos-sdk 0.46
message DenomOwner {
// address defines the address that owns a particular denomination.
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// balance is the balance of the denominated coin for an account.
cosmos.base.v1beta1.Coin balance = 2 [(gogoproto.nullable) = false];
}

// QueryDenomOwnersResponse defines the RPC response of a DenomOwners RPC query.
//
// Since: cosmos-sdk 0.46
message QueryDenomOwnersResponse {
repeated DenomOwner denom_owners = 1;

// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QuerySendEnabledRequest defines the RPC request for looking up SendEnabled entries.
//
// Since: cosmos-sdk 0.47
message QuerySendEnabledRequest {
// denoms is the specific denoms you want look up. Leave empty to get all entries.
repeated string denoms = 1;
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 99;
}

// QuerySendEnabledResponse defines the RPC response of a SendEnable query.
//
// Since: cosmos-sdk 0.47
message QuerySendEnabledResponse {
repeated SendEnabled send_enabled = 1;
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 99;
}
Loading

0 comments on commit eb21bbf

Please sign in to comment.