From 241b9be741a225356eef3f2fcfc9bf86414651c9 Mon Sep 17 00:00:00 2001 From: faddat Date: Thu, 14 Oct 2021 03:32:31 +0000 Subject: [PATCH] update bank --- x/bank/app_test.go | 27 +- x/bank/bench_test.go | 21 +- x/bank/client/cli/query.go | 1 - .../grpc.go => rest/grpc_query_test.go} | 26 +- x/bank/client/rest/query.go | 118 +++ x/bank/client/rest/query_test.go | 198 ++++ x/bank/client/rest/rest.go | 19 + x/bank/client/rest/tx.go | 51 ++ x/bank/client/rest/tx_test.go | 107 +++ x/bank/client/testutil/suite.go | 3 +- x/bank/handler.go | 30 + x/bank/handler_test.go | 88 ++ x/bank/keeper/genesis.go | 2 +- x/bank/keeper/genesis_test.go | 20 +- x/bank/keeper/grpc_query.go | 56 +- x/bank/keeper/grpc_query_test.go | 115 +-- x/bank/keeper/keeper.go | 18 +- x/bank/keeper/keeper_test.go | 113 ++- x/bank/keeper/migrations.go | 8 +- x/bank/keeper/querier_test.go | 16 +- x/bank/keeper/send.go | 57 +- x/bank/keeper/view.go | 41 +- x/bank/{migrations => legacy}/v036/types.go | 0 x/bank/{migrations => legacy}/v038/types.go | 0 x/bank/{migrations => legacy}/v040/keys.go | 11 +- x/bank/{migrations => legacy}/v040/migrate.go | 6 +- .../v040/migrate_test.go | 12 +- x/bank/{migrations => legacy}/v040/types.go | 0 x/bank/{migrations => legacy}/v043/json.go | 0 .../{migrations => legacy}/v043/json_test.go | 4 +- x/bank/legacy/v043/keys.go | 12 + x/bank/{migrations => legacy}/v043/store.go | 11 +- .../{migrations => legacy}/v043/store_test.go | 14 +- x/bank/migrations/v043/keys.go | 45 - x/bank/migrations/v045/keys.go | 16 - x/bank/migrations/v045/store.go | 94 -- x/bank/migrations/v045/store_test.go | 129 --- x/bank/module.go | 23 +- x/bank/simulation/operations.go | 4 +- x/bank/simulation/operations_test.go | 5 +- x/bank/spec/01_state.md | 17 +- x/bank/spec/06_client.md | 390 -------- x/bank/spec/README.md | 3 - x/bank/testutil/test_helpers.go | 35 - x/bank/types/authz.pb.go | 6 +- x/bank/types/balance.go | 25 +- x/bank/types/balance_test.go | 35 - x/bank/types/bank.pb.go | 190 +--- x/bank/types/expected_keepers.go | 1 - x/bank/types/genesis.pb.go | 54 +- x/bank/types/key.go | 48 +- x/bank/types/key_test.go | 15 +- x/bank/types/msgs.go | 31 +- x/bank/types/msgs_test.go | 55 +- x/bank/types/params.go | 14 +- x/bank/types/params_test.go | 15 +- x/bank/types/query.pb.go | 867 ++---------------- x/bank/types/query.pb.gw.go | 116 --- x/bank/types/send_authorization_test.go | 2 +- x/bank/types/tx.pb.go | 63 +- 60 files changed, 1076 insertions(+), 2427 deletions(-) rename x/bank/client/{testutil/grpc.go => rest/grpc_query_test.go} (93%) create mode 100644 x/bank/client/rest/query.go create mode 100644 x/bank/client/rest/query_test.go create mode 100644 x/bank/client/rest/rest.go create mode 100644 x/bank/client/rest/tx.go create mode 100644 x/bank/client/rest/tx_test.go create mode 100644 x/bank/handler.go create mode 100644 x/bank/handler_test.go rename x/bank/{migrations => legacy}/v036/types.go (100%) rename x/bank/{migrations => legacy}/v038/types.go (100%) rename x/bank/{migrations => legacy}/v040/keys.go (83%) rename x/bank/{migrations => legacy}/v040/migrate.go (83%) rename x/bank/{migrations => legacy}/v040/migrate_test.go (83%) rename x/bank/{migrations => legacy}/v040/types.go (100%) rename x/bank/{migrations => legacy}/v043/json.go (100%) rename x/bank/{migrations => legacy}/v043/json_test.go (95%) create mode 100644 x/bank/legacy/v043/keys.go rename x/bank/{migrations => legacy}/v043/store.go (89%) rename x/bank/{migrations => legacy}/v043/store_test.go (88%) delete mode 100644 x/bank/migrations/v043/keys.go delete mode 100644 x/bank/migrations/v045/keys.go delete mode 100644 x/bank/migrations/v045/store.go delete mode 100644 x/bank/migrations/v045/store_test.go delete mode 100644 x/bank/spec/06_client.md delete mode 100644 x/bank/testutil/test_helpers.go diff --git a/x/bank/app_test.go b/x/bank/app_test.go index d1e810277edd..ba8085026a5c 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -92,10 +91,10 @@ func TestSendNotEnoughBalance(t *testing.T) { } genAccs := []authtypes.GenesisAccount{acc} - app := simapp.SetupWithGenesisAccounts(t, genAccs) + app := simapp.SetupWithGenesisAccounts(genAccs) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67)))) + require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67)))) app.Commit() @@ -127,10 +126,10 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { } genAccs := []authtypes.GenesisAccount{acc} - app := simapp.SetupWithGenesisAccounts(t, genAccs) + app := simapp.SetupWithGenesisAccounts(genAccs) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67)))) + require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67)))) app.Commit() @@ -197,12 +196,12 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { } genAccs := []authtypes.GenesisAccount{acc1, acc2} - app := simapp.SetupWithGenesisAccounts(t, genAccs) + app := simapp.SetupWithGenesisAccounts(genAccs) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) + require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) - require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) + require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) app.Commit() @@ -246,14 +245,14 @@ func TestMsgMultiSendMultipleInOut(t *testing.T) { } genAccs := []authtypes.GenesisAccount{acc1, acc2, acc4} - app := simapp.SetupWithGenesisAccounts(t, genAccs) + app := simapp.SetupWithGenesisAccounts(genAccs) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) + require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) - require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) + require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) - require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr4, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) + require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr4, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) app.Commit() @@ -293,10 +292,10 @@ func TestMsgMultiSendDependent(t *testing.T) { require.NoError(t, err) genAccs := []authtypes.GenesisAccount{acc1, acc2} - app := simapp.SetupWithGenesisAccounts(t, genAccs) + app := simapp.SetupWithGenesisAccounts(genAccs) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) + require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) app.Commit() diff --git a/x/bank/bench_test.go b/x/bank/bench_test.go index 7503ee671565..4ba2624b7627 100644 --- a/x/bank/bench_test.go +++ b/x/bank/bench_test.go @@ -12,15 +12,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) var moduleAccAddr = authtypes.NewModuleAddress(stakingtypes.BondedPoolName) func BenchmarkOneBankSendTxPerBlock(b *testing.B) { - b.Skip("Skipping benchmark with buggy code reported at https://github.com/cosmos/cosmos-sdk/issues/10023") - b.ReportAllocs() // Add an account at genesis acc := authtypes.BaseAccount{ @@ -29,11 +26,11 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) { // construct genesis state genAccs := []types.GenesisAccount{&acc} - benchmarkApp := simapp.SetupWithGenesisAccounts(&testing.T{}, genAccs) + benchmarkApp := simapp.SetupWithGenesisAccounts(genAccs) ctx := benchmarkApp.BaseApp.NewContext(false, tmproto.Header{}) // some value conceivably higher than the benchmarks would ever go - require.NoError(b, testutil.FundAccount(benchmarkApp.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 100000000000)))) + require.NoError(b, simapp.FundAccount(benchmarkApp.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 100000000000)))) benchmarkApp.Commit() txGen := simappparams.MakeTestEncodingConfig().TxConfig @@ -49,12 +46,12 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) { // Committing, and what time comes from Check/Deliver Tx. for i := 0; i < b.N; i++ { benchmarkApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: height}}) - _, _, err := benchmarkApp.SimCheck(txGen.TxEncoder(), txs[i]) + _, _, err := benchmarkApp.Check(txGen.TxEncoder(), txs[i]) if err != nil { panic("something is broken in checking transaction") } - _, _, err = benchmarkApp.SimDeliver(txGen.TxEncoder(), txs[i]) + _, _, err = benchmarkApp.Deliver(txGen.TxEncoder(), txs[i]) require.NoError(b, err) benchmarkApp.EndBlock(abci.RequestEndBlock{Height: height}) benchmarkApp.Commit() @@ -63,8 +60,6 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) { } func BenchmarkOneBankMultiSendTxPerBlock(b *testing.B) { - b.Skip("Skipping benchmark with buggy code reported at https://github.com/cosmos/cosmos-sdk/issues/10023") - b.ReportAllocs() // Add an account at genesis acc := authtypes.BaseAccount{ @@ -73,11 +68,11 @@ func BenchmarkOneBankMultiSendTxPerBlock(b *testing.B) { // Construct genesis state genAccs := []authtypes.GenesisAccount{&acc} - benchmarkApp := simapp.SetupWithGenesisAccounts(&testing.T{}, genAccs) + benchmarkApp := simapp.SetupWithGenesisAccounts(genAccs) ctx := benchmarkApp.BaseApp.NewContext(false, tmproto.Header{}) // some value conceivably higher than the benchmarks would ever go - require.NoError(b, testutil.FundAccount(benchmarkApp.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 100000000000)))) + require.NoError(b, simapp.FundAccount(benchmarkApp.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 100000000000)))) benchmarkApp.Commit() txGen := simappparams.MakeTestEncodingConfig().TxConfig @@ -93,12 +88,12 @@ func BenchmarkOneBankMultiSendTxPerBlock(b *testing.B) { // Committing, and what time comes from Check/Deliver Tx. for i := 0; i < b.N; i++ { benchmarkApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: height}}) - _, _, err := benchmarkApp.SimCheck(txGen.TxEncoder(), txs[i]) + _, _, err := benchmarkApp.Check(txGen.TxEncoder(), txs[i]) if err != nil { panic("something is broken in checking transaction") } - _, _, err = benchmarkApp.SimDeliver(txGen.TxEncoder(), txs[i]) + _, _, err = benchmarkApp.Deliver(txGen.TxEncoder(), txs[i]) require.NoError(b, err) benchmarkApp.EndBlock(abci.RequestEndBlock{Height: height}) benchmarkApp.Commit() diff --git a/x/bank/client/cli/query.go b/x/bank/client/cli/query.go index f5ddcd0c4db9..4019bb738d9a 100644 --- a/x/bank/client/cli/query.go +++ b/x/bank/client/cli/query.go @@ -159,7 +159,6 @@ func GetCmdQueryTotalSupply() *cobra.Command { cmd := &cobra.Command{ Use: "total", Short: "Query the total supply of coins of the chain", - Args: cobra.NoArgs, Long: strings.TrimSpace( fmt.Sprintf(`Query total supply of coins that are held by accounts in the chain. diff --git a/x/bank/client/testutil/grpc.go b/x/bank/client/rest/grpc_query_test.go similarity index 93% rename from x/bank/client/testutil/grpc.go rename to x/bank/client/rest/grpc_query_test.go index cebaa32388bd..5277fd22d010 100644 --- a/x/bank/client/testutil/grpc.go +++ b/x/bank/client/rest/grpc_query_test.go @@ -1,4 +1,6 @@ -package testutil +// +build norace + +package rest_test import ( "fmt" @@ -6,10 +8,10 @@ import ( "github.com/gogo/protobuf/proto" "github.com/cosmos/cosmos-sdk/testutil" - "github.com/cosmos/cosmos-sdk/testutil/rest" sdk "github.com/cosmos/cosmos-sdk/types" grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" "github.com/cosmos/cosmos-sdk/types/query" + "github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -140,26 +142,8 @@ func (s *IntegrationTestSuite) TestDenomMetadataGRPCHandler() { Base: "uatom", Display: "atom", }, - { - Name: "Ethereum", - Symbol: "ETH", - Description: "Ethereum mainnet token", - DenomUnits: []*types.DenomUnit{ - { - Denom: "wei", - Exponent: 0, - }, - { - Denom: "eth", - Exponent: 6, - Aliases: []string{"ETH"}, - }, - }, - Base: "wei", - Display: "eth", - }, }, - Pagination: &query.PageResponse{Total: 2}, + Pagination: &query.PageResponse{Total: 1}, }, }, { diff --git a/x/bank/client/rest/query.go b/x/bank/client/rest/query.go new file mode 100644 index 000000000000..7c88c790f83c --- /dev/null +++ b/x/bank/client/rest/query.go @@ -0,0 +1,118 @@ +package rest + +import ( + "fmt" + "net/http" + + "github.com/gorilla/mux" + + "github.com/cosmos/cosmos-sdk/client" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +// QueryBalancesRequestHandlerFn returns a REST handler that queries for all +// account balances or a specific balance by denomination. +func QueryBalancesRequestHandlerFn(clientCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + + vars := mux.Vars(r) + bech32addr := vars["address"] + + addr, err := sdk.AccAddressFromBech32(bech32addr) + if rest.CheckInternalServerError(w, err) { + return + } + + ctx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r) + if !ok { + return + } + + var ( + params interface{} + route string + ) + + denom := r.FormValue("denom") + if denom == "" { + params = types.NewQueryAllBalancesRequest(addr, nil) + route = fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryAllBalances) + } else { + params = types.NewQueryBalanceRequest(addr, denom) + route = fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryBalance) + } + + bz, err := ctx.LegacyAmino.MarshalJSON(params) + if rest.CheckBadRequestError(w, err) { + return + } + + res, height, err := ctx.QueryWithData(route, bz) + if rest.CheckInternalServerError(w, err) { + return + } + + ctx = ctx.WithHeight(height) + rest.PostProcessResponse(w, ctx, res) + } +} + +// HTTP request handler to query the total supply of coins +func totalSupplyHandlerFn(clientCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + _, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0) + if rest.CheckBadRequestError(w, err) { + return + } + + clientCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r) + if !ok { + return + } + + params := types.NewQueryTotalSupplyParams(page, limit) + bz, err := clientCtx.LegacyAmino.MarshalJSON(params) + + if rest.CheckBadRequestError(w, err) { + return + } + + res, height, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalSupply), bz) + + if rest.CheckInternalServerError(w, err) { + return + } + + clientCtx = clientCtx.WithHeight(height) + rest.PostProcessResponse(w, clientCtx, res) + } +} + +// HTTP request handler to query the supply of a single denom +func supplyOfHandlerFn(clientCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + denom := mux.Vars(r)["denom"] + clientCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r) + if !ok { + return + } + + params := types.NewQuerySupplyOfParams(denom) + bz, err := clientCtx.LegacyAmino.MarshalJSON(params) + + if rest.CheckBadRequestError(w, err) { + return + } + + res, height, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QuerySupplyOf), bz) + if rest.CheckInternalServerError(w, err) { + return + } + + clientCtx = clientCtx.WithHeight(height) + rest.PostProcessResponse(w, clientCtx, res) + } +} diff --git a/x/bank/client/rest/query_test.go b/x/bank/client/rest/query_test.go new file mode 100644 index 000000000000..a9e43a53db86 --- /dev/null +++ b/x/bank/client/rest/query_test.go @@ -0,0 +1,198 @@ +// +build norace + +package rest_test + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/suite" + + "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" +) + +type IntegrationTestSuite struct { + suite.Suite + + cfg network.Config + network *network.Network +} + +func (s *IntegrationTestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + cfg := network.DefaultConfig() + genesisState := cfg.GenesisState + cfg.NumValidators = 1 + + var bankGenesis types.GenesisState + s.Require().NoError(cfg.Codec.UnmarshalJSON(genesisState[types.ModuleName], &bankGenesis)) + + bankGenesis.DenomMetadata = []types.Metadata{ + { + Name: "Cosmos Hub Atom", + Symbol: "ATOM", + Description: "The native staking token of the Cosmos Hub.", + DenomUnits: []*types.DenomUnit{ + { + Denom: "uatom", + Exponent: 0, + Aliases: []string{"microatom"}, + }, + { + Denom: "atom", + Exponent: 6, + Aliases: []string{"ATOM"}, + }, + }, + Base: "uatom", + Display: "atom", + }, + } + + bankGenesisBz, err := cfg.Codec.MarshalJSON(&bankGenesis) + s.Require().NoError(err) + genesisState[types.ModuleName] = bankGenesisBz + cfg.GenesisState = genesisState + + s.cfg = cfg + s.network = network.New(s.T(), cfg) + + _, err = s.network.WaitForHeight(2) + s.Require().NoError(err) +} + +func (s *IntegrationTestSuite) TearDownSuite() { + s.T().Log("tearing down integration test suite") + s.network.Cleanup() +} + +func (s *IntegrationTestSuite) TestQueryBalancesRequestHandlerFn() { + val := s.network.Validators[0] + baseURL := val.APIAddress + + testCases := []struct { + name string + url string + expHeight int64 + respType fmt.Stringer + expected fmt.Stringer + }{ + { + "total account balance", + fmt.Sprintf("%s/bank/balances/%s", baseURL, val.Address), + -1, + &sdk.Coins{}, + sdk.NewCoins( + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens), + sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Sub(s.cfg.BondedTokens)), + ), + }, + { + "total account balance with height", + fmt.Sprintf("%s/bank/balances/%s?height=1", baseURL, val.Address), + 1, + &sdk.Coins{}, + sdk.NewCoins( + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens), + sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Sub(s.cfg.BondedTokens)), + ), + }, + { + "total account balance of a specific denom", + fmt.Sprintf("%s/bank/balances/%s?denom=%s", baseURL, val.Address, s.cfg.BondDenom), + -1, + &sdk.Coin{}, + sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Sub(s.cfg.BondedTokens)), + }, + { + "total account balance of a bogus denom", + fmt.Sprintf("%s/bank/balances/%s?denom=foobar", baseURL, val.Address), + -1, + &sdk.Coin{}, + sdk.NewCoin("foobar", sdk.ZeroInt()), + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + respJSON, err := rest.GetRequest(tc.url) + s.Require().NoError(err) + + var resp = rest.ResponseWithHeight{} + err = val.ClientCtx.LegacyAmino.UnmarshalJSON(respJSON, &resp) + s.Require().NoError(err) + + // Check height. + if tc.expHeight >= 0 { + s.Require().Equal(resp.Height, tc.expHeight) + } else { + // To avoid flakiness, just test that height is positive. + s.Require().Greater(resp.Height, int64(0)) + } + + // Check result. + s.Require().NoError(val.ClientCtx.LegacyAmino.UnmarshalJSON(resp.Result, tc.respType)) + s.Require().Equal(tc.expected.String(), tc.respType.String()) + }) + } +} + +func (s *IntegrationTestSuite) TestTotalSupplyHandlerFn() { + val := s.network.Validators[0] + baseURL := val.APIAddress + + testCases := []struct { + name string + url string + respType fmt.Stringer + expected fmt.Stringer + }{ + { + "total supply", + fmt.Sprintf("%s/bank/total?height=1", baseURL), + &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", + fmt.Sprintf("%s/bank/total/%s?height=1", baseURL, s.cfg.BondDenom), + &sdk.Coin{}, + sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))), + }, + { + "total supply of a bogus denom", + fmt.Sprintf("%s/bank/total/foobar?height=1", baseURL), + &sdk.Coin{}, + sdk.NewCoin("foobar", sdk.ZeroInt()), + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + resp, err := rest.GetRequest(tc.url) + s.Require().NoError(err) + + bz, err := rest.ParseResponseWithHeight(val.ClientCtx.LegacyAmino, resp) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.LegacyAmino.UnmarshalJSON(bz, tc.respType)) + s.Require().Equal(tc.expected.String(), tc.respType.String()) + }) + } +} + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} diff --git a/x/bank/client/rest/rest.go b/x/bank/client/rest/rest.go new file mode 100644 index 000000000000..db4909c53258 --- /dev/null +++ b/x/bank/client/rest/rest.go @@ -0,0 +1,19 @@ +package rest + +import ( + "github.com/gorilla/mux" + + "github.com/cosmos/cosmos-sdk/client/rest" + + "github.com/cosmos/cosmos-sdk/client" +) + +// RegisterHandlers registers all x/bank transaction and query HTTP REST handlers +// on the provided mux router. +func RegisterHandlers(clientCtx client.Context, rtr *mux.Router) { + r := rest.WithHTTPDeprecationHeaders(rtr) + r.HandleFunc("/bank/accounts/{address}/transfers", NewSendRequestHandlerFn(clientCtx)).Methods("POST") + r.HandleFunc("/bank/balances/{address}", QueryBalancesRequestHandlerFn(clientCtx)).Methods("GET") + r.HandleFunc("/bank/total", totalSupplyHandlerFn(clientCtx)).Methods("GET") + r.HandleFunc("/bank/total/{denom}", supplyOfHandlerFn(clientCtx)).Methods("GET") +} diff --git a/x/bank/client/rest/tx.go b/x/bank/client/rest/tx.go new file mode 100644 index 000000000000..e630710dff22 --- /dev/null +++ b/x/bank/client/rest/tx.go @@ -0,0 +1,51 @@ +package rest + +import ( + "net/http" + + "github.com/gorilla/mux" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +// SendReq defines the properties of a send request's body. +type SendReq struct { + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + Amount sdk.Coins `json:"amount" yaml:"amount"` +} + +// NewSendRequestHandlerFn returns an HTTP REST handler for creating a MsgSend +// transaction. +func NewSendRequestHandlerFn(clientCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + bech32Addr := vars["address"] + + toAddr, err := sdk.AccAddressFromBech32(bech32Addr) + if rest.CheckBadRequestError(w, err) { + return + } + + var req SendReq + if !rest.ReadRESTReq(w, r, clientCtx.LegacyAmino, &req) { + return + } + + req.BaseReq = req.BaseReq.Sanitize() + if !req.BaseReq.ValidateBasic(w) { + return + } + + fromAddr, err := sdk.AccAddressFromBech32(req.BaseReq.From) + if rest.CheckBadRequestError(w, err) { + return + } + + msg := types.NewMsgSend(fromAddr, toAddr, req.Amount) + tx.WriteGeneratedTxResponse(clientCtx, w, req.BaseReq, msg) + } +} diff --git a/x/bank/client/rest/tx_test.go b/x/bank/client/rest/tx_test.go new file mode 100644 index 000000000000..8406a2c2abdf --- /dev/null +++ b/x/bank/client/rest/tx_test.go @@ -0,0 +1,107 @@ +// +build norace + +package rest_test + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + bankrest "github.com/cosmos/cosmos-sdk/x/bank/client/rest" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +func (s *IntegrationTestSuite) TestCoinSend() { + val := s.network.Validators[0] + + account, err := getAccountInfo(val) + s.Require().NoError(err) + + sendReq := generateSendReq( + account, + types.Coins{types.NewCoin(s.cfg.BondDenom, types.TokensFromConsensusPower(1, sdk.DefaultPowerReduction))}, + ) + + stdTx, err := submitSendReq(val, sendReq) + s.Require().NoError(err) + + s.Require().Nil(stdTx.Signatures) + s.Require().Equal([]types.Msg{ + &banktypes.MsgSend{ + FromAddress: account.GetAddress().String(), + ToAddress: account.GetAddress().String(), + Amount: sendReq.Amount, + }, + }, stdTx.GetMsgs()) +} + +func submitSendReq(val *network.Validator, req bankrest.SendReq) (legacytx.StdTx, error) { + url := fmt.Sprintf("%s/bank/accounts/%s/transfers", val.APIAddress, val.Address) + + // NOTE: this uses amino explicitly, don't migrate it! + bz, err := val.ClientCtx.LegacyAmino.MarshalJSON(req) + if err != nil { + return legacytx.StdTx{}, errors.Wrap(err, "error encoding SendReq to json") + } + + res, err := rest.PostRequest(url, "application/json", bz) + if err != nil { + return legacytx.StdTx{}, err + } + + var tx legacytx.StdTx + // NOTE: this uses amino explicitly, don't migrate it! + err = val.ClientCtx.LegacyAmino.UnmarshalJSON(res, &tx) + if err != nil { + return legacytx.StdTx{}, errors.Wrap(err, "error unmarshaling to StdTx SendReq response") + } + + return tx, nil +} + +func generateSendReq(from authtypes.AccountI, amount types.Coins) bankrest.SendReq { + baseReq := rest.NewBaseReq( + from.GetAddress().String(), + "someMemo", + "some-id", + "10000", + fmt.Sprintf("%f", 1.0), + from.GetAccountNumber(), + from.GetSequence(), + types.NewCoins(), + nil, + false, + ) + + return bankrest.SendReq{ + BaseReq: baseReq, + Amount: amount, + } +} + +func getAccountInfo(val *network.Validator) (authtypes.AccountI, error) { + url := fmt.Sprintf("%s/auth/accounts/%s", val.APIAddress, val.Address) + + resp, err := rest.GetRequest(url) + if err != nil { + return nil, err + } + + bz, err := rest.ParseResponseWithHeight(val.ClientCtx.LegacyAmino, resp) + if err != nil { + return nil, err + } + + var acc authtypes.AccountI + err = val.ClientCtx.LegacyAmino.UnmarshalJSON(bz, &acc) + if err != nil { + return nil, err + } + + return acc, nil +} diff --git a/x/bank/client/testutil/suite.go b/x/bank/client/testutil/suite.go index da09851701c1..19be5401c672 100644 --- a/x/bank/client/testutil/suite.go +++ b/x/bank/client/testutil/suite.go @@ -80,8 +80,7 @@ func (s *IntegrationTestSuite) SetupSuite() { genesisState[types.ModuleName] = bankGenesisBz s.cfg.GenesisState = genesisState - s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg) - s.Require().NoError(err) + s.network = network.New(s.T(), s.cfg) _, err = s.network.WaitForHeight(1) s.Require().NoError(err) diff --git a/x/bank/handler.go b/x/bank/handler.go new file mode 100644 index 000000000000..0fb0f53a4cd8 --- /dev/null +++ b/x/bank/handler.go @@ -0,0 +1,30 @@ +package bank + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/bank/keeper" + "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +// NewHandler returns a handler for "bank" type messages. +func NewHandler(k keeper.Keeper) sdk.Handler { + msgServer := keeper.NewMsgServerImpl(k) + + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + + switch msg := msg.(type) { + case *types.MsgSend: + res, err := msgServer.Send(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *types.MsgMultiSend: + res, err := msgServer.MultiSend(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + default: + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized bank message type: %T", msg) + } + } +} diff --git a/x/bank/handler_test.go b/x/bank/handler_test.go new file mode 100644 index 000000000000..5fcdf02f1a93 --- /dev/null +++ b/x/bank/handler_test.go @@ -0,0 +1,88 @@ +package bank_test + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/bank" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + "github.com/cosmos/cosmos-sdk/x/bank/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +func TestInvalidMsg(t *testing.T) { + h := bank.NewHandler(nil) + + res, err := h(sdk.NewContext(nil, tmproto.Header{}, false, nil), testdata.NewTestMsg()) + require.Error(t, err) + require.Nil(t, res) + + _, _, log := sdkerrors.ABCIInfo(err, false) + require.True(t, strings.Contains(log, "unrecognized bank message type")) +} + +// A module account cannot be the recipient of bank sends unless it has been marked as such +func TestSendToModuleAccount(t *testing.T) { + priv1 := secp256k1.GenPrivKey() + addr1 := sdk.AccAddress(priv1.PubKey().Address()) + moduleAccAddr := authtypes.NewModuleAddress(stakingtypes.BondedPoolName) + coins := sdk.Coins{sdk.NewInt64Coin("foocoin", 10)} + + tests := []struct { + name string + expectedError error + msg *types.MsgSend + }{ + { + name: "not allowed module account", + msg: types.NewMsgSend(addr1, moduleAccAddr, coins), + expectedError: sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", moduleAccAddr), + }, + { + name: "allowed module account", + msg: types.NewMsgSend(addr1, authtypes.NewModuleAddress(stakingtypes.ModuleName), coins), + expectedError: nil, + }, + } + + acc1 := &authtypes.BaseAccount{ + Address: addr1.String(), + } + accs := authtypes.GenesisAccounts{acc1} + balances := []types.Balance{ + { + Address: addr1.String(), + Coins: coins, + }, + } + + app := simapp.SetupWithGenesisAccounts(accs, balances...) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + app.BankKeeper = bankkeeper.NewBaseKeeper( + app.AppCodec(), app.GetKey(types.StoreKey), app.AccountKeeper, app.GetSubspace(types.ModuleName), map[string]bool{ + moduleAccAddr.String(): true, + }, + ) + handler := bank.NewHandler(app.BankKeeper) + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + _, err := handler(ctx, tc.msg) + if tc.expectedError != nil { + require.EqualError(t, err, tc.expectedError.Error()) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/bank/keeper/genesis.go b/x/bank/keeper/genesis.go index 694fa6668e61..24b5ef44f9fc 100644 --- a/x/bank/keeper/genesis.go +++ b/x/bank/keeper/genesis.go @@ -13,8 +13,8 @@ func (k BaseKeeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { k.SetParams(ctx, genState.Params) totalSupply := sdk.Coins{} - genState.Balances = types.SanitizeGenesisBalances(genState.Balances) + genState.Balances = types.SanitizeGenesisBalances(genState.Balances) for _, balance := range genState.Balances { addr, err := sdk.AccAddressFromBech32(balance.Address) if err != nil { diff --git a/x/bank/keeper/genesis_test.go b/x/bank/keeper/genesis_test.go index d8fd84d2e290..70d53b9f0430 100644 --- a/x/bank/keeper/genesis_test.go +++ b/x/bank/keeper/genesis_test.go @@ -11,13 +11,7 @@ func (suite *IntegrationTestSuite) TestExportGenesis() { app, ctx := suite.app, suite.ctx expectedMetadata := suite.getTestMetadata() - expectedBalances, expTotalSupply := suite.getTestBalancesAndSupply() - - // Adding genesis supply to the expTotalSupply - genesisSupply, _, err := suite.app.BankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) - suite.Require().NoError(err) - expTotalSupply = expTotalSupply.Add(genesisSupply...) - + expectedBalances, totalSupply := suite.getTestBalancesAndSupply() for i := range []int{1, 2} { app.BankKeeper.SetDenomMetaData(ctx, expectedMetadata[i]) accAddr, err1 := sdk.AccAddressFromBech32(expectedBalances[i].Address) @@ -38,8 +32,8 @@ func (suite *IntegrationTestSuite) TestExportGenesis() { suite.Require().Len(exportGenesis.Params.SendEnabled, 0) suite.Require().Equal(types.DefaultParams().DefaultSendEnabled, exportGenesis.Params.DefaultSendEnabled) - suite.Require().Equal(expTotalSupply, exportGenesis.Supply) - suite.Require().Subset(exportGenesis.Balances, expectedBalances) + suite.Require().Equal(totalSupply, exportGenesis.Supply) + suite.Require().Equal(expectedBalances, exportGenesis.Balances) suite.Require().Equal(expectedMetadata, exportGenesis.DenomMetadata) } @@ -80,9 +74,6 @@ func (suite *IntegrationTestSuite) TestTotalSupply() { } totalSupply := sdk.NewCoins(sdk.NewCoin("foocoin", sdk.NewInt(11)), sdk.NewCoin("barcoin", sdk.NewInt(21))) - genesisSupply, _, err := suite.app.BankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) - suite.Require().NoError(err) - testcases := []struct { name string genesis *types.GenesisState @@ -116,10 +107,7 @@ func (suite *IntegrationTestSuite) TestTotalSupply() { suite.app.BankKeeper.InitGenesis(suite.ctx, tc.genesis) totalSupply, _, err := suite.app.BankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) suite.Require().NoError(err) - - // adding genesis supply to expected supply - expected := tc.expSupply.Add(genesisSupply...) - suite.Require().Equal(expected, totalSupply) + suite.Require().Equal(tc.expSupply, totalSupply) } }) } diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index 70c780dcf5e6..02655aa2f595 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -59,12 +59,13 @@ func (k BaseKeeper) AllBalances(ctx context.Context, req *types.QueryAllBalances balances := sdk.NewCoins() accountStore := k.getAccountStore(sdkCtx, addr) - pageRes, err := query.Paginate(accountStore, req.Pagination, func(key, value []byte) error { - var amount sdk.Int - if err := amount.Unmarshal(value); err != nil { + pageRes, err := query.Paginate(accountStore, req.Pagination, func(_, value []byte) error { + var result sdk.Coin + err := k.cdc.Unmarshal(value, &result) + if err != nil { return err } - balances = append(balances, sdk.NewCoin(string(key), amount)) + balances = append(balances, result) return nil }) @@ -163,50 +164,3 @@ func (k BaseKeeper) DenomMetadata(c context.Context, req *types.QueryDenomMetada Metadata: metadata, }, nil } - -func (k BaseKeeper) DenomOwners( - goCtx context.Context, - req *types.QueryDenomOwnersRequest, -) (*types.QueryDenomOwnersResponse, error) { - - if req == nil { - return nil, status.Errorf(codes.InvalidArgument, "empty request") - } - - if req.Denom == "" { - return nil, status.Error(codes.InvalidArgument, "empty denom") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - denomPrefixStore := k.getDenomAddressPrefixStore(ctx, req.Denom) - - var denomOwners []*types.DenomOwner - pageRes, err := query.FilteredPaginate( - denomPrefixStore, - req.Pagination, - func(key []byte, value []byte, accumulate bool) (bool, error) { - if accumulate { - address, _, err := types.AddressAndDenomFromBalancesStore(key) - if err != nil { - return false, err - } - - denomOwners = append( - denomOwners, - &types.DenomOwner{ - Address: address.String(), - Balance: k.GetBalance(ctx, address, req.Denom), - }, - ) - } - - return true, nil - }, - ) - - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - return &types.QueryDenomOwnersResponse{DenomOwners: denomOwners, Pagination: pageRes}, nil -} diff --git a/x/bank/keeper/grpc_query_test.go b/x/bank/keeper/grpc_query_test.go index 1f8a1de5efc4..181506a6d7fb 100644 --- a/x/bank/keeper/grpc_query_test.go +++ b/x/bank/keeper/grpc_query_test.go @@ -4,13 +4,14 @@ import ( gocontext "context" "fmt" + "github.com/cosmos/cosmos-sdk/simapp" + + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/bank/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) func (suite *IntegrationTestSuite) TestQueryBalance() { @@ -33,7 +34,7 @@ func (suite *IntegrationTestSuite) TestQueryBalance() { acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) res, err = queryClient.Balance(gocontext.Background(), req) suite.Require().NoError(err) @@ -65,7 +66,7 @@ func (suite *IntegrationTestSuite) TestQueryAllBalances() { acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) res, err = queryClient.AllBalances(gocontext.Background(), req) suite.Require().NoError(err) @@ -81,29 +82,22 @@ func (suite *IntegrationTestSuite) TestQueryAllBalances() { } req = types.NewQueryAllBalancesRequest(addr, pageReq) res, err = queryClient.AllBalances(gocontext.Background(), req) - suite.Require().NoError(err) suite.Equal(res.Balances.Len(), 1) suite.Nil(res.Pagination.NextKey) } func (suite *IntegrationTestSuite) TestQueryTotalSupply() { app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient - res, err := queryClient.TotalSupply(gocontext.Background(), &types.QueryTotalSupplyRequest{}) - suite.Require().NoError(err) - genesisSupply := res.Supply - - testCoins := sdk.NewCoins(sdk.NewInt64Coin("test", 400000000)) + expectedTotalSupply := sdk.NewCoins(sdk.NewInt64Coin("test", 400000000)) suite. Require(). - NoError(app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, testCoins)) + NoError(app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, expectedTotalSupply)) - res, err = queryClient.TotalSupply(gocontext.Background(), &types.QueryTotalSupplyRequest{}) + res, err := queryClient.TotalSupply(gocontext.Background(), &types.QueryTotalSupplyRequest{}) suite.Require().NoError(err) suite.Require().NotNil(res) - expectedTotalSupply := genesisSupply.Add(testCoins...) - suite.Require().Equal(2, len(res.Supply)) - suite.Require().Equal(res.Supply, expectedTotalSupply) + suite.Require().Equal(expectedTotalSupply, res.Supply) } func (suite *IntegrationTestSuite) TestQueryTotalSupplyOf() { @@ -311,92 +305,3 @@ func (suite *IntegrationTestSuite) QueryDenomMetadataRequest() { }) } } - -func (suite *IntegrationTestSuite) TestGRPCDenomOwners() { - ctx := suite.ctx - - authKeeper, keeper := suite.initKeepersWithmAccPerms(make(map[string]bool)) - suite.Require().NoError(keeper.MintCoins(ctx, minttypes.ModuleName, initCoins)) - - for i := 0; i < 10; i++ { - acc := authKeeper.NewAccountWithAddress(ctx, authtypes.NewModuleAddress(fmt.Sprintf("account-%d", i))) - authKeeper.SetAccount(ctx, acc) - - bal := sdk.NewCoins(sdk.NewCoin( - sdk.DefaultBondDenom, - sdk.TokensFromConsensusPower(initialPower/10, sdk.DefaultPowerReduction), - )) - suite.Require().NoError(keeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, acc.GetAddress(), bal)) - } - - testCases := map[string]struct { - req *types.QueryDenomOwnersRequest - expPass bool - numAddrs int - hasNext bool - total uint64 - }{ - "empty request": { - req: &types.QueryDenomOwnersRequest{}, - expPass: false, - }, - "invalid denom": { - req: &types.QueryDenomOwnersRequest{ - Denom: "foo", - }, - expPass: true, - numAddrs: 0, - hasNext: false, - total: 0, - }, - "valid request - page 1": { - req: &types.QueryDenomOwnersRequest{ - Denom: sdk.DefaultBondDenom, - Pagination: &query.PageRequest{ - Limit: 6, - CountTotal: true, - }, - }, - expPass: true, - numAddrs: 6, - hasNext: true, - total: 13, - }, - "valid request - page 2": { - req: &types.QueryDenomOwnersRequest{ - Denom: sdk.DefaultBondDenom, - Pagination: &query.PageRequest{ - Offset: 6, - Limit: 10, - CountTotal: true, - }, - }, - expPass: true, - numAddrs: 7, - hasNext: false, - total: 13, - }, - } - - for name, tc := range testCases { - suite.Run(name, func() { - resp, err := suite.queryClient.DenomOwners(gocontext.Background(), tc.req) - if tc.expPass { - suite.NoError(err) - suite.NotNil(resp) - suite.Len(resp.DenomOwners, tc.numAddrs) - suite.Equal(tc.total, resp.Pagination.Total) - - if tc.hasNext { - suite.NotNil(resp.Pagination.NextKey) - } else { - suite.Nil(resp.Pagination.NextKey) - } - } else { - suite.Require().Error(err) - } - }) - } - - suite.Require().True(true) -} diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index 50aec230dda1..cc8ded240136 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -5,7 +5,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" @@ -29,7 +28,6 @@ type Keeper interface { 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) - HasDenomMetaData(ctx sdk.Context, denom string) bool SetDenomMetaData(ctx sdk.Context, denomMetaData types.Metadata) IterateAllDenomMetaData(ctx sdk.Context, cb func(types.Metadata) bool) @@ -53,7 +51,7 @@ type BaseKeeper struct { ak types.AccountKeeper cdc codec.BinaryCodec - storeKey storetypes.StoreKey + storeKey sdk.StoreKey paramSpace paramtypes.Subspace } @@ -75,6 +73,7 @@ func (k BaseKeeper) GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.P supply = supply.Add(sdk.NewCoin(string(key), amount)) return nil }) + if err != nil { return nil, nil, err } @@ -90,7 +89,7 @@ func (k BaseKeeper) GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.P // by using a SendCoinsFromModuleToAccount execution. func NewBaseKeeper( cdc codec.BinaryCodec, - storeKey storetypes.StoreKey, + storeKey sdk.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace, blockedAddrs map[string]bool, @@ -219,7 +218,7 @@ func (k BaseKeeper) GetSupply(ctx sdk.Context, denom string) sdk.Coin { // false otherwise. func (k BaseKeeper) GetDenomMetaData(ctx sdk.Context, denom string) (types.Metadata, bool) { store := ctx.KVStore(k.storeKey) - store = prefix.NewStore(store, types.DenomMetadataPrefix) + store = prefix.NewStore(store, types.DenomMetadataKey(denom)) bz := store.Get([]byte(denom)) if bz == nil { @@ -232,13 +231,6 @@ func (k BaseKeeper) GetDenomMetaData(ctx sdk.Context, denom string) (types.Metad return metadata, true } -// HasDenomMetaData checks if the denomination metadata exists in store. -func (k BaseKeeper) HasDenomMetaData(ctx sdk.Context, denom string) bool { - store := ctx.KVStore(k.storeKey) - store = prefix.NewStore(store, types.DenomMetadataPrefix) - return store.Has([]byte(denom)) -} - // GetAllDenomMetaData retrieves all denominations metadata func (k BaseKeeper) GetAllDenomMetaData(ctx sdk.Context) []types.Metadata { denomMetaData := make([]types.Metadata, 0) @@ -273,7 +265,7 @@ func (k BaseKeeper) IterateAllDenomMetaData(ctx sdk.Context, cb func(types.Metad // SetDenomMetaData sets the denominations metadata func (k BaseKeeper) SetDenomMetaData(ctx sdk.Context, denomMetaData types.Metadata) { store := ctx.KVStore(k.storeKey) - denomMetaDataStore := prefix.NewStore(store, types.DenomMetadataPrefix) + denomMetaDataStore := prefix.NewStore(store, types.DenomMetadataKey(denomMetaData.Base)) m := k.cdc.MustMarshal(&denomMetaData) denomMetaDataStore.Set([]byte(denomMetaData.Base), m) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 52d0dc1338e3..f9074f423e92 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -4,6 +4,11 @@ import ( "testing" "time" + "github.com/cosmos/cosmos-sdk/types/query" + + "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -12,15 +17,11 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/query" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/bank/keeper" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/bank/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) const ( @@ -74,7 +75,7 @@ type IntegrationTestSuite struct { func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[string]bool) (authkeeper.AccountKeeper, keeper.BaseKeeper) { app := suite.app maccPerms := simapp.GetMaccPerms() - appCodec := simapp.MakeTestEncodingConfig().Codec + appCodec := simapp.MakeTestEncodingConfig().Marshaler maccPerms[holder] = nil maccPerms[authtypes.Burner] = []string{authtypes.Burner} @@ -83,7 +84,7 @@ func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[str maccPerms[randomPerm] = []string{"random"} authKeeper := authkeeper.NewAccountKeeper( appCodec, app.GetKey(types.StoreKey), app.GetSubspace(types.ModuleName), - authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, + authtypes.ProtoBaseAccount, maccPerms, ) keeper := keeper.NewBaseKeeper( appCodec, app.GetKey(types.StoreKey), authKeeper, @@ -94,7 +95,7 @@ func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[str } func (suite *IntegrationTestSuite) SetupTest() { - app := simapp.Setup(suite.T(), false) + app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) @@ -117,31 +118,26 @@ func (suite *IntegrationTestSuite) TestSupply() { // add module accounts to supply keeper authKeeper, keeper := suite.initKeepersWithmAccPerms(make(map[string]bool)) - genesisSupply, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) - require.NoError(err) - initialPower := int64(100) initTokens := suite.app.StakingKeeper.TokensFromConsensusPower(ctx, initialPower) - initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens)) + totalSupply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens)) // set burnerAcc balance authKeeper.SetModuleAccount(ctx, burnerAcc) - require.NoError(keeper.MintCoins(ctx, authtypes.Minter, initCoins)) - require.NoError(keeper.SendCoinsFromModuleToAccount(ctx, authtypes.Minter, burnerAcc.GetAddress(), initCoins)) + require.NoError(keeper.MintCoins(ctx, authtypes.Minter, totalSupply)) + require.NoError(keeper.SendCoinsFromModuleToAccount(ctx, authtypes.Minter, burnerAcc.GetAddress(), totalSupply)) total, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) require.NoError(err) - - expTotalSupply := initCoins.Add(genesisSupply...) - require.Equal(expTotalSupply, total) + require.Equal(totalSupply, total) // burning all supplied tokens - err = keeper.BurnCoins(ctx, authtypes.Burner, initCoins) + err = keeper.BurnCoins(ctx, authtypes.Burner, totalSupply) require.NoError(err) total, _, err = keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) require.NoError(err) - require.Equal(total, genesisSupply) + require.Equal(total.String(), "") } func (suite *IntegrationTestSuite) TestSendCoinsFromModuleToAccount_Blocklist() { @@ -314,7 +310,7 @@ func (suite *IntegrationTestSuite) TestSendCoinsNewAccount() { addr1 := sdk.AccAddress([]byte("addr1_______________")) acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) app.AccountKeeper.SetAccount(ctx, acc1) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, balances)) acc1Balances := app.BankKeeper.GetAllBalances(ctx, addr1) suite.Require().Equal(balances, acc1Balances) @@ -344,7 +340,7 @@ func (suite *IntegrationTestSuite) TestInputOutputNewAccount() { addr1 := sdk.AccAddress([]byte("addr1_______________")) acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) app.AccountKeeper.SetAccount(ctx, acc1) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, balances)) acc1Balances := app.BankKeeper.GetAllBalances(ctx, addr1) suite.Require().Equal(balances, acc1Balances) @@ -397,7 +393,7 @@ func (suite *IntegrationTestSuite) TestInputOutputCoins() { suite.Require().Error(app.BankKeeper.InputOutputCoins(ctx, inputs, []types.Output{})) suite.Require().Error(app.BankKeeper.InputOutputCoins(ctx, inputs, outputs)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, balances)) insufficientInputs := []types.Input{ {Address: addr1.String(), Coins: sdk.NewCoins(newFooCoin(300), newBarCoin(100))}, @@ -432,12 +428,12 @@ func (suite *IntegrationTestSuite) TestSendCoins() { addr2 := sdk.AccAddress("addr2_______________") acc2 := app.AccountKeeper.NewAccountWithAddress(ctx, addr2) app.AccountKeeper.SetAccount(ctx, acc2) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, balances)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, balances)) sendAmt := sdk.NewCoins(newFooCoin(50), newBarCoin(25)) suite.Require().Error(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendAmt)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, balances)) suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendAmt)) acc1Balances := app.BankKeeper.GetAllBalances(ctx, addr1) @@ -473,14 +469,14 @@ func (suite *IntegrationTestSuite) TestValidateBalance() { app.AccountKeeper.SetAccount(ctx, acc) balances := sdk.NewCoins(newFooCoin(100)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, balances)) suite.Require().NoError(app.BankKeeper.ValidateBalance(ctx, addr1)) bacc := authtypes.NewBaseAccountWithAddress(addr2) vacc := vesting.NewContinuousVestingAccount(bacc, balances.Add(balances...), now.Unix(), endTime.Unix()) app.AccountKeeper.SetAccount(ctx, vacc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, balances)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, balances)) suite.Require().Error(app.BankKeeper.ValidateBalance(ctx, addr2)) } @@ -537,7 +533,7 @@ func (suite *IntegrationTestSuite) TestHasBalance() { balances := sdk.NewCoins(newFooCoin(100)) suite.Require().False(app.BankKeeper.HasBalance(ctx, addr, newFooCoin(99))) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr, balances)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr, balances)) suite.Require().False(app.BankKeeper.HasBalance(ctx, addr, newFooCoin(101))) suite.Require().True(app.BankKeeper.HasBalance(ctx, addr, newFooCoin(100))) suite.Require().True(app.BankKeeper.HasBalance(ctx, addr, newFooCoin(1))) @@ -551,7 +547,7 @@ func (suite *IntegrationTestSuite) TestMsgSendEvents() { app.AccountKeeper.SetAccount(ctx, acc) newCoins := sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr, newCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr, newCoins)) suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr, addr2, newCoins)) event1 := sdk.Event{ @@ -619,7 +615,7 @@ func (suite *IntegrationTestSuite) TestMsgMultiSendEvents() { suite.Require().Equal(0, len(events)) // Set addr's coins but not addr2's coins - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr, sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50)))) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr, sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50)))) suite.Require().Error(app.BankKeeper.InputOutputCoins(ctx, inputs, outputs)) events = ctx.EventManager().ABCIEvents() @@ -636,10 +632,10 @@ func (suite *IntegrationTestSuite) TestMsgMultiSendEvents() { suite.Require().Equal(abci.Event(event1), events[7]) // Set addr's coins and addr2's coins - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr, sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50)))) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr, sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50)))) newCoins = sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)))) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)))) newCoins2 = sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)) suite.Require().NoError(app.BankKeeper.InputOutputCoins(ctx, inputs, outputs)) @@ -706,8 +702,8 @@ func (suite *IntegrationTestSuite) TestSpendableCoins() { app.AccountKeeper.SetAccount(ctx, macc) app.AccountKeeper.SetAccount(ctx, vacc) app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) suite.Require().Equal(origCoins, app.BankKeeper.SpendableCoins(ctx, addr2)) @@ -732,13 +728,13 @@ func (suite *IntegrationTestSuite) TestVestingAccountSend() { vacc := vesting.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) app.AccountKeeper.SetAccount(ctx, vacc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) // require that no coins be sendable at the beginning of the vesting schedule suite.Require().Error(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendCoins)) // receive some coins - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, sendCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, sendCoins)) // require that all vested coins are spendable plus any received ctx = ctx.WithBlockTime(now.Add(12 * time.Hour)) suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendCoins)) @@ -764,13 +760,13 @@ func (suite *IntegrationTestSuite) TestPeriodicVestingAccountSend() { vacc := vesting.NewPeriodicVestingAccount(bacc, origCoins, ctx.BlockHeader().Time.Unix(), periods) app.AccountKeeper.SetAccount(ctx, vacc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) // require that no coins be sendable at the beginning of the vesting schedule suite.Require().Error(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendCoins)) // receive some coins - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, sendCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, sendCoins)) // require that all vested coins are spendable plus any received ctx = ctx.WithBlockTime(now.Add(12 * time.Hour)) @@ -796,8 +792,8 @@ func (suite *IntegrationTestSuite) TestVestingAccountReceive() { app.AccountKeeper.SetAccount(ctx, vacc) app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) // send some coins to the vesting account suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr2, addr1, sendCoins)) @@ -835,8 +831,8 @@ func (suite *IntegrationTestSuite) TestPeriodicVestingAccountReceive() { app.AccountKeeper.SetAccount(ctx, vacc) app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) // send some coins to the vesting account suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr2, addr1, sendCoins)) @@ -872,8 +868,8 @@ func (suite *IntegrationTestSuite) TestDelegateCoins() { app.AccountKeeper.SetAccount(ctx, vacc) app.AccountKeeper.SetAccount(ctx, acc) app.AccountKeeper.SetAccount(ctx, macc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) ctx = ctx.WithBlockTime(now.Add(12 * time.Hour)) @@ -936,8 +932,8 @@ func (suite *IntegrationTestSuite) TestUndelegateCoins() { app.AccountKeeper.SetAccount(ctx, vacc) app.AccountKeeper.SetAccount(ctx, acc) app.AccountKeeper.SetAccount(ctx, macc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) ctx = ctx.WithBlockTime(now.Add(12 * time.Hour)) @@ -987,7 +983,7 @@ func (suite *IntegrationTestSuite) TestUndelegateCoins_Invalid() { suite.Require().Error(app.BankKeeper.UndelegateCoins(ctx, addrModule, addr1, delCoins)) app.AccountKeeper.SetAccount(ctx, macc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) suite.Require().Error(app.BankKeeper.UndelegateCoins(ctx, addrModule, addr1, delCoins)) app.AccountKeeper.SetAccount(ctx, acc) @@ -1006,8 +1002,6 @@ func (suite *IntegrationTestSuite) TestSetDenomMetaData() { actualMetadata, found := app.BankKeeper.GetDenomMetaData(ctx, metadata[1].Base) suite.Require().True(found) - found = app.BankKeeper.HasDenomMetaData(ctx, metadata[1].Base) - suite.Require().True(found) suite.Require().Equal(metadata[1].GetBase(), actualMetadata.GetBase()) suite.Require().Equal(metadata[1].GetDisplay(), actualMetadata.GetDisplay()) suite.Require().Equal(metadata[1].GetDescription(), actualMetadata.GetDescription()) @@ -1050,7 +1044,7 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() { suite.app.AccountKeeper = authkeeper.NewAccountKeeper( suite.app.AppCodec(), suite.app.GetKey(authtypes.StoreKey), suite.app.GetSubspace(authtypes.ModuleName), - authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, + authtypes.ProtoBaseAccount, maccPerms, ) suite.app.BankKeeper = keeper.NewBaseKeeper(suite.app.AppCodec(), suite.app.GetKey(types.StoreKey), @@ -1139,19 +1133,18 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() { } func (suite *IntegrationTestSuite) getTestMetadata() []types.Metadata { - return []types.Metadata{ - { - Name: "Cosmos Hub Atom", - Symbol: "ATOM", - Description: "The native staking token of the Cosmos Hub.", - DenomUnits: []*types.DenomUnit{ - {"uatom", uint32(0), []string{"microatom"}}, - {"matom", uint32(3), []string{"milliatom"}}, - {"atom", uint32(6), nil}, - }, - Base: "uatom", - Display: "atom", + return []types.Metadata{{ + Name: "Cosmos Hub Atom", + Symbol: "ATOM", + Description: "The native staking token of the Cosmos Hub.", + DenomUnits: []*types.DenomUnit{ + {"uatom", uint32(0), []string{"microatom"}}, + {"matom", uint32(3), []string{"milliatom"}}, + {"atom", uint32(6), nil}, }, + Base: "uatom", + Display: "atom", + }, { Name: "Token", Symbol: "TOKEN", diff --git a/x/bank/keeper/migrations.go b/x/bank/keeper/migrations.go index 5bba06caacc9..e46b386b81a9 100644 --- a/x/bank/keeper/migrations.go +++ b/x/bank/keeper/migrations.go @@ -2,8 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - v043 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043" - v045 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v045" + v043 "github.com/cosmos/cosmos-sdk/x/bank/legacy/v043" ) // Migrator is a struct for handling in-place store migrations. @@ -20,8 +19,3 @@ func NewMigrator(keeper BaseKeeper) Migrator { func (m Migrator) Migrate1to2(ctx sdk.Context) error { return v043.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) } - -// Migrate2to3 migrates x/bank storage from version 2 to 3. -func (m Migrator) Migrate2to3(ctx sdk.Context) error { - return v045.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) -} diff --git a/x/bank/keeper/querier_test.go b/x/bank/keeper/querier_test.go index 7eba1f608a2b..66f98fdd17f8 100644 --- a/x/bank/keeper/querier_test.go +++ b/x/bank/keeper/querier_test.go @@ -5,11 +5,11 @@ import ( 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/testutil" "github.com/cosmos/cosmos-sdk/x/bank/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) @@ -42,7 +42,7 @@ func (suite *IntegrationTestSuite) TestQuerier_QueryBalance() { acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) res, err = querier(ctx, []string{types.QueryBalance}, req) suite.Require().NoError(err) @@ -79,7 +79,7 @@ func (suite *IntegrationTestSuite) TestQuerier_QueryAllBalances() { acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) res, err = querier(ctx, []string{types.QueryAllBalances}, req) suite.Require().NoError(err) suite.Require().NotNil(res) @@ -90,14 +90,10 @@ func (suite *IntegrationTestSuite) TestQuerier_QueryAllBalances() { func (suite *IntegrationTestSuite) TestQuerier_QueryTotalSupply() { app, ctx := suite.app, suite.ctx legacyAmino := app.LegacyAmino() - - genesisSupply, _, err := suite.app.BankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) - suite.Require().NoError(err) - - testCoins := sdk.NewCoins(sdk.NewInt64Coin("test", 400000000)) + expectedTotalSupply := sdk.NewCoins(sdk.NewInt64Coin("test", 400000000)) suite. Require(). - NoError(app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, testCoins)) + NoError(app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, expectedTotalSupply)) req := abci.RequestQuery{ Path: fmt.Sprintf("custom/%s/%s", types.ModuleName, types.QueryTotalSupply), @@ -119,8 +115,6 @@ func (suite *IntegrationTestSuite) TestQuerier_QueryTotalSupply() { var resp types.QueryTotalSupplyResponse suite.Require().NoError(legacyAmino.UnmarshalJSON(res, &resp)) - - expectedTotalSupply := genesisSupply.Add(testCoins...) suite.Require().Equal(expectedTotalSupply, resp.Supply) } diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index fa77baa5e696..369fa631c447 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -2,11 +2,8 @@ package keeper import ( "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/store/prefix" - storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/address" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/bank/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -38,7 +35,7 @@ type BaseSendKeeper struct { cdc codec.BinaryCodec ak types.AccountKeeper - storeKey storetypes.StoreKey + storeKey sdk.StoreKey paramSpace paramtypes.Subspace // list of addresses that are restricted from receiving transactions @@ -46,7 +43,7 @@ type BaseSendKeeper struct { } func NewBaseSendKeeper( - cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace, blockedAddrs map[string]bool, + cdc codec.BinaryCodec, storeKey sdk.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace, blockedAddrs map[string]bool, ) BaseSendKeeper { return BaseSendKeeper{ @@ -121,8 +118,8 @@ func (k BaseSendKeeper) InputOutputCoins(ctx sdk.Context, inputs []types.Input, // // NOTE: This should ultimately be removed in favor a more flexible approach // such as delegated fee messages. - accExists := k.ak.HasAccount(ctx, outAddress) - if !accExists { + acc := k.ak.GetAccount(ctx, outAddress) + if acc == nil { defer telemetry.IncrCounter(1, "new", "account") k.ak.SetAccount(ctx, k.ak.NewAccountWithAddress(ctx, outAddress)) } @@ -148,8 +145,8 @@ func (k BaseSendKeeper) SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAd // // NOTE: This should ultimately be removed in favor a more flexible approach // such as delegated fee messages. - accExists := k.ak.HasAccount(ctx, toAddr) - if !accExists { + acc := k.ak.GetAccount(ctx, toAddr) + if acc == nil { defer telemetry.IncrCounter(1, "new", "account") k.ak.SetAccount(ctx, k.ak.NewAccountWithAddress(ctx, toAddr)) } @@ -234,34 +231,16 @@ func (k BaseSendKeeper) addCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.C // An error is returned upon failure. func (k BaseSendKeeper) initBalances(ctx sdk.Context, addr sdk.AccAddress, balances sdk.Coins) error { accountStore := k.getAccountStore(ctx, addr) - denomPrefixStores := make(map[string]prefix.Store) // memoize prefix stores - for i := range balances { balance := balances[i] if !balance.IsValid() { return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, balance.String()) } - // x/bank invariants prohibit persistence of zero balances + // Bank invariants require to not store zero balances. if !balance.IsZero() { - amount, err := balance.Amount.Marshal() - if err != nil { - return err - } - accountStore.Set([]byte(balance.Denom), amount) - - denomPrefixStore, ok := denomPrefixStores[balance.Denom] - if !ok { - denomPrefixStore = k.getDenomAddressPrefixStore(ctx, balance.Denom) - denomPrefixStores[balance.Denom] = denomPrefixStore - } - - // Store a reverse index from denomination to account address with a - // sentinel value. - denomAddrKey := address.MustLengthPrefix(addr) - if !denomPrefixStore.Has(denomAddrKey) { - denomPrefixStore.Set(denomAddrKey, []byte{0}) - } + bz := k.cdc.MustMarshal(&balance) + accountStore.Set([]byte(balance.Denom), bz) } } @@ -275,25 +254,13 @@ func (k BaseSendKeeper) setBalance(ctx sdk.Context, addr sdk.AccAddress, balance } accountStore := k.getAccountStore(ctx, addr) - denomPrefixStore := k.getDenomAddressPrefixStore(ctx, balance.Denom) - // x/bank invariants prohibit persistence of zero balances + // Bank invariants require to not store zero balances. if balance.IsZero() { accountStore.Delete([]byte(balance.Denom)) - denomPrefixStore.Delete(address.MustLengthPrefix(addr)) } else { - amount, err := balance.Amount.Marshal() - if err != nil { - return err - } - accountStore.Set([]byte(balance.Denom), amount) - - // Store a reverse index from denomination to account address with a - // sentinel value. - denomAddrKey := address.MustLengthPrefix(addr) - if !denomPrefixStore.Has(denomAddrKey) { - denomPrefixStore.Set(denomAddrKey, []byte{0}) - } + bz := k.cdc.MustMarshal(&balance) + accountStore.Set([]byte(balance.Denom), bz) } return nil diff --git a/x/bank/keeper/view.go b/x/bank/keeper/view.go index 6f178bb7f7e4..fe46ec9b6ec1 100644 --- a/x/bank/keeper/view.go +++ b/x/bank/keeper/view.go @@ -7,7 +7,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" @@ -35,12 +34,12 @@ type ViewKeeper interface { // BaseViewKeeper implements a read only keeper implementation of ViewKeeper. type BaseViewKeeper struct { cdc codec.BinaryCodec - storeKey storetypes.StoreKey + storeKey sdk.StoreKey ak types.AccountKeeper } // NewBaseViewKeeper returns a new BaseViewKeeper. -func NewBaseViewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak types.AccountKeeper) BaseViewKeeper { +func NewBaseViewKeeper(cdc codec.BinaryCodec, storeKey sdk.StoreKey, ak types.AccountKeeper) BaseViewKeeper { return BaseViewKeeper{ cdc: cdc, storeKey: storeKey, @@ -99,17 +98,16 @@ func (k BaseViewKeeper) GetAccountsBalances(ctx sdk.Context) []types.Balance { // by address. func (k BaseViewKeeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { accountStore := k.getAccountStore(ctx, addr) - amount := sdk.ZeroInt() + bz := accountStore.Get([]byte(denom)) if bz == nil { - return sdk.NewCoin(denom, amount) + return sdk.NewCoin(denom, sdk.ZeroInt()) } - if err := amount.Unmarshal(bz); err != nil { - panic(err) - } + var balance sdk.Coin + k.cdc.MustUnmarshal(bz, &balance) - return sdk.NewCoin(denom, amount) + return balance } // IterateAccountBalances iterates over the balances of a single account and @@ -122,12 +120,10 @@ func (k BaseViewKeeper) IterateAccountBalances(ctx sdk.Context, addr sdk.AccAddr defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - var amount sdk.Int - if err := amount.Unmarshal(iterator.Value()); err != nil { - panic(err) - } + var balance sdk.Coin + k.cdc.MustUnmarshal(iterator.Value(), &balance) - if cb(sdk.NewCoin(string(iterator.Key()), amount)) { + if cb(balance) { break } } @@ -144,7 +140,7 @@ func (k BaseViewKeeper) IterateAllBalances(ctx sdk.Context, cb func(sdk.AccAddre defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - address, denom, err := types.AddressAndDenomFromBalancesStore(iterator.Key()) + address, err := types.AddressFromBalancesStore(iterator.Key()) if err != nil { k.Logger(ctx).With("key", iterator.Key(), "err", err).Error("failed to get address from balances store") // TODO: revisit, for now, panic here to keep same behavior as in 0.42 @@ -152,12 +148,10 @@ func (k BaseViewKeeper) IterateAllBalances(ctx sdk.Context, cb func(sdk.AccAddre panic(err) } - var amount sdk.Int - if err := amount.Unmarshal(iterator.Value()); err != nil { - panic(err) - } + var balance sdk.Coin + k.cdc.MustUnmarshal(iterator.Value(), &balance) - if cb(address, sdk.NewCoin(denom, amount)) { + if cb(address, balance) { break } } @@ -234,11 +228,6 @@ func (k BaseViewKeeper) ValidateBalance(ctx sdk.Context, addr sdk.AccAddress) er // getAccountStore gets the account store of the given address. func (k BaseViewKeeper) getAccountStore(ctx sdk.Context, addr sdk.AccAddress) prefix.Store { store := ctx.KVStore(k.storeKey) - return prefix.NewStore(store, types.CreateAccountBalancesPrefix(addr)) -} -// getDenomAddressPrefixStore returns a prefix store that acts as a reverse index -// between a denomination and account balance for that denomination. -func (k BaseViewKeeper) getDenomAddressPrefixStore(ctx sdk.Context, denom string) prefix.Store { - return prefix.NewStore(ctx.KVStore(k.storeKey), types.CreateDenomAddressPrefix(denom)) + return prefix.NewStore(store, types.CreateAccountBalancesPrefix(addr)) } diff --git a/x/bank/migrations/v036/types.go b/x/bank/legacy/v036/types.go similarity index 100% rename from x/bank/migrations/v036/types.go rename to x/bank/legacy/v036/types.go diff --git a/x/bank/migrations/v038/types.go b/x/bank/legacy/v038/types.go similarity index 100% rename from x/bank/migrations/v038/types.go rename to x/bank/legacy/v038/types.go diff --git a/x/bank/migrations/v040/keys.go b/x/bank/legacy/v040/keys.go similarity index 83% rename from x/bank/migrations/v040/keys.go rename to x/bank/legacy/v040/keys.go index 38bb49a0032d..043c208b627c 100644 --- a/x/bank/migrations/v040/keys.go +++ b/x/bank/legacy/v040/keys.go @@ -3,9 +3,10 @@ package v040 import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/kv" - v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040" + v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040" ) const ( @@ -39,8 +40,10 @@ func DenomMetadataKey(denom string) []byte { // store. The key must not contain the perfix BalancesPrefix as the prefix store // iterator discards the actual prefix. func AddressFromBalancesStore(key []byte) sdk.AccAddress { - kv.AssertKeyAtLeastLength(key, 1+v040auth.AddrLen) addr := key[:v040auth.AddrLen] - kv.AssertKeyLength(addr, v040auth.AddrLen) + if len(addr) != v040auth.AddrLen { + panic(fmt.Sprintf("unexpected account address key length; got: %d, expected: %d", len(addr), v040auth.AddrLen)) + } + return sdk.AccAddress(addr) } diff --git a/x/bank/migrations/v040/migrate.go b/x/bank/legacy/v040/migrate.go similarity index 83% rename from x/bank/migrations/v040/migrate.go rename to x/bank/legacy/v040/migrate.go index 9a7f82a0705c..1c8d270e406a 100644 --- a/x/bank/migrations/v040/migrate.go +++ b/x/bank/legacy/v040/migrate.go @@ -1,9 +1,9 @@ package v040 import ( - v039auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v039" - v036supply "github.com/cosmos/cosmos-sdk/x/bank/migrations/v036" - v038bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v038" + v039auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v039" + v036supply "github.com/cosmos/cosmos-sdk/x/bank/legacy/v036" + v038bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v038" "github.com/cosmos/cosmos-sdk/x/bank/types" ) diff --git a/x/bank/migrations/v040/migrate_test.go b/x/bank/legacy/v040/migrate_test.go similarity index 83% rename from x/bank/migrations/v040/migrate_test.go rename to x/bank/legacy/v040/migrate_test.go index 2a4053e9b44e..e30299ff9251 100644 --- a/x/bank/migrations/v040/migrate_test.go +++ b/x/bank/legacy/v040/migrate_test.go @@ -8,11 +8,11 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - v038auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v038" - v039auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v039" - v036supply "github.com/cosmos/cosmos-sdk/x/bank/migrations/v036" - v038bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v038" - v040bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v040" + v038auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v038" + v039auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v039" + v036supply "github.com/cosmos/cosmos-sdk/x/bank/legacy/v036" + v038bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v038" + v040bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v040" ) func TestMigrate(t *testing.T) { @@ -21,7 +21,7 @@ func TestMigrate(t *testing.T) { WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). - WithCodec(encodingConfig.Codec) + WithJSONCodec(encodingConfig.Marshaler) coins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) addr1, _ := sdk.AccAddressFromBech32("cosmos1xxkueklal9vejv9unqu80w9vptyepfa95pd53u") diff --git a/x/bank/migrations/v040/types.go b/x/bank/legacy/v040/types.go similarity index 100% rename from x/bank/migrations/v040/types.go rename to x/bank/legacy/v040/types.go diff --git a/x/bank/migrations/v043/json.go b/x/bank/legacy/v043/json.go similarity index 100% rename from x/bank/migrations/v043/json.go rename to x/bank/legacy/v043/json.go diff --git a/x/bank/migrations/v043/json_test.go b/x/bank/legacy/v043/json_test.go similarity index 95% rename from x/bank/migrations/v043/json_test.go rename to x/bank/legacy/v043/json_test.go index 709b39c02920..d56ce35195a6 100644 --- a/x/bank/migrations/v043/json_test.go +++ b/x/bank/legacy/v043/json_test.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - v043bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043" + v043bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v043" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -18,7 +18,7 @@ func TestMigrateJSON(t *testing.T) { clientCtx := client.Context{}. WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). - WithCodec(encodingConfig.Codec) + WithCodec(encodingConfig.Marshaler) voter, err := sdk.AccAddressFromBech32("cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh") require.NoError(t, err) diff --git a/x/bank/legacy/v043/keys.go b/x/bank/legacy/v043/keys.go new file mode 100644 index 000000000000..fbef37c9885e --- /dev/null +++ b/x/bank/legacy/v043/keys.go @@ -0,0 +1,12 @@ +package v043 + +const ( + // ModuleName is the name of the module + ModuleName = "bank" +) + +// KVStore keys +var ( + BalancesPrefix = []byte{0x02} + SupplyKey = []byte{0x00} +) diff --git a/x/bank/migrations/v043/store.go b/x/bank/legacy/v043/store.go similarity index 89% rename from x/bank/migrations/v043/store.go rename to x/bank/legacy/v043/store.go index 4c6b56e2b3ee..c4924f17df2d 100644 --- a/x/bank/migrations/v043/store.go +++ b/x/bank/legacy/v043/store.go @@ -3,10 +3,9 @@ package v043 import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040" - v040bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v040" + v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040" + v040bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v040" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -29,7 +28,7 @@ func migrateSupply(store sdk.KVStore, cdc codec.BinaryCodec) error { } // We add a new key for each denom - supplyStore := prefix.NewStore(store, SupplyKey) + supplyStore := prefix.NewStore(store, types.SupplyKey) // We're sure that SupplyI is a Supply struct, there's no other // implementation. @@ -62,7 +61,7 @@ func migrateBalanceKeys(store sdk.KVStore) { for ; oldStoreIter.Valid(); oldStoreIter.Next() { addr := v040bank.AddressFromBalancesStore(oldStoreIter.Key()) denom := oldStoreIter.Key()[v040auth.AddrLen:] - newStoreKey := append(CreateAccountBalancesPrefix(addr), denom...) + newStoreKey := append(types.CreateAccountBalancesPrefix(addr), denom...) // Set new key on store. Values don't change. store.Set(newStoreKey, oldStoreIter.Value()) @@ -77,7 +76,7 @@ func migrateBalanceKeys(store sdk.KVStore) { // - Change balances prefix to 1 byte // - Change supply to be indexed by denom // - Prune balances & supply with zero coins (ref: https://github.com/cosmos/cosmos-sdk/pull/9229) -func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { +func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) error { store := ctx.KVStore(storeKey) migrateBalanceKeys(store) diff --git a/x/bank/migrations/v043/store_test.go b/x/bank/legacy/v043/store_test.go similarity index 88% rename from x/bank/migrations/v043/store_test.go rename to x/bank/legacy/v043/store_test.go index d1b7eae50b35..2b6af2c6ed9b 100644 --- a/x/bank/migrations/v043/store_test.go +++ b/x/bank/legacy/v043/store_test.go @@ -10,8 +10,8 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" - v040bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v040" - v043bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043" + v040bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v040" + v043bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v043" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -28,12 +28,12 @@ func TestSupplyMigration(t *testing.T) { // Old supply was stored as a single blob under the `SupplyKey`. var oldSupply v040bank.SupplyI oldSupply = &types.Supply{Total: sdk.Coins{oldFooCoin, oldBarCoin, oldFooBarCoin}} - oldSupplyBz, err := encCfg.Codec.MarshalInterface(oldSupply) + oldSupplyBz, err := encCfg.Marshaler.MarshalInterface(oldSupply) require.NoError(t, err) store.Set(v040bank.SupplyKey, oldSupplyBz) // Run migration. - err = v043bank.MigrateStore(ctx, bankKey, encCfg.Codec) + err = v043bank.MigrateStore(ctx, bankKey, encCfg.Marshaler) require.NoError(t, err) // New supply is indexed by denom. @@ -75,19 +75,19 @@ func TestBalanceKeysMigration(t *testing.T) { // set 10 foo coin fooCoin := sdk.NewCoin("foo", sdk.NewInt(10)) oldFooKey := append(append(v040bank.BalancesPrefix, addr...), []byte(fooCoin.Denom)...) - fooBz, err := encCfg.Codec.Marshal(&fooCoin) + fooBz, err := encCfg.Marshaler.Marshal(&fooCoin) require.NoError(t, err) store.Set(oldFooKey, fooBz) // set 0 foobar coin fooBarCoin := sdk.NewCoin("foobar", sdk.NewInt(0)) oldKeyFooBar := append(append(v040bank.BalancesPrefix, addr...), []byte(fooBarCoin.Denom)...) - fooBarBz, err := encCfg.Codec.Marshal(&fooBarCoin) + fooBarBz, err := encCfg.Marshaler.Marshal(&fooBarCoin) require.NoError(t, err) store.Set(oldKeyFooBar, fooBarBz) require.NotNil(t, store.Get(oldKeyFooBar)) // before store migation zero values can also exist in store. - err = v043bank.MigrateStore(ctx, bankKey, encCfg.Codec) + err = v043bank.MigrateStore(ctx, bankKey, encCfg.Marshaler) require.NoError(t, err) newKey := append(types.CreateAccountBalancesPrefix(addr), []byte(fooCoin.Denom)...) diff --git a/x/bank/migrations/v043/keys.go b/x/bank/migrations/v043/keys.go deleted file mode 100644 index ef24217ef0f3..000000000000 --- a/x/bank/migrations/v043/keys.go +++ /dev/null @@ -1,45 +0,0 @@ -package v043 - -import ( - "errors" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/address" -) - -const ( - ModuleName = "bank" -) - -var ( - SupplyKey = []byte{0x00} - BalancesPrefix = []byte{0x02} - DenomMetadataPrefix = []byte{0x1} - - ErrInvalidKey = errors.New("invalid key") -) - -func CreateAccountBalancesPrefix(addr []byte) []byte { - return append(BalancesPrefix, address.MustLengthPrefix(addr)...) -} - -func AddressFromBalancesStore(key []byte) (sdk.AccAddress, error) { - if len(key) == 0 { - return nil, ErrInvalidKey - } - - addrLen := key[0] - bound := int(addrLen) - - if len(key)-1 < bound { - return nil, ErrInvalidKey - } - - return key[1 : bound+1], nil -} - -// DenomMetadataKey returns the denomination metadata key. -func DenomMetadataKey(denom string) []byte { - d := []byte(denom) - return append(DenomMetadataPrefix, d...) -} diff --git a/x/bank/migrations/v045/keys.go b/x/bank/migrations/v045/keys.go deleted file mode 100644 index f6a0af5fa6d2..000000000000 --- a/x/bank/migrations/v045/keys.go +++ /dev/null @@ -1,16 +0,0 @@ -package v045 - -var ( - DenomAddressPrefix = []byte{0x03} -) - -// CreateDenomAddressPrefix creates a prefix for a reverse index of denomination -// to account balance for that denomination. -func CreateDenomAddressPrefix(denom string) []byte { - // we add a "zero" byte at the end - null byte terminator, to allow prefix denom prefix - // scan. Setting it is not needed (key[last] = 0) - because this is the default. - key := make([]byte, len(DenomAddressPrefix)+len(denom)+1) - copy(key, DenomAddressPrefix) - copy(key[len(DenomAddressPrefix):], denom) - return key -} diff --git a/x/bank/migrations/v045/store.go b/x/bank/migrations/v045/store.go deleted file mode 100644 index 6a6ee8aa0347..000000000000 --- a/x/bank/migrations/v045/store.go +++ /dev/null @@ -1,94 +0,0 @@ -package v045 - -import ( - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/store/prefix" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/address" - v043 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043" - "github.com/cosmos/cosmos-sdk/x/bank/types" -) - -// MigrateStore performs in-place store migrations from v0.43 to v0.45. The -// migration includes: -// -// - Migrate coin storage to save only amount. -// - Add an additional reverse index from denomination to address. -// - Remove duplicate denom from denom metadata store key. -func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { - store := ctx.KVStore(storeKey) - err := addDenomReverseIndex(store, cdc) - if err != nil { - return err - } - - return migrateDenomMetadata(store) -} - -func addDenomReverseIndex(store sdk.KVStore, cdc codec.BinaryCodec) error { - oldBalancesStore := prefix.NewStore(store, v043.BalancesPrefix) - - oldBalancesIter := oldBalancesStore.Iterator(nil, nil) - defer oldBalancesIter.Close() - - denomPrefixStores := make(map[string]prefix.Store) // memoize prefix stores - - for ; oldBalancesIter.Valid(); oldBalancesIter.Next() { - var balance sdk.Coin - if err := cdc.Unmarshal(oldBalancesIter.Value(), &balance); err != nil { - return err - } - - addr, err := v043.AddressFromBalancesStore(oldBalancesIter.Key()) - if err != nil { - return err - } - - var coin sdk.DecCoin - if err := cdc.Unmarshal(oldBalancesIter.Value(), &coin); err != nil { - return err - } - - bz, err := coin.Amount.Marshal() - if err != nil { - return err - } - - newStore := prefix.NewStore(store, types.CreateAccountBalancesPrefix(addr)) - newStore.Set([]byte(coin.Denom), bz) - - denomPrefixStore, ok := denomPrefixStores[balance.Denom] - if !ok { - denomPrefixStore = prefix.NewStore(store, CreateDenomAddressPrefix(balance.Denom)) - denomPrefixStores[balance.Denom] = denomPrefixStore - } - - // Store a reverse index from denomination to account address with a - // sentinel value. - denomPrefixStore.Set(address.MustLengthPrefix(addr), []byte{0}) - } - - return nil -} - -func migrateDenomMetadata(store sdk.KVStore) error { - oldDenomMetaDataStore := prefix.NewStore(store, v043.DenomMetadataPrefix) - - oldDenomMetaDataIter := oldDenomMetaDataStore.Iterator(nil, nil) - defer oldDenomMetaDataIter.Close() - - for ; oldDenomMetaDataIter.Valid(); oldDenomMetaDataIter.Next() { - oldKey := oldDenomMetaDataIter.Key() - l := len(oldKey)/2 + 1 - - var newKey = make([]byte, len(types.DenomMetadataPrefix)+l) - // old key: prefix_bytes | denom_bytes | denom_bytes - copy(newKey, types.DenomMetadataPrefix) - copy(newKey[len(types.DenomMetadataPrefix):], oldKey[:l]) - store.Set(newKey, oldDenomMetaDataIter.Value()) - oldDenomMetaDataStore.Delete(oldKey) - } - - return nil -} diff --git a/x/bank/migrations/v045/store_test.go b/x/bank/migrations/v045/store_test.go deleted file mode 100644 index e155e98eea1d..000000000000 --- a/x/bank/migrations/v045/store_test.go +++ /dev/null @@ -1,129 +0,0 @@ -package v045_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/store/prefix" - "github.com/cosmos/cosmos-sdk/testutil" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/address" - v043 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043" - v045 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v045" - "github.com/cosmos/cosmos-sdk/x/bank/types" -) - -func TestMigrateStore(t *testing.T) { - encCfg := simapp.MakeTestEncodingConfig() - bankKey := sdk.NewKVStoreKey("bank") - ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test")) - store := ctx.KVStore(bankKey) - - addr := sdk.AccAddress([]byte("addr________________")) - prefixAccStore := prefix.NewStore(store, v043.CreateAccountBalancesPrefix(addr)) - - balances := sdk.NewCoins( - sdk.NewCoin("foo", sdk.NewInt(10000)), - sdk.NewCoin("bar", sdk.NewInt(20000)), - ) - - for _, b := range balances { - bz, err := encCfg.Codec.Marshal(&b) - require.NoError(t, err) - - prefixAccStore.Set([]byte(b.Denom), bz) - } - - require.NoError(t, v045.MigrateStore(ctx, bankKey, encCfg.Codec)) - - for _, b := range balances { - addrPrefixStore := prefix.NewStore(store, types.CreateAccountBalancesPrefix(addr)) - bz := addrPrefixStore.Get([]byte(b.Denom)) - var expected sdk.Int - require.NoError(t, expected.Unmarshal(bz)) - require.Equal(t, expected, b.Amount) - } - - for _, b := range balances { - denomPrefixStore := prefix.NewStore(store, v045.CreateDenomAddressPrefix(b.Denom)) - bz := denomPrefixStore.Get(address.MustLengthPrefix(addr)) - require.NotNil(t, bz) - } -} - -func TestMigrateDenomMetaData(t *testing.T) { - encCfg := simapp.MakeTestEncodingConfig() - bankKey := sdk.NewKVStoreKey("bank") - ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test")) - store := ctx.KVStore(bankKey) - metaData := []types.Metadata{ - { - Name: "Cosmos Hub Atom", - Symbol: "ATOM", - Description: "The native staking token of the Cosmos Hub.", - DenomUnits: []*types.DenomUnit{ - {"uatom", uint32(0), []string{"microatom"}}, - {"matom", uint32(3), []string{"milliatom"}}, - {"atom", uint32(6), nil}, - }, - Base: "uatom", - Display: "atom", - }, - { - Name: "Token", - Symbol: "TOKEN", - Description: "The native staking token of the Token Hub.", - DenomUnits: []*types.DenomUnit{ - {"1token", uint32(5), []string{"decitoken"}}, - {"2token", uint32(4), []string{"centitoken"}}, - {"3token", uint32(7), []string{"dekatoken"}}, - }, - Base: "utoken", - Display: "token", - }, - } - denomMetadataStore := prefix.NewStore(store, v043.DenomMetadataPrefix) - - for i := range []int{0, 1} { - key := append(v043.DenomMetadataPrefix, []byte(metaData[i].Base)...) - // keys before 0.44 had denom two times in the key - key = append(key, []byte(metaData[i].Base)...) - bz, err := encCfg.Codec.Marshal(&metaData[i]) - require.NoError(t, err) - denomMetadataStore.Set(key, bz) - } - - require.NoError(t, v045.MigrateStore(ctx, bankKey, encCfg.Codec)) - - denomMetadataStore = prefix.NewStore(store, v043.DenomMetadataPrefix) - denomMetadataIter := denomMetadataStore.Iterator(nil, nil) - defer denomMetadataIter.Close() - for i := 0; denomMetadataIter.Valid(); denomMetadataIter.Next() { - var result types.Metadata - newKey := denomMetadataIter.Key() - - // make sure old entry is deleted - oldKey := append(newKey, newKey[1:]...) - bz := denomMetadataStore.Get(oldKey) - require.Nil(t, bz) - - require.Equal(t, string(newKey)[1:], metaData[i].Base, "idx: %d", i) - bz = denomMetadataStore.Get(denomMetadataIter.Key()) - require.NotNil(t, bz) - err := encCfg.Codec.Unmarshal(bz, &result) - require.NoError(t, err) - assertMetaDataEqual(t, metaData[i], result) - i++ - } -} - -func assertMetaDataEqual(t *testing.T, expected, actual types.Metadata) { - require.Equal(t, expected.GetBase(), actual.GetBase()) - require.Equal(t, expected.GetDisplay(), actual.GetDisplay()) - require.Equal(t, expected.GetDescription(), actual.GetDescription()) - require.Equal(t, expected.GetDenomUnits()[1].GetDenom(), actual.GetDenomUnits()[1].GetDenom()) - require.Equal(t, expected.GetDenomUnits()[1].GetExponent(), actual.GetDenomUnits()[1].GetExponent()) - require.Equal(t, expected.GetDenomUnits()[1].GetAliases(), actual.GetDenomUnits()[1].GetAliases()) -} diff --git a/x/bank/module.go b/x/bank/module.go index 62038da8b7b8..c43251acc253 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -20,8 +20,9 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/bank/client/cli" + "github.com/cosmos/cosmos-sdk/x/bank/client/rest" "github.com/cosmos/cosmos-sdk/x/bank/keeper" - v040 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v040" + v040 "github.com/cosmos/cosmos-sdk/x/bank/legacy/v040" "github.com/cosmos/cosmos-sdk/x/bank/simulation" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -62,9 +63,9 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingCo } // RegisterRESTRoutes registers the REST routes for the bank module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/bank` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { + rest.RegisterHandlers(clientCtx, rtr) +} // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the bank module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { @@ -103,13 +104,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryServer(cfg.QueryServer(), am.keeper) m := keeper.NewMigrator(am.keeper.(keeper.BaseKeeper)) - if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil { - panic(fmt.Sprintf("failed to migrate x/bank from version 1 to 2: %v", err)) - } - - if err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3); err != nil { - panic(fmt.Sprintf("failed to migrate x/bank from version 2 to 3: %v", err)) - } + cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2) } // NewAppModule creates a new AppModule object @@ -129,9 +124,9 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper) } -// Deprecated: Route returns the message routing key for the bank module. +// Route returns the message routing key for the bank module. func (am AppModule) Route() sdk.Route { - return sdk.Route{} + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) } // QuerierRoute returns the bank module's querier route name. @@ -162,7 +157,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 3 } +func (AppModule) ConsensusVersion() uint64 { return 2 } // BeginBlock performs a no-op. func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index 05d14a7375f7..3b30157b857f 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -152,7 +152,7 @@ func sendMsgSend( return err } - _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) + _, _, err = app.Deliver(txGen.TxEncoder(), tx) if err != nil { return err } @@ -374,7 +374,7 @@ func sendMsgMultiSend( return err } - _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) + _, _, err = app.Deliver(txGen.TxEncoder(), tx) if err != nil { return err } diff --git a/x/bank/simulation/operations_test.go b/x/bank/simulation/operations_test.go index f50c2b944885..aeaa9f938905 100644 --- a/x/bank/simulation/operations_test.go +++ b/x/bank/simulation/operations_test.go @@ -13,7 +13,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/bank/simulation" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -26,7 +25,7 @@ type SimTestSuite struct { func (suite *SimTestSuite) SetupTest() { checkTx := false - app := simapp.Setup(suite.T(), checkTx) + app := simapp.Setup(checkTx) suite.app = app suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{}) } @@ -194,7 +193,7 @@ func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Ac for _, account := range accounts { acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, account.Address) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) - suite.Require().NoError(testutil.FundAccount(suite.app.BankKeeper, suite.ctx, account.Address, initCoins)) + suite.Require().NoError(simapp.FundAccount(suite.app.BankKeeper, suite.ctx, account.Address, initCoins)) } return accounts diff --git a/x/bank/spec/01_state.md b/x/bank/spec/01_state.md index 97584ca1abb6..5328e8b3caee 100644 --- a/x/bank/spec/01_state.md +++ b/x/bank/spec/01_state.md @@ -4,16 +4,9 @@ order: 1 # State -The `x/bank` module keeps state of three primary objects: +The `x/bank` module keeps state of three primary objects, account balances, denom metadata and the +total supply of all balances. -1. Account balances -2. Denomination metadata -3. The total supply of all balances - -In addition, the `x/bank` module keeps the following indexes to manage the -aforementioned state: - -- Supply Index: `0x0 | byte(denom) -> byte(amount)` -- Denom Metadata Index: `0x1 | byte(denom) -> ProtocolBuffer(Metadata)` -- Balances Index: `0x2 | byte(address length) | []byte(address) | []byte(balance.Denom) -> ProtocolBuffer(balance)` -- Reverse Denomination to Address Index: `0x03 | byte(denom) | 0x00 | []byte(address) -> 0` +- 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/spec/06_client.md b/x/bank/spec/06_client.md deleted file mode 100644 index 077e950e8baf..000000000000 --- a/x/bank/spec/06_client.md +++ /dev/null @@ -1,390 +0,0 @@ - - -# Client - -## CLI - -A user can query and interact with the `bank` module using the CLI. - -### Query - -The `query` commands allow users to query `bank` state. - -``` -simd query bank --help -``` - -#### balances - -The `balances` command allows users to query account balances by address. - -``` -simd query bank balances [address] [flags] -``` - -Example: - -``` -simd query bank balances cosmos1.. -``` - -Example Output: - -``` -balances: -- amount: "1000000000" - denom: stake -pagination: - next_key: null - total: "0" -``` - -#### denom-metadata - -The `denom-metadata` command allows users to query metadata for coin denominations. A user can query metadata for a single denomination using the `--denom` flag or all denominations without it. - -``` -simd query bank denom-metadata [flags] -``` - -Example: - -``` -simd query bank denom-metadata --denom stake -``` - -Example Output: - -``` -metadata: - base: stake - denom_units: - - aliases: - - STAKE - denom: stake - description: native staking token of simulation app - display: stake - name: SimApp Token - symbol: STK -``` - -#### total - -The `total` command allows users to query the total supply of coins. A user can query the total supply for a single coin using the `--denom` flag or all coins without it. - -``` -simd query bank total [flags] -``` - -Example: - -``` -simd query bank total --denom stake -``` - -Example Output: - -``` -amount: "10000000000" -denom: stake -``` - -### Transactions - -The `tx` commands allow users to interact with the `bank` module. - -``` -simd tx bank --help -``` - -#### send - -The `send` command allows users to send funds from one account to another. - -``` -simd tx bank send [from_key_or_address] [to_address] [amount] [flags] -``` - -Example: - -``` -simd tx bank send cosmos1.. cosmos1.. 100stake -``` - -## gRPC - -A user can query the `bank` module using gRPC endpoints. - -### Balance - -The `Balance` endpoint allows users to query account balance by address for a given denomination. - -``` -cosmos.bank.v1beta1.Query/Balance -``` - -Example: - -``` -grpcurl -plaintext \ - -d '{"address":"cosmos1..","denom":"stake"}' \ - localhost:9090 \ - cosmos.bank.v1beta1.Query/Balance -``` - -Example Output: - -``` -{ - "balance": { - "denom": "stake", - "amount": "1000000000" - } -} -``` - -### AllBalances - -The `AllBalances` endpoint allows users to query account balance by address for all denominations. - -``` -cosmos.bank.v1beta1.Query/AllBalances -``` - -Example: - -``` -grpcurl -plaintext \ - -d '{"address":"cosmos1.."}' \ - localhost:9090 \ - cosmos.bank.v1beta1.Query/AllBalances -``` - -Example Output: - -``` -{ - "balances": [ - { - "denom": "stake", - "amount": "1000000000" - } - ], - "pagination": { - "total": "1" - } -} -``` - -### DenomMetadata - -The `DenomMetadata` endpoint allows users to query metadata for a single coin denomination. - -``` -cosmos.bank.v1beta1.Query/DenomMetadata -``` - -Example: - -``` -grpcurl -plaintext \ - -d '{"denom":"stake"}' \ - localhost:9090 \ - cosmos.bank.v1beta1.Query/DenomMetadata -``` - -Example Output: - -``` -{ - "metadata": { - "description": "native staking token of simulation app", - "denomUnits": [ - { - "denom": "stake", - "aliases": [ - "STAKE" - ] - } - ], - "base": "stake", - "display": "stake", - "name": "SimApp Token", - "symbol": "STK" - } -} -``` - -### DenomsMetadata - -The `DenomsMetadata` endpoint allows users to query metadata for all coin denominations. - -``` -cosmos.bank.v1beta1.Query/DenomsMetadata -``` - -Example: - -``` -grpcurl -plaintext \ - localhost:9090 \ - cosmos.bank.v1beta1.Query/DenomsMetadata -``` - -Example Output: - -``` -{ - "metadatas": [ - { - "description": "native staking token of simulation app", - "denomUnits": [ - { - "denom": "stake", - "aliases": [ - "STAKE" - ] - } - ], - "base": "stake", - "display": "stake", - "name": "SimApp Token", - "symbol": "STK" - } - ], - "pagination": { - "total": "1" - } -} -``` - -### DenomOwners - -The `DenomOwners` endpoint allows users to query metadata for a single coin denomination. - -``` -cosmos.bank.v1beta1.Query/DenomOwners -``` - -Example: - -``` -grpcurl -plaintext \ - -d '{"denom":"stake"}' \ - localhost:9090 \ - cosmos.bank.v1beta1.Query/DenomOwners -``` - -Example Output: - -``` -{ - "denomOwners": [ - { - "address": "cosmos1..", - "balance": { - "denom": "stake", - "amount": "5000000000" - } - }, - { - "address": "cosmos1..", - "balance": { - "denom": "stake", - "amount": "5000000000" - } - }, - ], - "pagination": { - "total": "2" - } -} -``` - -### TotalSupply - -The `TotalSupply` endpoint allows users to query the total supply of all coins. - -``` -cosmos.bank.v1beta1.Query/TotalSupply -``` - -Example: - -``` -grpcurl -plaintext \ - localhost:9090 \ - cosmos.bank.v1beta1.Query/TotalSupply -``` - -Example Output: - -``` -{ - "supply": [ - { - "denom": "stake", - "amount": "10000000000" - } - ], - "pagination": { - "total": "1" - } -} -``` - -### SupplyOf - -The `SupplyOf` endpoint allows users to query the total supply of a single coin. - -``` -cosmos.bank.v1beta1.Query/SupplyOf -``` - -Example: - -``` -grpcurl -plaintext \ - -d '{"denom":"stake"}' \ - localhost:9090 \ - cosmos.bank.v1beta1.Query/SupplyOf -``` - -Example Output: - -``` -{ - "amount": { - "denom": "stake", - "amount": "10000000000" - } -} -``` - -### Params - -The `Params` endpoint allows users to query the parameters of the `bank` module. - -``` -cosmos.bank.v1beta1.Query/Params -``` - -Example: - -``` -grpcurl -plaintext \ - localhost:9090 \ - cosmos.bank.v1beta1.Query/Params -``` - -Example Output: - -``` -{ - "params": { - "defaultSendEnabled": true - } -} -``` diff --git a/x/bank/spec/README.md b/x/bank/spec/README.md index 53b68c7d7b57..9a1a0afb6edc 100644 --- a/x/bank/spec/README.md +++ b/x/bank/spec/README.md @@ -100,6 +100,3 @@ The available permissions are: 4. **[Events](04_events.md)** - [Handlers](04_events.md#handlers) 5. **[Parameters](05_params.md)** -6. **[Client](06_client.md)** - - [CLI](06_client.md#cli) - - [gRPC](06_client.md#grpc) \ No newline at end of file diff --git a/x/bank/testutil/test_helpers.go b/x/bank/testutil/test_helpers.go deleted file mode 100644 index e8805ed7b348..000000000000 --- a/x/bank/testutil/test_helpers.go +++ /dev/null @@ -1,35 +0,0 @@ -package testutil - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" -) - -// FundAccount is a utility function that funds an account by minting and -// sending the coins to the address. This should be used for testing purposes -// only! -// -// TODO: Instead of using the mint module account, which has the -// permission of minting, create a "faucet" account. (@fdymylja) -func FundAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, addr sdk.AccAddress, amounts sdk.Coins) error { - if err := bankKeeper.MintCoins(ctx, minttypes.ModuleName, amounts); err != nil { - return err - } - - return bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, amounts) -} - -// FundModuleAccount is a utility function that funds a module account by -// minting and sending the coins to the address. This should be used for testing -// purposes only! -// -// TODO: Instead of using the mint module account, which has the -// permission of minting, create a "faucet" account. (@fdymylja) -func FundModuleAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, recipientMod string, amounts sdk.Coins) error { - if err := bankKeeper.MintCoins(ctx, minttypes.ModuleName, amounts); err != nil { - return err - } - - return bankKeeper.SendCoinsFromModuleToModule(ctx, minttypes.ModuleName, recipientMod, amounts) -} diff --git a/x/bank/types/authz.pb.go b/x/bank/types/authz.pb.go index e5352246fbef..92444cb98e91 100644 --- a/x/bank/types/authz.pb.go +++ b/x/bank/types/authz.pb.go @@ -5,11 +5,11 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + _ "github.com/regen-network/cosmos-proto" io "io" math "math" math_bits "math/bits" @@ -92,10 +92,10 @@ var fileDescriptor_a4d2a37888ea779f = []byte{ 0x9c, 0x9f, 0x99, 0xe7, 0x64, 0x70, 0xe2, 0x9e, 0x3c, 0xc3, 0xaa, 0xfb, 0xf2, 0x1a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0x50, 0x67, 0x40, 0x29, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x92, 0xca, 0x82, 0xd4, 0x62, 0xb0, 0x86, 0xe2, 0x20, 0x2e, 0xb0, 0xf9, 0x3e, 0x20, 0xe3, - 0xad, 0x04, 0x4f, 0x6d, 0xd1, 0xe5, 0x45, 0x71, 0x80, 0x93, 0xf3, 0x89, 0x47, 0x72, 0x8c, 0x17, + 0xad, 0x04, 0x2f, 0x6d, 0xd1, 0xe5, 0x45, 0x71, 0x80, 0x93, 0xf3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x69, 0xe2, 0xb5, 0xa2, 0x02, 0x12, 0x9e, 0x60, 0x9b, 0x92, 0xd8, - 0xc0, 0x5e, 0x34, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x8c, 0x86, 0xc3, 0x2e, 0x6b, 0x01, 0x00, + 0xc0, 0x5e, 0x34, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x3b, 0xce, 0xe1, 0x4c, 0x6b, 0x01, 0x00, 0x00, } diff --git a/x/bank/types/balance.go b/x/bank/types/balance.go index 78539ace6cff..b944fea27f85 100644 --- a/x/bank/types/balance.go +++ b/x/bank/types/balance.go @@ -30,14 +30,33 @@ func (b Balance) GetCoins() sdk.Coins { // Validate checks for address and coins correctness. func (b Balance) Validate() error { - if _, err := sdk.AccAddressFromBech32(b.Address); err != nil { + _, err := sdk.AccAddressFromBech32(b.Address) + if err != nil { return err } + seenDenoms := make(map[string]bool) - if err := b.Coins.Validate(); err != nil { - return err + // NOTE: we perform a custom validation since the coins.Validate function + // errors on zero balance coins + for _, coin := range b.Coins { + if seenDenoms[coin.Denom] { + return fmt.Errorf("duplicate denomination %s", coin.Denom) + } + + if err := sdk.ValidateDenom(coin.Denom); err != nil { + return err + } + + if coin.IsNegative() { + return fmt.Errorf("coin %s amount is cannot be negative", coin.Denom) + } + + seenDenoms[coin.Denom] = true } + // sort the coins post validation + b.Coins = b.Coins.Sort() + return nil } diff --git a/x/bank/types/balance_test.go b/x/bank/types/balance_test.go index 10ee2a74bf6e..f328314910b7 100644 --- a/x/bank/types/balance_test.go +++ b/x/bank/types/balance_test.go @@ -64,41 +64,6 @@ func TestBalanceValidate(t *testing.T) { }, true, }, - { - "0 value coin", - bank.Balance{ - Address: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", - Coins: sdk.Coins{ - sdk.NewInt64Coin("atom", 0), - sdk.NewInt64Coin("zatom", 2), - }, - }, - true, - }, - { - "unsorted coins", - bank.Balance{ - Address: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", - Coins: sdk.Coins{ - sdk.NewInt64Coin("atom", 2), - sdk.NewInt64Coin("zatom", 2), - sdk.NewInt64Coin("batom", 12), - }, - }, - true, - }, - { - "valid sorted coins", - bank.Balance{ - Address: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", - Coins: sdk.Coins{ - sdk.NewInt64Coin("atom", 2), - sdk.NewInt64Coin("batom", 12), - sdk.NewInt64Coin("zatom", 2), - }, - }, - false, - }, } for _, tc := range testCases { diff --git a/x/bank/types/bank.pb.go b/x/bank/types/bank.pb.go index c720f94a3d98..f190a457b28c 100644 --- a/x/bank/types/bank.pb.go +++ b/x/bank/types/bank.pb.go @@ -5,11 +5,11 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + _ "github.com/regen-network/cosmos-proto" io "io" math "math" math_bits "math/bits" @@ -28,8 +28,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the bank module. type Params struct { - SendEnabled []*SendEnabled `protobuf:"bytes,1,rep,name=send_enabled,json=sendEnabled,proto3" json:"send_enabled,omitempty"` - DefaultSendEnabled bool `protobuf:"varint,2,opt,name=default_send_enabled,json=defaultSendEnabled,proto3" json:"default_send_enabled,omitempty"` + SendEnabled []*SendEnabled `protobuf:"bytes,1,rep,name=send_enabled,json=sendEnabled,proto3" json:"send_enabled,omitempty" yaml:"send_enabled,omitempty"` + DefaultSendEnabled bool `protobuf:"varint,2,opt,name=default_send_enabled,json=defaultSendEnabled,proto3" json:"default_send_enabled,omitempty" yaml:"default_send_enabled,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -336,11 +336,6 @@ type Metadata struct { // symbol is the token symbol usually shown on exchanges (eg: ATOM). This can // be the same as the display. Symbol string `protobuf:"bytes,6,opt,name=symbol,proto3" json:"symbol,omitempty"` - // URI to a document (on or off-chain) that contains additional information. Optional. - URI string `protobuf:"bytes,7,opt,name=uri,proto3" json:"uri,omitempty"` - // URIHash is a sha256 hash of a document pointed by URI. It's used to verify that - // the document didn't change. Optional. - URIHash string `protobuf:"bytes,8,opt,name=uri_hash,json=uriHash,proto3" json:"uri_hash,omitempty"` } func (m *Metadata) Reset() { *m = Metadata{} } @@ -418,20 +413,6 @@ func (m *Metadata) GetSymbol() string { return "" } -func (m *Metadata) GetURI() string { - if m != nil { - return m.URI - } - return "" -} - -func (m *Metadata) GetURIHash() string { - if m != nil { - return m.URIHash - } - return "" -} - func init() { proto.RegisterType((*Params)(nil), "cosmos.bank.v1beta1.Params") proto.RegisterType((*SendEnabled)(nil), "cosmos.bank.v1beta1.SendEnabled") @@ -445,47 +426,44 @@ func init() { func init() { proto.RegisterFile("cosmos/bank/v1beta1/bank.proto", fileDescriptor_dd052eee12edf988) } var fileDescriptor_dd052eee12edf988 = []byte{ - // 626 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x54, 0x41, 0x6b, 0x13, 0x41, - 0x14, 0xce, 0x34, 0x4d, 0xb2, 0x9d, 0xe8, 0x65, 0x0c, 0x32, 0xed, 0x61, 0x13, 0x72, 0x90, 0x28, - 0x34, 0x49, 0xab, 0xa7, 0x20, 0x88, 0xad, 0xa2, 0x11, 0x44, 0xd9, 0x52, 0x04, 0x2f, 0x61, 0x92, - 0x19, 0x93, 0xa1, 0xbb, 0x33, 0xcb, 0xce, 0x6c, 0x69, 0x7e, 0x80, 0x20, 0x9e, 0x3c, 0x7a, 0xec, - 0x51, 0x3d, 0x17, 0xfc, 0x0b, 0xc5, 0x53, 0xf1, 0xe4, 0xa9, 0x4a, 0x7a, 0xf1, 0x67, 0xc8, 0xcc, - 0xec, 0xa6, 0x29, 0x54, 0xf1, 0xe0, 0xc5, 0xd3, 0xbe, 0xef, 0x7d, 0xef, 0x7d, 0xef, 0xbd, 0x99, - 0x37, 0x0b, 0xfd, 0x91, 0x54, 0x91, 0x54, 0x9d, 0x21, 0x11, 0x7b,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xa3, 0x41, 0x2a, 0xb8, 0xce, 0x2f, 0xcd, - 0xbf, 0xf4, 0x75, 0xcd, 0xfb, 0x0d, 0x20, 0xcd, 0x4d, 0x85, 0x10, 0x5c, 0x36, 0x47, 0x8c, 0x8b, - 0x56, 0xdb, 0xda, 0xa6, 0x3b, 0xca, 0x55, 0x1c, 0x92, 0x29, 0x5e, 0xb6, 0xee, 0x1c, 0x9a, 0x68, - 0x41, 0x22, 0x86, 0x4b, 0x2e, 0xda, 0xd8, 0xe8, 0x3a, 0x2c, 0xab, 0x69, 0x34, 0x94, 0x21, 0x2e, - 0x5b, 0x6f, 0x86, 0xd0, 0x2a, 0x2c, 0xa6, 0x09, 0xc7, 0x15, 0xbb, 0x79, 0x95, 0xd9, 0x69, 0xbd, - 0xb8, 0x1b, 0xf4, 0x03, 0xe3, 0x43, 0x37, 0xa0, 0x97, 0x26, 0x7c, 0x30, 0x21, 0x6a, 0x82, 0x3d, - 0xcb, 0x57, 0x67, 0xa7, 0xf5, 0xca, 0x6e, 0xd0, 0x7f, 0x4c, 0xd4, 0x24, 0xa8, 0xa4, 0x09, 0x37, - 0xc6, 0xd6, 0xf6, 0xf1, 0xcc, 0x07, 0x27, 0x33, 0x1f, 0xfc, 0x98, 0xf9, 0xe0, 0xdd, 0x99, 0x5f, - 0x38, 0x39, 0xf3, 0x0b, 0xdf, 0xce, 0xfc, 0xc2, 0xcb, 0x9b, 0x7f, 0x73, 0x7d, 0x76, 0x07, 0x86, - 0x65, 0xfb, 0x4f, 0xba, 0xfd, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x5e, 0x80, 0x89, 0x32, 0x1b, 0x05, - 0x00, 0x00, + // 592 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0xbf, 0x6f, 0xd3, 0x40, + 0x14, 0xf6, 0x35, 0x8d, 0x49, 0x2f, 0xb0, 0x1c, 0x15, 0x72, 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c, 0xd0, 0x54, 0x7f, + 0x33, 0xb7, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x03, 0xbf, 0xe9, 0xee, 0x04, 0x00, 0x00, } func (this *SendEnabled) Equal(that interface{}) bool { @@ -820,20 +798,6 @@ func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.URIHash) > 0 { - i -= len(m.URIHash) - copy(dAtA[i:], m.URIHash) - i = encodeVarintBank(dAtA, i, uint64(len(m.URIHash))) - i-- - dAtA[i] = 0x42 - } - if len(m.URI) > 0 { - i -= len(m.URI) - copy(dAtA[i:], m.URI) - i = encodeVarintBank(dAtA, i, uint64(len(m.URI))) - i-- - dAtA[i] = 0x3a - } if len(m.Symbol) > 0 { i -= len(m.Symbol) copy(dAtA[i:], m.Symbol) @@ -1038,14 +1002,6 @@ func (m *Metadata) Size() (n int) { if l > 0 { n += 1 + l + sovBank(uint64(l)) } - l = len(m.URI) - if l > 0 { - n += 1 + l + sovBank(uint64(l)) - } - l = len(m.URIHash) - if l > 0 { - n += 1 + l + sovBank(uint64(l)) - } return n } @@ -1933,70 +1889,6 @@ func (m *Metadata) Unmarshal(dAtA []byte) error { } m.Symbol = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field URI", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBank - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthBank - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthBank - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.URI = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field URIHash", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBank - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthBank - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthBank - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.URIHash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipBank(dAtA[iNdEx:]) diff --git a/x/bank/types/expected_keepers.go b/x/bank/types/expected_keepers.go index 23ca020a34b0..7307864b86e6 100644 --- a/x/bank/types/expected_keepers.go +++ b/x/bank/types/expected_keepers.go @@ -13,7 +13,6 @@ type AccountKeeper interface { GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI GetAllAccounts(ctx sdk.Context) []types.AccountI - HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool SetAccount(ctx sdk.Context, acc types.AccountI) IterateAccounts(ctx sdk.Context, process func(types.AccountI) bool) diff --git a/x/bank/types/genesis.pb.go b/x/bank/types/genesis.pb.go index 1e8ecae3d0b5..4e4724f34a7d 100644 --- a/x/bank/types/genesis.pb.go +++ b/x/bank/types/genesis.pb.go @@ -5,7 +5,6 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" @@ -36,7 +35,7 @@ type GenesisState struct { // balances. Otherwise, it will be used to validate that the sum of the balances equals this amount. Supply github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=supply,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"supply"` // denom_metadata defines the metadata of the differents coins. - DenomMetadata []Metadata `protobuf:"bytes,4,rep,name=denom_metadata,json=denomMetadata,proto3" json:"denom_metadata"` + DenomMetadata []Metadata `protobuf:"bytes,4,rep,name=denom_metadata,json=denomMetadata,proto3" json:"denom_metadata" yaml:"denom_metadata"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -150,32 +149,31 @@ func init() { func init() { proto.RegisterFile("cosmos/bank/v1beta1/genesis.proto", fileDescriptor_8f007de11b420c6e) } var fileDescriptor_8f007de11b420c6e = []byte{ - // 395 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x3f, 0x4f, 0xfa, 0x40, - 0x18, 0xc7, 0x5b, 0xe0, 0x07, 0xfc, 0x0e, 0x75, 0xa8, 0x0c, 0x05, 0xb5, 0x45, 0x26, 0x1c, 0x68, - 0x05, 0x27, 0x1d, 0x4c, 0x2c, 0x83, 0x89, 0x89, 0x89, 0x81, 0xcd, 0x85, 0x5c, 0xdb, 0x4b, 0x6d, - 0xa0, 0xbd, 0xa6, 0x77, 0x18, 0x79, 0x07, 0x8e, 0xbe, 0x04, 0x66, 0x66, 0x27, 0x5f, 0x01, 0x23, - 0x71, 0x72, 0x52, 0x03, 0x8b, 0x2f, 0xc3, 0xf4, 0xee, 0xa8, 0x26, 0x12, 0x27, 0xa7, 0xfe, 0xf9, - 0x7e, 0x3f, 0xdf, 0xe7, 0x79, 0xee, 0x1e, 0xb0, 0xef, 0x60, 0x12, 0x60, 0x62, 0xda, 0x30, 0x1c, - 0x98, 0xb7, 0x2d, 0x1b, 0x51, 0xd8, 0x32, 0x3d, 0x14, 0x22, 0xe2, 0x13, 0x23, 0x8a, 0x31, 0xc5, - 0xca, 0x36, 0xb7, 0x18, 0x89, 0xc5, 0x10, 0x96, 0x6a, 0xd9, 0xc3, 0x1e, 0x66, 0xba, 0x99, 0xbc, - 0x71, 0x6b, 0x55, 0x4b, 0xd3, 0x08, 0x4a, 0xd3, 0x1c, 0xec, 0x87, 0x3f, 0xf4, 0x6f, 0xd5, 0x58, - 0x2e, 0xd7, 0x2b, 0x5c, 0xef, 0xf3, 0x60, 0x51, 0x97, 0x7d, 0xd4, 0x9f, 0x32, 0x60, 0xe3, 0x9c, - 0xf7, 0xd5, 0xa3, 0x90, 0x22, 0xe5, 0x18, 0xe4, 0x23, 0x18, 0xc3, 0x80, 0xa8, 0x72, 0x4d, 0x6e, - 0x94, 0xda, 0x3b, 0xc6, 0x9a, 0x3e, 0x8d, 0x2b, 0x66, 0xb1, 0x72, 0xb3, 0x57, 0x5d, 0xea, 0x0a, - 0x40, 0x39, 0x05, 0x45, 0x1b, 0x0e, 0x61, 0xe8, 0x20, 0xa2, 0x66, 0x6a, 0xd9, 0x46, 0xa9, 0xbd, - 0xbb, 0x16, 0xb6, 0xb8, 0x49, 0xd0, 0x29, 0xa3, 0x38, 0x20, 0x4f, 0x46, 0x51, 0x34, 0x1c, 0xab, - 0x59, 0x46, 0x57, 0xbe, 0x68, 0x82, 0x52, 0xba, 0x83, 0xfd, 0xd0, 0x3a, 0x4c, 0xd0, 0xe9, 0x9b, - 0xde, 0xf0, 0x7c, 0x7a, 0x33, 0xb2, 0x0d, 0x07, 0x07, 0x62, 0x2e, 0xf1, 0x68, 0x12, 0x77, 0x60, - 0xd2, 0x71, 0x84, 0x08, 0x03, 0x48, 0x57, 0x44, 0x2b, 0x17, 0x60, 0xcb, 0x45, 0x21, 0x0e, 0xfa, - 0x01, 0xa2, 0xd0, 0x85, 0x14, 0xaa, 0x39, 0x56, 0x6c, 0x6f, 0x6d, 0xab, 0x97, 0xc2, 0x24, 0x7a, - 0xdd, 0x64, 0xe8, 0xea, 0x67, 0x7d, 0x2a, 0x83, 0x82, 0x18, 0x46, 0x69, 0x83, 0x02, 0x74, 0xdd, - 0x18, 0x11, 0x7e, 0x70, 0xff, 0x2d, 0xf5, 0xf9, 0xb1, 0x59, 0x16, 0x99, 0x67, 0x5c, 0xe9, 0xd1, - 0xd8, 0x0f, 0xbd, 0xee, 0xca, 0xa8, 0x40, 0xf0, 0x2f, 0xb9, 0xc5, 0xd5, 0x69, 0xfd, 0xe9, 0xbc, - 0x3c, 0xf9, 0xa4, 0x78, 0x3f, 0xd1, 0xa5, 0x8f, 0x89, 0x2e, 0x59, 0x9d, 0xd9, 0x42, 0x93, 0xe7, - 0x0b, 0x4d, 0x7e, 0x5f, 0x68, 0xf2, 0xc3, 0x52, 0x93, 0xe6, 0x4b, 0x4d, 0x7a, 0x59, 0x6a, 0xd2, - 0xf5, 0xc1, 0xaf, 0xa1, 0x77, 0x7c, 0xad, 0x58, 0xb6, 0x9d, 0x67, 0x5b, 0x73, 0xf4, 0x19, 0x00, - 0x00, 0xff, 0xff, 0x78, 0xd8, 0xf3, 0x7f, 0xe0, 0x02, 0x00, 0x00, + // 383 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x3f, 0x4f, 0xc2, 0x40, + 0x18, 0x87, 0x5b, 0x40, 0xc0, 0x43, 0x1d, 0xaa, 0x26, 0x15, 0xa5, 0xc5, 0x4e, 0x38, 0xd8, 0x0a, + 0x4e, 0x32, 0x38, 0x94, 0xc1, 0xc9, 0xc4, 0xd4, 0xcd, 0xc5, 0x5c, 0xdb, 0x4b, 0x6d, 0xa0, 0xbd, + 0x86, 0x3b, 0x8c, 0x7c, 0x03, 0x47, 0x3e, 0x02, 0xb3, 0x9f, 0x84, 0x91, 0xc4, 0xc5, 0x09, 0x0d, + 0x2c, 0xce, 0x7e, 0x02, 0xd3, 0xbb, 0xa3, 0x6a, 0x24, 0x4e, 0x4e, 0xfd, 0xf3, 0xfe, 0x9e, 0xe7, + 0xbd, 0xf7, 0xee, 0xc0, 0xa1, 0x87, 0x49, 0x84, 0x89, 0xe5, 0xc2, 0xb8, 0x6b, 0xdd, 0x37, 0x5d, + 0x44, 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0x7d, 0x77, 0x08, 0xa3, 0x5e, 0xdb, 0xf8, + 0xa9, 0x30, 0x9c, 0x4d, 0xf6, 0x63, 0x99, 0x36, 0x46, 0x32, 0x28, 0x89, 0x29, 0x15, 0x15, 0x94, + 0xa0, 0xef, 0xf7, 0x11, 0xe1, 0x3b, 0xba, 0xee, 0x2c, 0x3f, 0x15, 0x08, 0xd6, 0xd2, 0x93, 0x5a, + 0x6e, 0xd6, 0xbf, 0x8e, 0xcb, 0xcd, 0xed, 0xf2, 0xe3, 0x58, 0x97, 0xde, 0xc7, 0xba, 0x64, 0x77, + 0x26, 0x73, 0x4d, 0x9e, 0xce, 0x35, 0xf9, 0x6d, 0xae, 0xc9, 0xa3, 0x85, 0x26, 0x4d, 0x17, 0x9a, + 0xf4, 0xb2, 0xd0, 0xa4, 0x9b, 0xa3, 0x3f, 0xa5, 0x0f, 0xfc, 0xea, 0x30, 0xb7, 0x5b, 0x64, 0x97, + 0xe6, 0xf4, 0x33, 0x00, 0x00, 0xff, 0xff, 0x15, 0x28, 0xf0, 0x44, 0xc4, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/bank/types/key.go b/x/bank/types/key.go index 44decc3e7160..5d7f52baa531 100644 --- a/x/bank/types/key.go +++ b/x/bank/types/key.go @@ -3,7 +3,6 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" - "github.com/cosmos/cosmos-sdk/types/kv" ) const ( @@ -22,48 +21,37 @@ const ( // KVStore keys var ( - SupplyKey = []byte{0x00} - DenomMetadataPrefix = []byte{0x1} - DenomAddressPrefix = []byte{0x03} - // BalancesPrefix is the prefix for the account balances store. We use a byte // (instead of `[]byte("balances")` to save some disk space). - BalancesPrefix = []byte{0x02} + BalancesPrefix = []byte{0x02} + SupplyKey = []byte{0x00} + DenomMetadataPrefix = []byte{0x1} ) -// AddressAndDenomFromBalancesStore returns an account address and denom from a balances prefix +// DenomMetadataKey returns the denomination metadata key. +func DenomMetadataKey(denom string) []byte { + d := []byte(denom) + return append(DenomMetadataPrefix, d...) +} + +// AddressFromBalancesStore returns an account address from a balances prefix // store. The key must not contain the prefix BalancesPrefix as the prefix store // iterator discards the actual prefix. // -// If invalid key is passed, AddressAndDenomFromBalancesStore returns ErrInvalidKey. -func AddressAndDenomFromBalancesStore(key []byte) (sdk.AccAddress, string, error) { +// If invalid key is passed, AddressFromBalancesStore returns ErrInvalidKey. +func AddressFromBalancesStore(key []byte) (sdk.AccAddress, error) { if len(key) == 0 { - return nil, "", ErrInvalidKey + return nil, ErrInvalidKey } - - kv.AssertKeyAtLeastLength(key, 1) - - addrBound := int(key[0]) - - if len(key)-1 < addrBound { - return nil, "", ErrInvalidKey + addrLen := key[0] + bound := int(addrLen) + if len(key)-1 < bound { + return nil, ErrInvalidKey } - - return key[1 : addrBound+1], string(key[addrBound+1:]), nil + return key[1 : bound+1], nil } // CreateAccountBalancesPrefix creates the prefix for an account's balances. func CreateAccountBalancesPrefix(addr []byte) []byte { return append(BalancesPrefix, address.MustLengthPrefix(addr)...) } - -// CreateDenomAddressPrefix creates a prefix for a reverse index of denomination -// to account balance for that denomination. -func CreateDenomAddressPrefix(denom string) []byte { - // we add a "zero" byte at the end - null byte terminator, to allow prefix denom prefix - // scan. Setting it is not needed (key[last] = 0) - because this is the default. - key := make([]byte, len(DenomAddressPrefix)+len(denom)+1) - copy(key, DenomAddressPrefix) - copy(key[len(DenomAddressPrefix):], denom) - return key -} diff --git a/x/bank/types/key_test.go b/x/bank/types/key_test.go index ba0dd5c63ee4..9a7f457e45bd 100644 --- a/x/bank/types/key_test.go +++ b/x/bank/types/key_test.go @@ -42,7 +42,7 @@ func TestAddressFromBalancesStore(t *testing.T) { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() - addr, denom, err := types.AddressAndDenomFromBalancesStore(tc.key) + addr, err := types.AddressFromBalancesStore(tc.key) if tc.wantErr { assert.Error(t, err) assert.True(t, errors.Is(types.ErrInvalidKey, err)) @@ -51,20 +51,7 @@ func TestAddressFromBalancesStore(t *testing.T) { } if len(tc.expectedKey) > 0 { assert.Equal(t, tc.expectedKey, addr) - assert.Equal(t, "stake", denom) } }) } } - -func TestCreateDenomAddressPrefix(t *testing.T) { - require := require.New(t) - - key := types.CreateDenomAddressPrefix("") - require.Len(key, len(types.DenomAddressPrefix)+1) - require.Equal(append(types.DenomAddressPrefix, 0), key) - - key = types.CreateDenomAddressPrefix("abc") - require.Len(key, len(types.DenomAddressPrefix)+4) - require.Equal(append(types.DenomAddressPrefix, 'a', 'b', 'c', 0), key) -} diff --git a/x/bank/types/msgs.go b/x/bank/types/msgs.go index 8030e04519f3..22fdc30b3886 100644 --- a/x/bank/types/msgs.go +++ b/x/bank/types/msgs.go @@ -27,12 +27,14 @@ func (msg MsgSend) Type() string { return TypeMsgSend } // ValidateBasic Implements Msg. func (msg MsgSend) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.FromAddress); err != nil { - return sdkerrors.ErrInvalidAddress.Wrapf("invalid from address: %s", err) + _, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) } - if _, err := sdk.AccAddressFromBech32(msg.ToAddress); err != nil { - return sdkerrors.ErrInvalidAddress.Wrapf("invalid to address: %s", err) + _, err = sdk.AccAddressFromBech32(msg.ToAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid recipient address (%s)", err) } if !msg.Amount.IsValid() { @@ -53,8 +55,11 @@ func (msg MsgSend) GetSignBytes() []byte { // GetSigners Implements Msg. func (msg MsgSend) GetSigners() []sdk.AccAddress { - fromAddress, _ := sdk.AccAddressFromBech32(msg.FromAddress) - return []sdk.AccAddress{fromAddress} + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} } var _ sdk.Msg = &MsgMultiSend{} @@ -94,8 +99,8 @@ func (msg MsgMultiSend) GetSignBytes() []byte { func (msg MsgMultiSend) GetSigners() []sdk.AccAddress { addrs := make([]sdk.AccAddress, len(msg.Inputs)) for i, in := range msg.Inputs { - inAddr, _ := sdk.AccAddressFromBech32(in.Address) - addrs[i] = inAddr + addr, _ := sdk.AccAddressFromBech32(in.Address) + addrs[i] = addr } return addrs @@ -103,8 +108,9 @@ func (msg MsgMultiSend) GetSigners() []sdk.AccAddress { // ValidateBasic - validate transaction input func (in Input) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(in.Address); err != nil { - return sdkerrors.ErrInvalidAddress.Wrapf("invalid input address: %s", err) + _, err := sdk.AccAddressFromBech32(in.Address) + if err != nil { + return err } if !in.Coins.IsValid() { @@ -129,8 +135,9 @@ func NewInput(addr sdk.AccAddress, coins sdk.Coins) Input { // ValidateBasic - validate transaction output func (out Output) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(out.Address); err != nil { - return sdkerrors.ErrInvalidAddress.Wrapf("invalid output address: %s", err) + _, err := sdk.AccAddressFromBech32(out.Address) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid output address (%s)", err) } if !out.Coins.IsValid() { diff --git a/x/bank/types/msgs_test.go b/x/bank/types/msgs_test.go index d11f78711591..334d72c13243 100644 --- a/x/bank/types/msgs_test.go +++ b/x/bank/types/msgs_test.go @@ -1,6 +1,7 @@ package types import ( + "fmt" "testing" "github.com/stretchr/testify/require" @@ -39,8 +40,8 @@ func TestMsgSendValidation(t *testing.T) { {"", NewMsgSend(addr1, addrLong, atom123)}, // valid send with long addr recipient {": invalid coins", NewMsgSend(addr1, addr2, atom0)}, // non positive coin {"123atom,0eth: invalid coins", NewMsgSend(addr1, addr2, atom123eth0)}, // non positive coin in multicoins - {"invalid from address: empty address string is not allowed: invalid address", NewMsgSend(addrEmpty, addr2, atom123)}, - {"invalid to address: empty address string is not allowed: invalid address", NewMsgSend(addr1, addrEmpty, atom123)}, + {"Invalid sender address (empty address string is not allowed): invalid address", NewMsgSend(addrEmpty, addr2, atom123)}, + {"Invalid recipient address (empty address string is not allowed): invalid address", NewMsgSend(addr1, addrEmpty, atom123)}, } for _, tc := range cases { @@ -64,6 +65,13 @@ func TestMsgSendGetSignBytes(t *testing.T) { require.Equal(t, expected, string(res)) } +func TestMsgSendGetSigners(t *testing.T) { + var msg = NewMsgSend(sdk.AccAddress([]byte("input111111111111111")), sdk.AccAddress{}, sdk.NewCoins()) + res := msg.GetSigners() + // TODO: fix this ! + require.Equal(t, fmt.Sprintf("%v", res), "[696E707574313131313131313131313131313131]") +} + func TestMsgMultiSendRoute(t *testing.T) { // Construct a MsgSend addr1 := sdk.AccAddress([]byte("input")) @@ -103,7 +111,7 @@ func TestInputValidation(t *testing.T) { {"", NewInput(addr2, multiCoins)}, {"", NewInput(addrLong, someCoins)}, - {"invalid input address: empty address string is not allowed: invalid address", NewInput(addrEmpty, someCoins)}, + {"empty address string is not allowed", NewInput(addrEmpty, someCoins)}, {": invalid coins", NewInput(addr1, emptyCoins)}, // invalid coins {": invalid coins", NewInput(addr1, emptyCoins2)}, // invalid coins {"10eth,0atom: invalid coins", NewInput(addr1, someEmptyCoins)}, // invalid coins @@ -144,7 +152,7 @@ func TestOutputValidation(t *testing.T) { {"", NewOutput(addr2, multiCoins)}, {"", NewOutput(addrLong, someCoins)}, - {"invalid output address: empty address string is not allowed: invalid address", NewOutput(addrEmpty, someCoins)}, + {"Invalid output address (empty address string is not allowed): invalid address", NewOutput(addrEmpty, someCoins)}, {": invalid coins", NewOutput(addr1, emptyCoins)}, // invalid coins {": invalid coins", NewOutput(addr1, emptyCoins2)}, // invalid coins {"10eth,0atom: invalid coins", NewOutput(addr1, someEmptyCoins)}, // invalid coins @@ -230,25 +238,32 @@ func TestMsgMultiSendGetSignBytes(t *testing.T) { } func TestMsgMultiSendGetSigners(t *testing.T) { - addrs := make([]string, 3) - inputs := make([]Input, 3) - for i, v := range []string{"input111111111111111", "input222222222222222", "input333333333333333"} { - addr := sdk.AccAddress([]byte(v)) - inputs[i] = NewInput(addr, nil) - addrs[i] = addr.String() + var msg = MsgMultiSend{ + Inputs: []Input{ + NewInput(sdk.AccAddress([]byte("input111111111111111")), nil), + NewInput(sdk.AccAddress([]byte("input222222222222222")), nil), + NewInput(sdk.AccAddress([]byte("input333333333333333")), nil), + }, } - var msg = NewMsgMultiSend(inputs, nil) res := msg.GetSigners() - for i, signer := range res { - require.Equal(t, signer.String(), addrs[i]) - } + // TODO: fix this ! + require.Equal(t, "[696E707574313131313131313131313131313131 696E707574323232323232323232323232323232 696E707574333333333333333333333333333333]", fmt.Sprintf("%v", res)) } -func TestMsgSendGetSigners(t *testing.T) { - from := sdk.AccAddress([]byte("input111111111111111")) - msg := NewMsgSend(from, sdk.AccAddress{}, sdk.NewCoins()) - res := msg.GetSigners() - require.Equal(t, 1, len(res)) - require.True(t, from.Equals(res[0])) +func TestMsgSendSigners(t *testing.T) { + signers := []sdk.AccAddress{ + {1, 2, 3}, + {4, 5, 6}, + {7, 8, 9}, + } + + someCoins := sdk.NewCoins(sdk.NewInt64Coin("atom", 123)) + inputs := make([]Input, len(signers)) + for i, signer := range signers { + inputs[i] = NewInput(signer, someCoins) + } + tx := NewMsgMultiSend(inputs, nil) + + require.Equal(t, signers, tx.GetSigners()) } diff --git a/x/bank/types/params.go b/x/bank/types/params.go index 414e8ddf5dd4..ed94ead34765 100644 --- a/x/bank/types/params.go +++ b/x/bank/types/params.go @@ -3,9 +3,8 @@ package types import ( "fmt" - "sigs.k8s.io/yaml" + yaml "gopkg.in/yaml.v2" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) @@ -122,16 +121,7 @@ func NewSendEnabled(denom string, sendEnabled bool) *SendEnabled { // String implements stringer insterface func (se SendEnabled) String() string { - bz, err := codec.ProtoMarshalJSON(&se, nil) - if err != nil { - panic(err) - } - - out, err := yaml.JSONToYAML(bz) - if err != nil { - panic(err) - } - + out, _ := yaml.Marshal(se) return string(out) } diff --git a/x/bank/types/params_test.go b/x/bank/types/params_test.go index d63c8b89c7ec..f6f95d73737e 100644 --- a/x/bank/types/params_test.go +++ b/x/bank/types/params_test.go @@ -91,12 +91,23 @@ func Test_validateParams(t *testing.T) { require.True(t, params.SendEnabledDenom(sdk.DefaultBondDenom)) require.False(t, params.SendEnabledDenom("foodenom2")) - paramYaml := "default_send_enabled: true\nsend_enabled:\n- denom: foodenom\n- denom: foodenom2\n" + paramYaml := `send_enabled: +- denom: foodenom + enabled: false +- denom: foodenom2 + enabled: false +default_send_enabled: true +` require.Equal(t, paramYaml, params.String()) // Ensure proper format of yaml output when false params.DefaultSendEnabled = false - paramYaml = "send_enabled:\n- denom: foodenom\n- denom: foodenom2\n" + paramYaml = `send_enabled: +- denom: foodenom + enabled: false +- denom: foodenom2 + enabled: false +` require.Equal(t, paramYaml, params.String()) params = NewParams(true, SendEnabledParams{ diff --git a/x/bank/types/query.pb.go b/x/bank/types/query.pb.go index 36018d4df0fd..5ad95812ba8c 100644 --- a/x/bank/types/query.pb.go +++ b/x/bank/types/query.pb.go @@ -6,7 +6,6 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" @@ -682,174 +681,6 @@ func (m *QueryDenomMetadataResponse) GetMetadata() Metadata { return Metadata{} } -// QueryDenomOwnersRequest defines the request type for the DenomOwners RPC query, -// which queries for a paginated set of all account holders of a particular -// denomination. -type QueryDenomOwnersRequest struct { - // denom defines the coin denomination to query all account holders for. - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` - // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryDenomOwnersRequest) Reset() { *m = QueryDenomOwnersRequest{} } -func (m *QueryDenomOwnersRequest) String() string { return proto.CompactTextString(m) } -func (*QueryDenomOwnersRequest) ProtoMessage() {} -func (*QueryDenomOwnersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{14} -} -func (m *QueryDenomOwnersRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryDenomOwnersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryDenomOwnersRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryDenomOwnersRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryDenomOwnersRequest.Merge(m, src) -} -func (m *QueryDenomOwnersRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryDenomOwnersRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryDenomOwnersRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryDenomOwnersRequest proto.InternalMessageInfo - -func (m *QueryDenomOwnersRequest) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - -func (m *QueryDenomOwnersRequest) GetPagination() *query.PageRequest { - if m != nil { - return m.Pagination - } - return nil -} - -// 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. -type DenomOwner struct { - // address defines the address that owns a particular denomination. - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - // balance is the balance of the denominated coin for an account. - Balance types.Coin `protobuf:"bytes,2,opt,name=balance,proto3" json:"balance"` -} - -func (m *DenomOwner) Reset() { *m = DenomOwner{} } -func (m *DenomOwner) String() string { return proto.CompactTextString(m) } -func (*DenomOwner) ProtoMessage() {} -func (*DenomOwner) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{15} -} -func (m *DenomOwner) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DenomOwner) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DenomOwner.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *DenomOwner) XXX_Merge(src proto.Message) { - xxx_messageInfo_DenomOwner.Merge(m, src) -} -func (m *DenomOwner) XXX_Size() int { - return m.Size() -} -func (m *DenomOwner) XXX_DiscardUnknown() { - xxx_messageInfo_DenomOwner.DiscardUnknown(m) -} - -var xxx_messageInfo_DenomOwner proto.InternalMessageInfo - -func (m *DenomOwner) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *DenomOwner) GetBalance() types.Coin { - if m != nil { - return m.Balance - } - return types.Coin{} -} - -// QueryDenomOwnersResponse defines the RPC response of a DenomOwners RPC query. -type QueryDenomOwnersResponse struct { - DenomOwners []*DenomOwner `protobuf:"bytes,1,rep,name=denom_owners,json=denomOwners,proto3" json:"denom_owners,omitempty"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryDenomOwnersResponse) Reset() { *m = QueryDenomOwnersResponse{} } -func (m *QueryDenomOwnersResponse) String() string { return proto.CompactTextString(m) } -func (*QueryDenomOwnersResponse) ProtoMessage() {} -func (*QueryDenomOwnersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{16} -} -func (m *QueryDenomOwnersResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryDenomOwnersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryDenomOwnersResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryDenomOwnersResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryDenomOwnersResponse.Merge(m, src) -} -func (m *QueryDenomOwnersResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryDenomOwnersResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryDenomOwnersResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryDenomOwnersResponse proto.InternalMessageInfo - -func (m *QueryDenomOwnersResponse) GetDenomOwners() []*DenomOwner { - if m != nil { - return m.DenomOwners - } - return nil -} - -func (m *QueryDenomOwnersResponse) GetPagination() *query.PageResponse { - if m != nil { - return m.Pagination - } - return nil -} - func init() { proto.RegisterType((*QueryBalanceRequest)(nil), "cosmos.bank.v1beta1.QueryBalanceRequest") proto.RegisterType((*QueryBalanceResponse)(nil), "cosmos.bank.v1beta1.QueryBalanceResponse") @@ -865,75 +696,64 @@ func init() { proto.RegisterType((*QueryDenomsMetadataResponse)(nil), "cosmos.bank.v1beta1.QueryDenomsMetadataResponse") proto.RegisterType((*QueryDenomMetadataRequest)(nil), "cosmos.bank.v1beta1.QueryDenomMetadataRequest") proto.RegisterType((*QueryDenomMetadataResponse)(nil), "cosmos.bank.v1beta1.QueryDenomMetadataResponse") - proto.RegisterType((*QueryDenomOwnersRequest)(nil), "cosmos.bank.v1beta1.QueryDenomOwnersRequest") - proto.RegisterType((*DenomOwner)(nil), "cosmos.bank.v1beta1.DenomOwner") - proto.RegisterType((*QueryDenomOwnersResponse)(nil), "cosmos.bank.v1beta1.QueryDenomOwnersResponse") } func init() { proto.RegisterFile("cosmos/bank/v1beta1/query.proto", fileDescriptor_9c6fc1939682df13) } var fileDescriptor_9c6fc1939682df13 = []byte{ - // 949 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xf6, 0x04, 0xea, 0x24, 0xcf, 0xc0, 0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 0x2b, 0x37, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0x11, 0x1b, 0xa0, - 0xde, 0xa0, 0x0d, 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, 0x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, 0x53, 0xc6, + 0xd4, 0x62, 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. @@ -960,12 +780,8 @@ type QueryClient interface { Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // DenomsMetadata queries the client metadata of a given coin denomination. DenomMetadata(ctx context.Context, in *QueryDenomMetadataRequest, opts ...grpc.CallOption) (*QueryDenomMetadataResponse, error) - // DenomsMetadata queries the client metadata for all registered coin - // denominations. + // DenomsMetadata queries the client metadata for all registered coin denominations. DenomsMetadata(ctx context.Context, in *QueryDenomsMetadataRequest, opts ...grpc.CallOption) (*QueryDenomsMetadataResponse, error) - // DenomOwners queries for all account addresses that own a particular token - // denomination. - DenomOwners(ctx context.Context, in *QueryDenomOwnersRequest, opts ...grpc.CallOption) (*QueryDenomOwnersResponse, error) } type queryClient struct { @@ -1039,15 +855,6 @@ func (c *queryClient) DenomsMetadata(ctx context.Context, in *QueryDenomsMetadat return out, nil } -func (c *queryClient) DenomOwners(ctx context.Context, in *QueryDenomOwnersRequest, opts ...grpc.CallOption) (*QueryDenomOwnersResponse, error) { - out := new(QueryDenomOwnersResponse) - err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Query/DenomOwners", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // QueryServer is the server API for Query service. type QueryServer interface { // Balance queries the balance of a single coin for a single account. @@ -1062,12 +869,8 @@ type QueryServer interface { Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // DenomsMetadata queries the client metadata of a given coin denomination. DenomMetadata(context.Context, *QueryDenomMetadataRequest) (*QueryDenomMetadataResponse, error) - // DenomsMetadata queries the client metadata for all registered coin - // denominations. + // DenomsMetadata queries the client metadata for all registered coin denominations. DenomsMetadata(context.Context, *QueryDenomsMetadataRequest) (*QueryDenomsMetadataResponse, error) - // DenomOwners queries for all account addresses that own a particular token - // denomination. - DenomOwners(context.Context, *QueryDenomOwnersRequest) (*QueryDenomOwnersResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1095,9 +898,6 @@ func (*UnimplementedQueryServer) DenomMetadata(ctx context.Context, req *QueryDe func (*UnimplementedQueryServer) DenomsMetadata(ctx context.Context, req *QueryDenomsMetadataRequest) (*QueryDenomsMetadataResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DenomsMetadata not implemented") } -func (*UnimplementedQueryServer) DenomOwners(ctx context.Context, req *QueryDenomOwnersRequest) (*QueryDenomOwnersResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DenomOwners not implemented") -} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1229,24 +1029,6 @@ func _Query_DenomsMetadata_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } -func _Query_DenomOwners_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryDenomOwnersRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).DenomOwners(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cosmos.bank.v1beta1.Query/DenomOwners", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).DenomOwners(ctx, req.(*QueryDenomOwnersRequest)) - } - return interceptor(ctx, in, info, handler) -} - var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.bank.v1beta1.Query", HandlerType: (*QueryServer)(nil), @@ -1279,10 +1061,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "DenomsMetadata", Handler: _Query_DenomsMetadata_Handler, }, - { - MethodName: "DenomOwners", - Handler: _Query_DenomOwners_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/bank/v1beta1/query.proto", @@ -1801,137 +1579,6 @@ func (m *QueryDenomMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *QueryDenomOwnersRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryDenomOwnersRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryDenomOwnersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = 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.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *DenomOwner) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DenomOwner) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DenomOwner) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Balance.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryDenomOwnersResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryDenomOwnersResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryDenomOwnersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = 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.DenomOwners) > 0 { - for iNdEx := len(m.DenomOwners) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.DenomOwners[iNdEx].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 -} - func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -2141,57 +1788,6 @@ func (m *QueryDenomMetadataResponse) Size() (n int) { return n } -func (m *QueryDenomOwnersRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *DenomOwner) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = m.Balance.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryDenomOwnersResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.DenomOwners) > 0 { - for _, e := range m.DenomOwners { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3511,359 +3107,6 @@ func (m *QueryDenomMetadataResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryDenomOwnersRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryDenomOwnersRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryDenomOwnersRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Denom = string(dAtA[iNdEx:postIndex]) - 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.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DenomOwner) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DenomOwner: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DenomOwner: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Balance", 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 err := m.Balance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryDenomOwnersResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryDenomOwnersResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryDenomOwnersResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DenomOwners", 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 - } - m.DenomOwners = append(m.DenomOwners, &DenomOwner{}) - if err := m.DenomOwners[len(m.DenomOwners)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - 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:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/bank/types/query.pb.gw.go b/x/bank/types/query.pb.gw.go index 60ebdb975662..8b8ed9a52607 100644 --- a/x/bank/types/query.pb.gw.go +++ b/x/bank/types/query.pb.gw.go @@ -377,78 +377,6 @@ func local_request_Query_DenomsMetadata_0(ctx context.Context, marshaler runtime } -var ( - filter_Query_DenomOwners_0 = &utilities.DoubleArray{Encoding: map[string]int{"denom": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - -func request_Query_DenomOwners_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryDenomOwnersRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["denom"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") - } - - protoReq.Denom, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_DenomOwners_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.DenomOwners(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_DenomOwners_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryDenomOwnersRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["denom"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") - } - - protoReq.Denom, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_DenomOwners_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.DenomOwners(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. @@ -595,26 +523,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_DenomOwners_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.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_DenomOwners_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_DenomOwners_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -796,26 +704,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_DenomOwners_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_DenomOwners_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_DenomOwners_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -833,8 +721,6 @@ var ( pattern_Query_DenomMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "bank", "v1beta1", "denoms_metadata", "denom"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_DenomsMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "bank", "v1beta1", "denoms_metadata"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_DenomOwners_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "bank", "v1beta1", "denom_owners", "denom"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -851,6 +737,4 @@ var ( forward_Query_DenomMetadata_0 = runtime.ForwardResponseMessage forward_Query_DenomsMetadata_0 = runtime.ForwardResponseMessage - - forward_Query_DenomOwners_0 = runtime.ForwardResponseMessage ) diff --git a/x/bank/types/send_authorization_test.go b/x/bank/types/send_authorization_test.go index 5e058317f1e9..11d2ae05dfd6 100644 --- a/x/bank/types/send_authorization_test.go +++ b/x/bank/types/send_authorization_test.go @@ -19,7 +19,7 @@ var ( ) func TestSendAuthorization(t *testing.T) { - app := simapp.Setup(t, false) + app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) authorization := types.NewSendAuthorization(coins1000) diff --git a/x/bank/types/tx.pb.go b/x/bank/types/tx.pb.go index 50e8fb2b9f85..6dd52c4b64d8 100644 --- a/x/bank/types/tx.pb.go +++ b/x/bank/types/tx.pb.go @@ -6,7 +6,6 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" @@ -33,8 +32,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgSend represents a message to send coins from one account to another. type MsgSend struct { - FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty"` - ToAddress string `protobuf:"bytes,2,opt,name=to_address,json=toAddress,proto3" json:"to_address,omitempty"` + FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty" yaml:"from_address"` + ToAddress string `protobuf:"bytes,2,opt,name=to_address,json=toAddress,proto3" json:"to_address,omitempty" yaml:"to_address"` Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` } @@ -208,35 +207,35 @@ func init() { func init() { proto.RegisterFile("cosmos/bank/v1beta1/tx.proto", fileDescriptor_1d8cb1613481f5b7) } var fileDescriptor_1d8cb1613481f5b7 = []byte{ - // 439 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcb, 0xae, 0xd2, 0x40, - 0x1c, 0xc6, 0x3b, 0x07, 0xc2, 0x91, 0x39, 0x27, 0x31, 0x56, 0x62, 0x38, 0xf5, 0xa4, 0x45, 0xe2, - 0x02, 0x16, 0x4c, 0x05, 0x17, 0x1a, 0x58, 0x59, 0x56, 0x9a, 0x34, 0x26, 0x65, 0xa5, 0x1b, 0xd2, - 0xcb, 0x58, 0x1b, 0xec, 0x4c, 0xd3, 0x99, 0x1a, 0x7c, 0x03, 0x13, 0x37, 0x3e, 0x02, 0x6b, 0xe3, - 0xd2, 0x87, 0x60, 0x49, 0x5c, 0xb9, 0x52, 0x03, 0x1b, 0x57, 0x3e, 0x83, 0xe9, 0x74, 0x5a, 0x49, - 0x44, 0x58, 0xf5, 0xf2, 0x7d, 0xbf, 0x6f, 0xfe, 0x97, 0x81, 0xd7, 0x3e, 0x65, 0x31, 0x65, 0xa6, - 0xe7, 0x92, 0x85, 0xf9, 0x76, 0xe8, 0x61, 0xee, 0x0e, 0x4d, 0xbe, 0x44, 0x49, 0x4a, 0x39, 0x55, - 0x6f, 0x17, 0x2a, 0xca, 0x55, 0x24, 0x55, 0xad, 0x15, 0xd2, 0x90, 0x0a, 0xdd, 0xcc, 0xdf, 0x0a, - 0xab, 0xa6, 0x57, 0x41, 0x0c, 0x57, 0x41, 0x3e, 0x8d, 0xc8, 0x3f, 0xfa, 0xde, 0x41, 0x22, 0xb7, - 0xd0, 0xaf, 0x0a, 0x7d, 0x5e, 0x04, 0xcb, 0x73, 0xc5, 0x47, 0xf7, 0x37, 0x80, 0xe7, 0x36, 0x0b, - 0x67, 0x98, 0x04, 0xea, 0x04, 0x5e, 0xbe, 0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39, 0xfa, - 0x0c, 0x60, 0xcd, 0x66, 0xa1, 0xfa, 0x0c, 0xd6, 0x45, 0x91, 0xd7, 0x07, 0x93, 0x65, 0x6f, 0xda, - 0xfd, 0x63, 0x6a, 0x99, 0xa9, 0xbe, 0x80, 0xcd, 0xbf, 0x5d, 0xdf, 0xfb, 0x1f, 0x52, 0x59, 0xb4, - 0xfe, 0x49, 0x4b, 0x19, 0x6d, 0x4d, 0xd7, 0x5b, 0x1d, 0x6c, 0xb6, 0x3a, 0xf8, 0xb9, 0xd5, 0xc1, - 0xc7, 0x9d, 0xae, 0x6c, 0x76, 0xba, 0xf2, 0x6d, 0xa7, 0x2b, 0x2f, 0xfb, 0x47, 0xb7, 0xb7, 0x2c, - 0x6e, 0xb1, 0x58, 0xa2, 0xd7, 0x10, 0x97, 0xf4, 0xe1, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe8, - 0x6d, 0x23, 0xe3, 0x4a, 0x03, 0x00, 0x00, + // 436 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x3f, 0xef, 0xd2, 0x40, + 0x1c, 0xc6, 0x7b, 0x3f, 0x08, 0x3f, 0x39, 0x48, 0x0c, 0x05, 0x15, 0x2b, 0x69, 0xb1, 0x71, 0x80, + 0xc1, 0xab, 0xa0, 0x83, 0xa9, 0x93, 0x65, 0xd2, 0xa4, 0x31, 0xa9, 0x93, 0x2e, 0xa6, 0x7f, 0xce, + 0xda, 0x40, 0x7b, 0x0d, 0x77, 0x35, 0xf0, 0x0e, 0x4c, 0x5c, 0x7c, 0x09, 0xcc, 0xc6, 0x17, 0xc2, + 0xc8, 0xe8, 0x84, 0x06, 0x16, 0xe3, 0xc8, 0x2b, 0x30, 0xbd, 0xfe, 0x81, 0x44, 0xc4, 0xa9, 0xbd, + 0x3c, 0xdf, 0xcf, 0xd3, 0xe7, 0xe9, 0xf7, 0x60, 0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xd7, + 0x4a, 0x11, 0xd4, 0x16, 0xbc, 0x99, 0x77, 0xb5, 0x30, 0x8d, 0x49, 0x44, 0xb1, 0xfa, 0x19, 0xc0, + 0xa6, 0x49, 0x7d, 0x33, 0x99, 0xb1, 0x80, 0xff, 0x84, 0xa7, 0xb0, 0x16, 0x44, 0x71, 0xc2, 0xd2, + 0xfa, 0x69, 0x24, 0x09, 0x9d, 0x59, 0x06, 0x7a, 0x91, 0x8e, 0x18, 0xd5, 0x34, 0x93, 0x95, 0xcf, + 0x8b, 0xcf, 0xe0, 0x35, 0x49, 0x18, 0x47, 0xaf, 0x38, 0x7a, 0xef, 0x2c, 0xfa, 0x8a, 0xcf, 0xe4, + 0x6c, 0x41, 0xe8, 0x55, 0x1e, 0xf0, 0x36, 0xec, 0x9c, 0x86, 0x29, 0x52, 0x8e, 0xbf, 0x01, 0x58, + 0x31, 0xa9, 0x2f, 0xbe, 0x84, 0x55, 0x1e, 0xb2, 0x77, 0xd6, 0x39, 0xef, 0x26, 0x3d, 0xb8, 0xa4, + 0x16, 0x9e, 0xe2, 0x1b, 0x58, 0x3f, 0xb6, 0xbe, 0xff, 0x2f, 0xa4, 0x1c, 0x91, 0x86, 0xff, 0x1d, + 0x29, 0xac, 0x8d, 0xc9, 0x7a, 0x27, 0x83, 0xcd, 0x4e, 0x06, 0x3f, 0x77, 0x32, 0xf8, 0xb2, 0x97, + 0x85, 0xcd, 0x5e, 0x16, 0xbe, 0xef, 0x65, 0xe1, 0xed, 0xf0, 0xe2, 0xf6, 0x16, 0xd9, 0x35, 0xe5, + 0x4b, 0x74, 0x6a, 0xfc, 0x82, 0x3e, 0xfe, 0x13, 0x00, 0x00, 0xff, 0xff, 0x78, 0xdc, 0x7c, 0x0b, + 0x2b, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used.