diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f07eeeb53f3..99dff3b43adc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * `MsgCreateValidator.Pubkey` type changed from `string` to `codectypes.Any`. * (client) [\#8926](https://github.com/cosmos/cosmos-sdk/pull/8926) `client/tx.PrepareFactory` has been converted to a private function, as it's only used internally. * (auth/tx) [\#8926](https://github.com/cosmos/cosmos-sdk/pull/8926) The `ProtoTxProvider` interface used as a workaround for transaction simulation has been removed. +* (x/bank) [\#8798](https://github.com/cosmos/cosmos-sdk/pull/8798) `GetTotalSupply` is removed in favour of `GetPaginatedTotalSupply` ### State Machine Breaking @@ -88,6 +89,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/bank) [\#8656](https://github.com/cosmos/cosmos-sdk/pull/8656) balance and supply are now correctly tracked via `coin_spent`, `coin_received`, `coinbase` and `burn` events. * (x/bank) [\#8517](https://github.com/cosmos/cosmos-sdk/pull/8517) Supply is now stored and tracked as `sdk.Coins` * (store) [\#8790](https://github.com/cosmos/cosmos-sdk/pull/8790) Reduce gas costs by 10x for transient store operations. +* (x/bank) [\#9051](https://github.com/cosmos/cosmos-sdk/pull/9051) Supply value is stored as `sdk.Int` rather than `string`. ### Improvements diff --git a/Dockerfile b/Dockerfile index 973fcf2a7b43..af8b4c1febce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ FROM golang:alpine AS build-env # Install minimum necessary dependencies, -ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3 plantuml +ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3 RUN apk add --no-cache $PACKAGES # Set working directory for the build diff --git a/docs/ibc/overview.md b/docs/ibc/overview.md index 958769aee7dc..89bfb3d27c64 100644 --- a/docs/ibc/overview.md +++ b/docs/ibc/overview.md @@ -46,7 +46,7 @@ In IBC, blockchains do not directly pass messages to each other over the network - A relayer process monitors for updates to these paths and relays messages by submitting the data stored under the path along with a proof of that data to the counterparty chain. -- The paths that all IBC implementations must support for committing IBC messages are defined in [ICS-24 host requirements](https://github.com/cosmos/ics/tree/master/spec/ics-024-host-requirements). +- The paths that all IBC implementations must support for committing IBC messages are defined in [ICS-24 host requirements](https://github.com/cosmos/ics/tree/master/spec/core/ics-024-host-requirements). - The proof format that all implementations must produce and verify is defined in [ICS-23 implementation](https://github.com/confio/ics23). diff --git a/proto/cosmos/bank/v1beta1/query.proto b/proto/cosmos/bank/v1beta1/query.proto index bc5e29137a95..e3a464f8baac 100644 --- a/proto/cosmos/bank/v1beta1/query.proto +++ b/proto/cosmos/bank/v1beta1/query.proto @@ -90,7 +90,13 @@ message QueryAllBalancesResponse { // QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC // method. -message QueryTotalSupplyRequest {} +message QueryTotalSupplyRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} // QueryTotalSupplyResponse is the response type for the Query/TotalSupply RPC // method @@ -98,6 +104,9 @@ message QueryTotalSupplyResponse { // supply is the supply of the coins repeated cosmos.base.v1beta1.Coin supply = 1 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; } // QuerySupplyOfRequest is the request type for the Query/SupplyOf RPC method. diff --git a/types/query/pagination.go b/types/query/pagination.go index 868571f861cf..9d9431faba11 100644 --- a/types/query/pagination.go +++ b/types/query/pagination.go @@ -2,6 +2,7 @@ package query import ( "fmt" + "math" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -14,6 +15,10 @@ import ( // if the `limit` is not supplied, paginate will use `DefaultLimit` const DefaultLimit = 100 +// MaxLimit is the maximum limit the paginate function can handle +// which equals the maximum value that can be stored in uint64 +const MaxLimit = math.MaxUint64 + // ParsePagination validate PageRequest and returns page number & limit. func ParsePagination(pageReq *PageRequest) (page, limit int, err error) { offset := 0 diff --git a/x/bank/client/cli/cli_test.go b/x/bank/client/cli/cli_test.go index 19325b430c17..60b8c504b57d 100644 --- a/x/bank/client/cli/cli_test.go +++ b/x/bank/client/cli/cli_test.go @@ -187,7 +187,9 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() { Supply: sdk.NewCoins( sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens), sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))), - )}, + ), + Pagination: &query.PageResponse{Total: 2}, + }, }, { name: "total supply of a specific denomination", diff --git a/x/bank/client/cli/query.go b/x/bank/client/cli/query.go index a192c8deba1b..4019bb738d9a 100644 --- a/x/bank/client/cli/query.go +++ b/x/bank/client/cli/query.go @@ -183,8 +183,13 @@ To query for the total supply of a specific coin denomination use: queryClient := types.NewQueryClient(clientCtx) ctx := cmd.Context() + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } if denom == "" { - res, err := queryClient.TotalSupply(ctx, &types.QueryTotalSupplyRequest{}) + res, err := queryClient.TotalSupply(ctx, &types.QueryTotalSupplyRequest{Pagination: pageReq}) if err != nil { return err } diff --git a/x/bank/client/rest/grpc_query_test.go b/x/bank/client/rest/grpc_query_test.go index 438cca5294d8..b32b9386d514 100644 --- a/x/bank/client/rest/grpc_query_test.go +++ b/x/bank/client/rest/grpc_query_test.go @@ -38,6 +38,9 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() { sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens), sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))), ), + Pagination: &query.PageResponse{ + Total: 2, + }, }, }, { diff --git a/x/bank/client/rest/query_test.go b/x/bank/client/rest/query_test.go index 0201e6763125..a9e43a53db86 100644 --- a/x/bank/client/rest/query_test.go +++ b/x/bank/client/rest/query_test.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -155,11 +156,14 @@ func (s *IntegrationTestSuite) TestTotalSupplyHandlerFn() { { "total supply", fmt.Sprintf("%s/bank/total?height=1", baseURL), - &sdk.Coins{}, - sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens), - sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))), - ), + &types.QueryTotalSupplyResponse{}, + &types.QueryTotalSupplyResponse{ + Supply: sdk.NewCoins( + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens), + sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))), + ), + Pagination: &query.PageResponse{Total: 2}, + }, }, { "total supply of a specific denom", diff --git a/x/bank/keeper/genesis.go b/x/bank/keeper/genesis.go index 375f44787dfa..712e2f5d19ed 100644 --- a/x/bank/keeper/genesis.go +++ b/x/bank/keeper/genesis.go @@ -4,6 +4,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -42,10 +43,15 @@ func (k BaseKeeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { // ExportGenesis returns the bank module's genesis state. func (k BaseKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + totalSupply, _, err := k.GetPaginatedTotalSupply(ctx, &query.PageRequest{Limit: query.MaxLimit}) + if err != nil { + panic(fmt.Errorf("unable to fetch total supply %v", err)) + } + return types.NewGenesisState( k.GetParams(ctx), k.GetAccountsBalances(ctx), - k.GetTotalSupply(ctx), + totalSupply, k.GetAllDenomMetaData(ctx), ) } diff --git a/x/bank/keeper/genesis_test.go b/x/bank/keeper/genesis_test.go index 7793140396f2..5adb2174133a 100644 --- a/x/bank/keeper/genesis_test.go +++ b/x/bank/keeper/genesis_test.go @@ -2,6 +2,7 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/x/bank/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) @@ -106,7 +107,9 @@ func (suite *IntegrationTestSuite) TestTotalSupply() { suite.PanicsWithError(tc.expPanicMsg, func() { suite.app.BankKeeper.InitGenesis(suite.ctx, tc.genesis) }) } else { suite.app.BankKeeper.InitGenesis(suite.ctx, tc.genesis) - suite.Require().Equal(tc.expSupply, suite.app.BankKeeper.GetTotalSupply(suite.ctx)) + totalSupply, _, err := suite.app.BankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) + suite.Require().NoError(err) + suite.Require().Equal(tc.expSupply, totalSupply) } }) } diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index fa385e3cb468..356cc4596b04 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -77,11 +77,14 @@ func (k BaseKeeper) AllBalances(ctx context.Context, req *types.QueryAllBalances } // TotalSupply implements the Query/TotalSupply gRPC method -func (k BaseKeeper) TotalSupply(ctx context.Context, _ *types.QueryTotalSupplyRequest) (*types.QueryTotalSupplyResponse, error) { +func (k BaseKeeper) TotalSupply(ctx context.Context, req *types.QueryTotalSupplyRequest) (*types.QueryTotalSupplyResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) - totalSupply := k.GetTotalSupply(sdkCtx) + totalSupply, pageRes, err := k.GetPaginatedTotalSupply(sdkCtx, req.Pagination) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } - return &types.QueryTotalSupplyResponse{Supply: totalSupply}, nil + return &types.QueryTotalSupplyResponse{Supply: totalSupply, Pagination: pageRes}, nil } // SupplyOf implements the Query/SupplyOf gRPC method diff --git a/x/bank/keeper/invariants.go b/x/bank/keeper/invariants.go index 6b4716ecb36f..52da98381fc6 100644 --- a/x/bank/keeper/invariants.go +++ b/x/bank/keeper/invariants.go @@ -4,6 +4,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -50,7 +51,12 @@ func NonnegativeBalanceInvariant(k ViewKeeper) sdk.Invariant { func TotalSupply(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { expectedTotal := sdk.Coins{} - supply := k.GetTotalSupply(ctx) + supply, _, err := k.GetPaginatedTotalSupply(ctx, &query.PageRequest{Limit: query.MaxLimit}) + + if err != nil { + return sdk.FormatInvariant(types.ModuleName, "query supply", + fmt.Sprintf("error querying total supply %v", err)), false + } k.IterateAllBalances(ctx, func(_ sdk.AccAddress, balance sdk.Coin) bool { expectedTotal = expectedTotal.Add(balance) diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index bb3bd1080c9c..34eb434c6fba 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -1,10 +1,13 @@ package keeper import ( + "fmt" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/query" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -22,9 +25,8 @@ type Keeper interface { ExportGenesis(sdk.Context) *types.GenesisState GetSupply(ctx sdk.Context, denom string) sdk.Coin - GetTotalSupply(ctx sdk.Context) sdk.Coins + GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.PageRequest) (sdk.Coins, *query.PageResponse, error) IterateTotalSupply(ctx sdk.Context, cb func(sdk.Coin) bool) - 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) @@ -53,14 +55,27 @@ type BaseKeeper struct { paramSpace paramtypes.Subspace } -func (k BaseKeeper) GetTotalSupply(ctx sdk.Context) sdk.Coins { - balances := sdk.NewCoins() - k.IterateTotalSupply(ctx, func(balance sdk.Coin) bool { - balances = balances.Add(balance) - return false +func (k BaseKeeper) GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.PageRequest) (sdk.Coins, *query.PageResponse, error) { + store := ctx.KVStore(k.storeKey) + supplyStore := prefix.NewStore(store, types.SupplyKey) + + supply := sdk.NewCoins() + + pageRes, err := query.Paginate(supplyStore, pagination, func(key, value []byte) error { + var amount sdk.Int + err := amount.Unmarshal(value) + if err != nil { + return fmt.Errorf("unable to convert amount string to Int %v", err) + } + supply = append(supply, sdk.NewCoin(string(key), amount)) + return nil }) - return balances.Sort() + if err != nil { + return nil, nil, err + } + + return supply, pageRes, nil } // NewBaseKeeper returns a new BaseKeeper object with a given codec, dedicated @@ -184,9 +199,10 @@ func (k BaseKeeper) GetSupply(ctx sdk.Context, denom string) sdk.Coin { } } - amount, ok := sdk.NewIntFromString(string(bz)) - if !ok { - panic("unexpected supply") + var amount sdk.Int + err := amount.Unmarshal(bz) + if err != nil { + panic(fmt.Errorf("unable to unmarshal supply value %v", err)) } return sdk.Coin{ @@ -413,7 +429,11 @@ func (k BaseKeeper) setSupply(ctx sdk.Context, coin sdk.Coin) { store := ctx.KVStore(k.storeKey) supplyStore := prefix.NewStore(store, types.SupplyKey) - supplyStore.Set([]byte(coin.GetDenom()), []byte(coin.Amount.String())) + intBytes, err := coin.Amount.Marshal() + if err != nil { + panic(fmt.Errorf("unable to marshal amount value %v", err)) + } + supplyStore.Set([]byte(coin.GetDenom()), intBytes) } func (k BaseKeeper) trackDelegation(ctx sdk.Context, addr sdk.AccAddress, balance, amt sdk.Coins) error { @@ -454,9 +474,10 @@ func (k BaseViewKeeper) IterateTotalSupply(ctx sdk.Context, cb func(sdk.Coin) bo defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - amount, ok := sdk.NewIntFromString(string(iterator.Value())) - if !ok { - panic("unexpected supply") + var amount sdk.Int + err := amount.Unmarshal(iterator.Value()) + if err != nil { + panic(fmt.Errorf("unable to unmarshal supply value %v", err)) } balance := sdk.Coin{ diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 33e65b9780fe..52d32db4fc7f 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "github.com/cosmos/cosmos-sdk/types/query" "testing" "time" @@ -93,7 +94,8 @@ func (suite *IntegrationTestSuite) TestSupply() { totalSupply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens)) suite.NoError(app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, totalSupply)) - total := app.BankKeeper.GetTotalSupply(ctx) + total, _, err := app.BankKeeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) + suite.Require().NoError(err) suite.Require().Equal(totalSupply, total) } @@ -224,12 +226,13 @@ func (suite *IntegrationTestSuite) TestSupply_MintCoins() { authKeeper.SetModuleAccount(ctx, multiPermAcc) authKeeper.SetModuleAccount(ctx, randomPermAcc) - initialSupply := keeper.GetTotalSupply(ctx) + initialSupply, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) + suite.Require().NoError(err) suite.Require().Panics(func() { keeper.MintCoins(ctx, "", initCoins) }, "no module account") // nolint:errcheck suite.Require().Panics(func() { keeper.MintCoins(ctx, authtypes.Burner, initCoins) }, "invalid permission") // nolint:errcheck - err := keeper.MintCoins(ctx, authtypes.Minter, sdk.Coins{sdk.Coin{Denom: "denom", Amount: sdk.NewInt(-10)}}) + err = keeper.MintCoins(ctx, authtypes.Minter, sdk.Coins{sdk.Coin{Denom: "denom", Amount: sdk.NewInt(-10)}}) suite.Require().Error(err, "insufficient coins") suite.Require().Panics(func() { keeper.MintCoins(ctx, randomPerm, initCoins) }) // nolint:errcheck @@ -238,16 +241,22 @@ func (suite *IntegrationTestSuite) TestSupply_MintCoins() { suite.Require().NoError(err) suite.Require().Equal(initCoins, getCoinsByName(ctx, keeper, authKeeper, authtypes.Minter)) - suite.Require().Equal(initialSupply.Add(initCoins...), keeper.GetTotalSupply(ctx)) + totalSupply, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) + suite.Require().NoError(err) + + suite.Require().Equal(initialSupply.Add(initCoins...), totalSupply) // test same functionality on module account with multiple permissions - initialSupply = keeper.GetTotalSupply(ctx) + initialSupply, _, err = keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) + suite.Require().NoError(err) err = keeper.MintCoins(ctx, multiPermAcc.GetName(), initCoins) suite.Require().NoError(err) + totalSupply, _, err = keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) + suite.Require().NoError(err) suite.Require().Equal(initCoins, getCoinsByName(ctx, keeper, authKeeper, multiPermAcc.GetName())) - suite.Require().Equal(initialSupply.Add(initCoins...), keeper.GetTotalSupply(ctx)) + suite.Require().Equal(initialSupply.Add(initCoins...), totalSupply) suite.Require().Panics(func() { keeper.MintCoins(ctx, authtypes.Burner, initCoins) }) // nolint:errcheck } @@ -286,32 +295,37 @@ func (suite *IntegrationTestSuite) TestSupply_BurnCoins() { suite. Require(). NoError(keeper.MintCoins(ctx, authtypes.Minter, initCoins)) - supplyAfterInflation := keeper.GetTotalSupply(ctx) + supplyAfterInflation, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) suite.Require().Panics(func() { keeper.BurnCoins(ctx, "", initCoins) }, "no module account") // nolint:errcheck suite.Require().Panics(func() { keeper.BurnCoins(ctx, authtypes.Minter, initCoins) }, "invalid permission") // nolint:errcheck suite.Require().Panics(func() { keeper.BurnCoins(ctx, randomPerm, supplyAfterInflation) }, "random permission") // nolint:errcheck - err := keeper.BurnCoins(ctx, authtypes.Burner, supplyAfterInflation) + err = keeper.BurnCoins(ctx, authtypes.Burner, supplyAfterInflation) suite.Require().Error(err, "insufficient coins") err = keeper.BurnCoins(ctx, authtypes.Burner, initCoins) suite.Require().NoError(err) + supplyAfterBurn, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) + suite.Require().NoError(err) suite.Require().Equal(sdk.NewCoins().String(), getCoinsByName(ctx, keeper, authKeeper, authtypes.Burner).String()) - suite.Require().Equal(supplyAfterInflation.Sub(initCoins), keeper.GetTotalSupply(ctx)) + suite.Require().Equal(supplyAfterInflation.Sub(initCoins), supplyAfterBurn) // test same functionality on module account with multiple permissions suite. Require(). NoError(keeper.MintCoins(ctx, authtypes.Minter, initCoins)) - supplyAfterInflation = keeper.GetTotalSupply(ctx) + supplyAfterInflation, _, err = keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) + suite.Require().NoError(err) suite.Require().NoError(keeper.SendCoins(ctx, authtypes.NewModuleAddress(authtypes.Minter), multiPermAcc.GetAddress(), initCoins)) authKeeper.SetModuleAccount(ctx, multiPermAcc) err = keeper.BurnCoins(ctx, multiPermAcc.GetName(), initCoins) + supplyAfterBurn, _, err = keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) + suite.Require().NoError(err) suite.Require().NoError(err) suite.Require().Equal(sdk.NewCoins().String(), getCoinsByName(ctx, keeper, authKeeper, multiPermAcc.GetName()).String()) - suite.Require().Equal(supplyAfterInflation.Sub(initCoins), keeper.GetTotalSupply(ctx)) + suite.Require().Equal(supplyAfterInflation.Sub(initCoins), supplyAfterBurn) } func (suite *IntegrationTestSuite) TestSendCoinsNewAccount() { diff --git a/x/bank/keeper/querier.go b/x/bank/keeper/querier.go index dca5414f45fd..e64321b6c0a8 100644 --- a/x/bank/keeper/querier.go +++ b/x/bank/keeper/querier.go @@ -3,7 +3,6 @@ package keeper import ( abci "github.com/tendermint/tendermint/abci/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -77,25 +76,24 @@ func queryAllBalance(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQue } func queryTotalSupply(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryTotalSupplyParams + var params types.QueryTotalSupplyRequest err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } - // TODO: paginate - // https://github.com/cosmos/cosmos-sdk/issues/8761 - totalSupply := k.GetTotalSupply(ctx) + totalSupply, pageRes, err := k.GetPaginatedTotalSupply(ctx, params.Pagination) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) + } - start, end := client.Paginate(len(totalSupply), params.Page, params.Limit, 100) - if start < 0 || end < 0 { - totalSupply = sdk.Coins{} - } else { - totalSupply = totalSupply[start:end] + supplyRes := &types.QueryTotalSupplyResponse{ + Supply: totalSupply, + Pagination: pageRes, } - res, err := legacyQuerierCdc.MarshalJSON(totalSupply) + res, err := codec.MarshalJSONIndent(legacyQuerierCdc, supplyRes) if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } diff --git a/x/bank/keeper/querier_test.go b/x/bank/keeper/querier_test.go index 3f1e2cb49e84..14270fbf0f80 100644 --- a/x/bank/keeper/querier_test.go +++ b/x/bank/keeper/querier_test.go @@ -3,16 +3,15 @@ package keeper_test import ( "fmt" - "github.com/cosmos/cosmos-sdk/simapp" - - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - abci "github.com/tendermint/tendermint/abci/types" + "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/bank/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) func (suite *IntegrationTestSuite) TestQuerier_QueryBalance() { @@ -107,14 +106,16 @@ func (suite *IntegrationTestSuite) TestQuerier_QueryTotalSupply() { suite.Require().NotNil(err) suite.Require().Nil(res) - req.Data = legacyAmino.MustMarshalJSON(types.NewQueryTotalSupplyParams(1, 100)) + req.Data = legacyAmino.MustMarshalJSON(types.QueryTotalSupplyRequest{Pagination: &query.PageRequest{ + Limit: 100, + }}) res, err = querier(ctx, []string{types.QueryTotalSupply}, req) suite.Require().NoError(err) suite.Require().NotNil(res) - var resp sdk.Coins + var resp types.QueryTotalSupplyResponse suite.Require().NoError(legacyAmino.UnmarshalJSON(res, &resp)) - suite.Require().Equal(expectedTotalSupply, resp) + suite.Require().Equal(expectedTotalSupply, resp.Supply) } func (suite *IntegrationTestSuite) TestQuerier_QueryTotalSupplyOf() { diff --git a/x/bank/legacy/v043/store.go b/x/bank/legacy/v043/store.go index 6dbc3ceab97f..dfd021abd9ea 100644 --- a/x/bank/legacy/v043/store.go +++ b/x/bank/legacy/v043/store.go @@ -35,7 +35,7 @@ func migrateSupply(store sdk.KVStore, cdc codec.BinaryMarshaler) error { oldSupply := oldSupplyI.(*types.Supply) for i := range oldSupply.Total { coin := oldSupply.Total[i] - coinBz, err := cdc.MarshalBinaryBare(&coin) + coinBz, err := coin.Amount.Marshal() if err != nil { return err } diff --git a/x/bank/legacy/v043/store_test.go b/x/bank/legacy/v043/store_test.go index 145db59f16cc..5f61e33dffde 100644 --- a/x/bank/legacy/v043/store_test.go +++ b/x/bank/legacy/v043/store_test.go @@ -36,12 +36,26 @@ func TestSupplyMigration(t *testing.T) { require.NoError(t, err) // New supply is indexed by denom. - var newFooCoin, newBarCoin sdk.Coin supplyStore := prefix.NewStore(store, types.SupplyKey) - encCfg.Marshaler.MustUnmarshalBinaryBare(supplyStore.Get([]byte("foo")), &newFooCoin) - encCfg.Marshaler.MustUnmarshalBinaryBare(supplyStore.Get([]byte("bar")), &newBarCoin) + bz := supplyStore.Get([]byte("foo")) + var amount sdk.Int + err = amount.Unmarshal(bz) + require.NoError(t, err) + newFooCoin := sdk.Coin{ + Denom: "foo", + Amount: amount, + } require.Equal(t, oldFooCoin, newFooCoin) + + bz = supplyStore.Get([]byte("bar")) + err = amount.Unmarshal(bz) + require.NoError(t, err) + + newBarCoin := sdk.Coin{ + Denom: "bar", + Amount: amount, + } require.Equal(t, oldBarCoin, newBarCoin) } diff --git a/x/bank/spec/01_state.md b/x/bank/spec/01_state.md index 4b8a512489e6..5328e8b3caee 100644 --- a/x/bank/spec/01_state.md +++ b/x/bank/spec/01_state.md @@ -7,6 +7,6 @@ order: 1 The `x/bank` module keeps state of three primary objects, account balances, denom metadata and the total supply of all balances. -- Supply: `0x0 | byte(denom) -> ProtocolBuffer(coin)` +- Supply: `0x0 | byte(denom) -> byte(amount)` - Denom Metadata: `0x1 | byte(denom) -> ProtocolBuffer(Metadata)` - Balances: `0x2 | byte(address length) | []byte(address) | []byte(balance.Denom) -> ProtocolBuffer(balance)` diff --git a/x/bank/types/query.pb.go b/x/bank/types/query.pb.go index c4bedb0098c5..5ad95812ba8c 100644 --- a/x/bank/types/query.pb.go +++ b/x/bank/types/query.pb.go @@ -219,6 +219,8 @@ func (m *QueryAllBalancesResponse) GetPagination() *query.PageResponse { // QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC // method. type QueryTotalSupplyRequest struct { + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *QueryTotalSupplyRequest) Reset() { *m = QueryTotalSupplyRequest{} } @@ -259,6 +261,8 @@ var xxx_messageInfo_QueryTotalSupplyRequest proto.InternalMessageInfo type QueryTotalSupplyResponse struct { // supply is the supply of the coins Supply github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=supply,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"supply"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *QueryTotalSupplyResponse) Reset() { *m = QueryTotalSupplyResponse{} } @@ -301,6 +305,13 @@ func (m *QueryTotalSupplyResponse) GetSupply() github_com_cosmos_cosmos_sdk_type return nil } +func (m *QueryTotalSupplyResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + // QuerySupplyOfRequest is the request type for the Query/SupplyOf RPC method. type QuerySupplyOfRequest struct { // denom is the coin denom to query balances for. @@ -690,59 +701,59 @@ func init() { func init() { proto.RegisterFile("cosmos/bank/v1beta1/query.proto", fileDescriptor_9c6fc1939682df13) } var fileDescriptor_9c6fc1939682df13 = []byte{ - // 824 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcf, 0x6b, 0x13, 0x5b, - 0x14, 0xce, 0xed, 0x7b, 0x4d, 0xd3, 0x13, 0xde, 0x5b, 0xdc, 0xe6, 0xf1, 0xd2, 0xe9, 0x6b, 0xf2, - 0x98, 0x6a, 0x9b, 0xd6, 0x74, 0xa6, 0x69, 0x85, 0xa2, 0x1b, 0x69, 0x2a, 0xba, 0x10, 0x69, 0x8c, - 0xae, 0x04, 0x91, 0x9b, 0x64, 0x1c, 0x43, 0x93, 0xb9, 0xd3, 0xdc, 0x89, 0x58, 0x4a, 0x51, 0x04, - 0xc1, 0x95, 0x0a, 0x2e, 0x5c, 0xb8, 0xa9, 0x1b, 0x41, 0x97, 0xfe, 0x15, 0x5d, 0xb8, 0x28, 0xb8, - 0x71, 0xa5, 0xd2, 0xba, 0xf0, 0xcf, 0x90, 0xdc, 0x1f, 0xd3, 0x49, 0x32, 0x4d, 0x06, 0xd1, 0x55, - 0x66, 0xee, 0x3d, 0xe7, 0x3b, 0xdf, 0x77, 0xee, 0xb9, 0xdf, 0x04, 0xb2, 0x55, 0xca, 0x9a, 0x94, - 0x99, 0x15, 0xe2, 0x6c, 0x9a, 0xf7, 0x0a, 0x15, 0xcb, 0x23, 0x05, 0x73, 0xab, 0x6d, 0xb5, 0xb6, - 0x0d, 0xb7, 0x45, 0x3d, 0x8a, 0x27, 0x44, 0x80, 0xd1, 0x09, 0x30, 0x64, 0x80, 0xb6, 0xe0, 0x67, - 0x31, 0x4b, 0x44, 0xfb, 0xb9, 0x2e, 0xb1, 0xeb, 0x0e, 0xf1, 0xea, 0xd4, 0x11, 0x00, 0x5a, 0xca, - 0xa6, 0x36, 0xe5, 0x8f, 0x66, 0xe7, 0x49, 0xae, 0xfe, 0x67, 0x53, 0x6a, 0x37, 0x2c, 0x93, 0xb8, - 0x75, 0x93, 0x38, 0x0e, 0xf5, 0x78, 0x0a, 0x93, 0xbb, 0x99, 0x20, 0xbe, 0x42, 0xae, 0xd2, 0xba, - 0xd3, 0xb7, 0x1f, 0x60, 0xcd, 0x19, 0xf2, 0x7d, 0x7d, 0x03, 0x26, 0xae, 0x75, 0x58, 0x15, 0x49, - 0x83, 0x38, 0x55, 0xab, 0x6c, 0x6d, 0xb5, 0x2d, 0xe6, 0xe1, 0x34, 0x8c, 0x91, 0x5a, 0xad, 0x65, - 0x31, 0x96, 0x46, 0xff, 0xa3, 0xdc, 0x78, 0x59, 0xbd, 0xe2, 0x14, 0x8c, 0xd6, 0x2c, 0x87, 0x36, - 0xd3, 0x23, 0x7c, 0x5d, 0xbc, 0x9c, 0x4f, 0x3c, 0xd9, 0xcb, 0xc6, 0xbe, 0xef, 0x65, 0x63, 0xfa, - 0x15, 0x48, 0x75, 0x03, 0x32, 0x97, 0x3a, 0xc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 0xb6, 0xe3, 0x0d, - 0x9d, 0xb6, 0xe2, 0x9f, 0x1d, 0xae, 0x65, 0x19, 0xae, 0xa7, 0x00, 0x73, 0xc4, 0x12, 0x69, 0x91, - 0xa6, 0x1a, 0x36, 0xbd, 0x24, 0xaf, 0x89, 0x5a, 0x95, 0x55, 0xce, 0x41, 0xdc, 0xe5, 0x2b, 0xb2, - 0xca, 0x94, 0x11, 0xe2, 0x01, 0x86, 0x48, 0x52, 0x75, 0x44, 0x82, 0x5e, 0x03, 0x8d, 0x23, 0x5e, - 0xec, 0xe8, 0x60, 0x57, 0x2d, 0x8f, 0xd4, 0x88, 0x47, 0x94, 0xda, 0xee, 0x11, 0x46, 0x3f, 0x3b, - 0xc2, 0xfa, 0x5b, 0x04, 0x53, 0xa1, 0x65, 0xa4, 0x80, 0x35, 0x18, 0x6f, 0xca, 0x35, 0x35, 0xbc, - 0xd3, 0xa1, 0x1a, 0x54, 0xa6, 0x54, 0x71, 0x9c, 0xf5, 0xeb, 0xa6, 0xb2, 0x00, 0x93, 0xc7, 0x54, - 0x7b, 0x1b, 0x12, 0x7e, 0xfc, 0xb7, 0x82, 0x4d, 0xec, 0x13, 0x77, 0x01, 0x12, 0x8a, 0xa6, 0x6c, - 0x61, 0x24, 0x6d, 0x7e, 0xd2, 0xf2, 0xfb, 0x04, 0x8c, 0x72, 0x7c, 0xfc, 0x12, 0xc1, 0x98, 0xbc, - 0xf8, 0x38, 0x17, 0x0a, 0x12, 0xe2, 0xa2, 0xda, 0x7c, 0x84, 0x48, 0xc1, 0x55, 0x5f, 0x7d, 0xf4, - 0xf1, 0xdb, 0x8b, 0x91, 0x02, 0x36, 0xcd, 0x70, 0xc3, 0x16, 0x16, 0x60, 0xee, 0x48, 0x8f, 0xdb, - 0x35, 0x77, 0x78, 0x07, 0x76, 0xf1, 0x2b, 0x04, 0xc9, 0x80, 0x2b, 0xe1, 0xfc, 0xc9, 0x35, 0xfb, - 0x4d, 0x54, 0x5b, 0x8c, 0x18,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, 0x00, 0xff, 0xff, - 0xb4, 0xd4, 0xb0, 0xfc, 0x75, 0x0a, 0x00, 0x00, + // 825 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4d, 0x6f, 0xd3, 0x58, + 0x14, 0xcd, 0xeb, 0x4c, 0xd3, 0xf4, 0x46, 0x33, 0x8b, 0xd7, 0x8c, 0x26, 0x75, 0xa7, 0xc9, 0xc8, + 0x9d, 0x69, 0xd3, 0x92, 0xda, 0x4d, 0x8b, 0x54, 0xc1, 0x06, 0x35, 0x45, 0xb0, 0x40, 0xa8, 0x21, + 0xb0, 0x42, 0x42, 0xe8, 0x25, 0x31, 0x26, 0x6a, 0xe2, 0xe7, 0xe6, 0x39, 0x88, 0xaa, 0xaa, 0x84, + 0x90, 0x90, 0x58, 0x01, 0x12, 0x0b, 0x16, 0x6c, 0xca, 0x06, 0x09, 0x96, 0xfc, 0x8a, 0x2e, 0x58, + 0x54, 0x62, 0xc3, 0x0a, 0x50, 0xcb, 0x82, 0x9f, 0x81, 0xf2, 0x3e, 0x5c, 0x27, 0x71, 0x13, 0x2f, + 0xc2, 0x2a, 0xf6, 0xf5, 0xfd, 0x38, 0xe7, 0x3c, 0xdf, 0xe3, 0x40, 0xb6, 0x4a, 0x59, 0x93, 0x32, + 0xb3, 0x42, 0x9c, 0x6d, 0xf3, 0x41, 0xa1, 0x62, 0x79, 0xa4, 0x60, 0xee, 0xb4, 0xad, 0xd6, 0xae, + 0xe1, 0xb6, 0xa8, 0x47, 0xf1, 0x94, 0x48, 0x30, 0x3a, 0x09, 0x86, 0x4c, 0xd0, 0x96, 0xfc, 0x2a, + 0x66, 0x89, 0x6c, 0xbf, 0xd6, 0x25, 0x76, 0xdd, 0x21, 0x5e, 0x9d, 0x3a, 0xa2, 0x81, 0x96, 0xb2, + 0xa9, 0x4d, 0xf9, 0xa5, 0xd9, 0xb9, 0x92, 0xd1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0xcd, 0x86, 0x72, 0x50, 0x95, 0x92, 0xc5, 0x69, 0xd5, 0xe8, 0x4e, 0xbe, 0x00, 0xd3, + 0xa7, 0x50, 0x7b, 0x05, 0x09, 0x3f, 0xfe, 0x3b, 0x41, 0x11, 0xfb, 0xc8, 0x5d, 0x82, 0x84, 0x82, + 0x29, 0x25, 0x8c, 0xc4, 0xcd, 0x2f, 0x5a, 0xfd, 0x90, 0x80, 0x71, 0xde, 0x1f, 0xbf, 0x42, 0x30, + 0x21, 0x4d, 0x09, 0xe7, 0x42, 0x9b, 0x84, 0x38, 0xbc, 0xb6, 0x18, 0x21, 0x53, 0x60, 0xd5, 0xd7, + 0x1f, 0x7f, 0xfa, 0xfe, 0x72, 0xac, 0x80, 0x4d, 0x33, 0xfc, 0x63, 0x22, 0xec, 0xc9, 0xdc, 0x93, + 0xfe, 0xbb, 0x6f, 0xee, 0x71, 0x05, 0xf6, 0xf1, 0x6b, 0x04, 0xc9, 0x80, 0x63, 0xe2, 0xfc, 0xd9, + 0x33, 0xfb, 0x0d, 0x5e, 0x5b, 0x8e, 0x98, 0x2d, 0x51, 0x9a, 0x1c, 0xe5, 0x22, 0x5e, 0x88, 0x88, + 0x12, 0x3f, 0x47, 0x90, 0x0c, 0x78, 0xd2, 0x20, 0x74, 0xfd, 0x46, 0x39, 0x08, 0x5d, 0x88, 0xd1, + 0xe9, 0x73, 0x1c, 0xdd, 0x2c, 0x9e, 0x09, 0x45, 0x27, 0x8d, 0xea, 0x19, 0x82, 0x84, 0x72, 0x0b, + 0x3c, 0xe0, 0x80, 0x7a, 0xfc, 0x47, 0x5b, 0x8a, 0x92, 0x2a, 0x81, 0x9c, 0xe3, 0x40, 0xfe, 0xc7, + 0x73, 0x03, 0x80, 0xf8, 0x07, 0xf8, 0x08, 0x41, 0x5c, 0x38, 0x04, 0x5e, 0x38, 0x7b, 0x46, 0x97, + 0x1d, 0x69, 0xb9, 0xe1, 0x89, 0x91, 0x34, 0x11, 0x5e, 0x84, 0xdf, 0x22, 0xf8, 0xa3, 0x6b, 0x85, + 0xb0, 0x71, 0xf6, 0x80, 0xb0, 0xf5, 0xd4, 0xcc, 0xc8, 0xf9, 0x12, 0xd7, 0x79, 0x8e, 0xcb, 0xc0, + 0xf9, 0x50, 0x5c, 0x5c, 0x1a, 0x76, 0x57, 0x2d, 0xa2, 0xaf, 0xd5, 0x1b, 0x04, 0x7f, 0x76, 0x3b, + 0x19, 0x1e, 0x36, 0xb9, 0xd7, 0x5a, 0xb5, 0x95, 0xe8, 0x05, 0x12, 0x6b, 0x9e, 0x63, 0x9d, 0xc7, + 0xff, 0x45, 0xc1, 0x5a, 0xdc, 0x3c, 0x3c, 0xce, 0xa0, 0xa3, 0xe3, 0x0c, 0xfa, 0x76, 0x9c, 0x41, + 0x2f, 0x4e, 0x32, 0xb1, 0xa3, 0x93, 0x4c, 0xec, 0xf3, 0x49, 0x26, 0x76, 0x7b, 0x71, 0xe0, 0x57, + 0xf5, 0xa1, 0x68, 0xcb, 0x3f, 0xae, 0x95, 0x38, 0xff, 0xe7, 0xb8, 0xf6, 0x33, 0x00, 0x00, 0xff, + 0xff, 0xa0, 0xfe, 0xe2, 0x92, 0x11, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1238,6 +1249,18 @@ func (m *QueryTotalSupplyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -1261,6 +1284,18 @@ func (m *QueryTotalSupplyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error _ = i var l int _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } if len(m.Supply) > 0 { for iNdEx := len(m.Supply) - 1; iNdEx >= 0; iNdEx-- { { @@ -1627,6 +1662,10 @@ func (m *QueryTotalSupplyRequest) Size() (n int) { } var l int _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -1642,6 +1681,10 @@ func (m *QueryTotalSupplyResponse) Size() (n int) { n += 1 + l + sovQuery(uint64(l)) } } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -2218,6 +2261,42 @@ func (m *QueryTotalSupplyRequest) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: QueryTotalSupplyRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2302,6 +2381,42 @@ func (m *QueryTotalSupplyResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/bank/types/query.pb.gw.go b/x/bank/types/query.pb.gw.go index 3dec93b8b363..8b8ed9a52607 100644 --- a/x/bank/types/query.pb.gw.go +++ b/x/bank/types/query.pb.gw.go @@ -179,10 +179,21 @@ func local_request_Query_AllBalances_0(ctx context.Context, marshaler runtime.Ma } +var ( + filter_Query_TotalSupply_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + 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 + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TotalSupply_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.TotalSupply(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -192,6 +203,13 @@ func local_request_Query_TotalSupply_0(ctx context.Context, marshaler runtime.Ma var protoReq QueryTotalSupplyRequest var metadata runtime.ServerMetadata + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TotalSupply_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.TotalSupply(ctx, &protoReq) return msg, metadata, err