From 04da382a9f29496fb7626faa420ad6732a11dea8 Mon Sep 17 00:00:00 2001 From: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Date: Mon, 23 Sep 2024 23:32:30 +0700 Subject: [PATCH] feat(bank/v2): Add MsgSend handler (#21736) --- runtime/v2/manager.go | 32 +- simapp/v2/simdv2/cmd/testnet.go | 21 + tests/systemtests/bankv2_test.go | 59 ++ x/bank/proto/cosmos/bank/v2/genesis.proto | 32 + x/bank/proto/cosmos/bank/v2/query.proto | 20 + x/bank/proto/cosmos/bank/v2/tx.proto | 41 +- x/bank/v2/client/cli/query.go | 79 ++ x/bank/v2/client/cli/tx.go | 65 ++ x/bank/v2/keeper/genesis.go | 31 + x/bank/v2/keeper/handlers.go | 112 +++ x/bank/v2/module.go | 60 ++ x/bank/v2/types/codec.go | 1 + x/bank/v2/types/genesis.pb.go | 383 ++++++++- x/bank/v2/types/msgs.go | 14 + x/bank/v2/types/query.go | 6 + x/bank/v2/types/query.pb.go | 431 +++++++++- x/bank/v2/types/tx.pb.go | 945 ++++++++++++++++++++-- 17 files changed, 2239 insertions(+), 93 deletions(-) create mode 100644 tests/systemtests/bankv2_test.go create mode 100644 x/bank/v2/client/cli/query.go create mode 100644 x/bank/v2/client/cli/tx.go create mode 100644 x/bank/v2/types/msgs.go create mode 100644 x/bank/v2/types/query.go diff --git a/runtime/v2/manager.go b/runtime/v2/manager.go index 1ce4aeba4663..6afce003657a 100644 --- a/runtime/v2/manager.go +++ b/runtime/v2/manager.go @@ -459,10 +459,8 @@ func (m *MM[T]) RunMigrations(ctx context.Context, fromVM appmodulev2.VersionMap func (m *MM[T]) RegisterServices(app *App[T]) error { for _, module := range m.modules { // register msg + query - if services, ok := module.(hasServicesV1); ok { - if err := registerServices(services, app, protoregistry.GlobalFiles); err != nil { - return err - } + if err := registerServices(module, app, protoregistry.GlobalFiles); err != nil { + return err } // register migrations @@ -594,7 +592,7 @@ func (m *MM[T]) assertNoForgottenModules( return nil } -func registerServices[T transaction.Tx](s hasServicesV1, app *App[T], registry *protoregistry.Files) error { +func registerServices[T transaction.Tx](s appmodulev2.AppModule, app *App[T], registry *protoregistry.Files) error { c := &configurator{ grpcQueryDecoders: map[string]func() gogoproto.Message{}, stfQueryRouter: app.queryRouterBuilder, @@ -603,8 +601,28 @@ func registerServices[T transaction.Tx](s hasServicesV1, app *App[T], registry * err: nil, } - if err := s.RegisterServices(c); err != nil { - return fmt.Errorf("unable to register services: %w", err) + if services, ok := s.(hasServicesV1); ok { + if err := services.RegisterServices(c); err != nil { + return fmt.Errorf("unable to register services: %w", err) + } + } else { + // If module not implement RegisterServices, register msg & query handler. + if module, ok := s.(appmodulev2.HasMsgHandlers); ok { + module.RegisterMsgHandlers(app.msgRouterBuilder) + } + + if module, ok := s.(appmodulev2.HasQueryHandlers); ok { + module.RegisterQueryHandlers(app.queryRouterBuilder) + // TODO: query regist by RegisterQueryHandlers not in grpcQueryDecoders + if module, ok := s.(interface { + GetQueryDecoders() map[string]func() gogoproto.Message + }); ok { + decoderMap := module.GetQueryDecoders() + for path, decoder := range decoderMap { + app.GRPCMethodsToMessageMap[path] = decoder + } + } + } } if c.err != nil { diff --git a/simapp/v2/simdv2/cmd/testnet.go b/simapp/v2/simdv2/cmd/testnet.go index 99dfb9459a13..8b15f9ccd7ad 100644 --- a/simapp/v2/simdv2/cmd/testnet.go +++ b/simapp/v2/simdv2/cmd/testnet.go @@ -24,6 +24,7 @@ import ( "cosmossdk.io/server/v2/cometbft" "cosmossdk.io/server/v2/store" banktypes "cosmossdk.io/x/bank/types" + bankv2types "cosmossdk.io/x/bank/v2/types" stakingtypes "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/client" @@ -402,6 +403,13 @@ func initGenFiles[T transaction.Tx]( } appGenState[banktypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(&bankGenState) + var bankV2GenState bankv2types.GenesisState + clientCtx.Codec.MustUnmarshalJSON(appGenState[bankv2types.ModuleName], &bankV2GenState) + if len(bankV2GenState.Balances) == 0 { + bankV2GenState = getBankV2GenesisFromV1(bankGenState) + } + appGenState[bankv2types.ModuleName] = clientCtx.Codec.MustMarshalJSON(&bankV2GenState) + appGenStateJSON, err := json.MarshalIndent(appGenState, "", " ") if err != nil { return err @@ -504,3 +512,16 @@ func writeFile(name, dir string, contents []byte) error { return os.WriteFile(file, contents, 0o600) } + +// getBankV2GenesisFromV1 clones bank/v1 state to bank/v2 +// since we not migrate yet +// TODO: Remove +func getBankV2GenesisFromV1(v1GenesisState banktypes.GenesisState) bankv2types.GenesisState { + var v2GenesisState bankv2types.GenesisState + for _, balance := range v1GenesisState.Balances { + v2Balance := bankv2types.Balance(balance) + v2GenesisState.Balances = append(v2GenesisState.Balances, v2Balance) + v2GenesisState.Supply = v2GenesisState.Supply.Add(balance.Coins...) + } + return v2GenesisState +} diff --git a/tests/systemtests/bankv2_test.go b/tests/systemtests/bankv2_test.go new file mode 100644 index 000000000000..275b50161f51 --- /dev/null +++ b/tests/systemtests/bankv2_test.go @@ -0,0 +1,59 @@ +//go:build system_test + +package systemtests + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" + "github.com/tidwall/gjson" +) + +func TestBankV2SendTxCmd(t *testing.T) { + // Currently only run with app v2 + if !isV2() { + t.Skip() + } + // scenario: test bank send command + // given a running chain + + sut.ResetChain(t) + cli := NewCLIWrapper(t, sut, verbose) + + // get validator address + valAddr := gjson.Get(cli.Keys("keys", "list"), "1.address").String() + require.NotEmpty(t, valAddr) + + // add new key + receiverAddr := cli.AddKey("account1") + denom := "stake" + sut.StartChain(t) + + // query validator balance and make sure it has enough balance + var transferAmount int64 = 1000 + raw := cli.CustomQuery("q", "bankv2", "balance", valAddr, denom) + valBalance := gjson.Get(raw, "balance.amount").Int() + + require.Greater(t, valBalance, transferAmount, "not enough balance found with validator") + + bankSendCmdArgs := []string{"tx", "bankv2", "send", valAddr, receiverAddr, fmt.Sprintf("%d%s", transferAmount, denom)} + + // test valid transaction + rsp := cli.Run(append(bankSendCmdArgs, "--fees=1stake")...) + txResult, found := cli.AwaitTxCommitted(rsp) + require.True(t, found) + RequireTxSuccess(t, txResult) + + // Check balance after send + valRaw := cli.CustomQuery("q", "bankv2", "balance", valAddr, denom) + valBalanceAfer := gjson.Get(valRaw, "balance.amount").Int() + + // TODO: Make DeductFee ante handler work with bank/v2 + require.Equal(t, valBalanceAfer, valBalance - transferAmount) + + receiverRaw := cli.CustomQuery("q", "bankv2", "balance", receiverAddr, denom) + receiverBalance := gjson.Get(receiverRaw, "balance.amount").Int() + require.Equal(t, receiverBalance, transferAmount) + +} diff --git a/x/bank/proto/cosmos/bank/v2/genesis.proto b/x/bank/proto/cosmos/bank/v2/genesis.proto index b73b1d1b4ce8..410baba84b19 100644 --- a/x/bank/proto/cosmos/bank/v2/genesis.proto +++ b/x/bank/proto/cosmos/bank/v2/genesis.proto @@ -4,6 +4,8 @@ package cosmos.bank.v2; import "gogoproto/gogo.proto"; import "cosmos/bank/v2/bank.proto"; import "amino/amino.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos_proto/cosmos.proto"; option go_package = "cosmossdk.io/x/bank/v2/types"; @@ -11,4 +13,34 @@ option go_package = "cosmossdk.io/x/bank/v2/types"; message GenesisState { // params defines all the parameters of the module. Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + + // balances is an array containing the balances of all the accounts. + repeated Balance balances = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + + // supply represents the total supply. If it is left empty, then supply will be calculated based on the provided + // balances. Otherwise, it will be used to validate that the sum of the balances equals this amount. + repeated cosmos.base.v1beta1.Coin supply = 3 [ + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; +} + +// Balance defines an account address and balance pair used in the bank module's +// genesis state. +message Balance { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // address is the address of the balance holder. + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // coins defines the different coins this balance holds. + repeated cosmos.base.v1beta1.Coin coins = 2 [ + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; } \ No newline at end of file diff --git a/x/bank/proto/cosmos/bank/v2/query.proto b/x/bank/proto/cosmos/bank/v2/query.proto index 4ec5a445635e..4b47915b0baf 100644 --- a/x/bank/proto/cosmos/bank/v2/query.proto +++ b/x/bank/proto/cosmos/bank/v2/query.proto @@ -4,6 +4,8 @@ package cosmos.bank.v2; import "gogoproto/gogo.proto"; import "amino/amino.proto"; import "cosmos/bank/v2/bank.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos_proto/cosmos.proto"; option go_package = "cosmossdk.io/x/bank/v2/types"; @@ -14,4 +16,22 @@ message QueryParamsRequest {} message QueryParamsResponse { // params provides the parameters of the bank module. Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} + +// QueryBalanceRequest is the request type for the Query/Balance RPC method. +message QueryBalanceRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // address is the address to query balances for. + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // denom is the coin denom to query balances for. + string denom = 2; +} + +// QueryBalanceResponse is the response type for the Query/Balance RPC method. +message QueryBalanceResponse { + // balance is the balance of the coin. + cosmos.base.v1beta1.Coin balance = 1; } \ No newline at end of file diff --git a/x/bank/proto/cosmos/bank/v2/tx.proto b/x/bank/proto/cosmos/bank/v2/tx.proto index a868e9fcab94..55eab2a9ffd5 100644 --- a/x/bank/proto/cosmos/bank/v2/tx.proto +++ b/x/bank/proto/cosmos/bank/v2/tx.proto @@ -6,6 +6,7 @@ import "cosmos/bank/v2/bank.proto"; import "cosmos_proto/cosmos.proto"; import "cosmos/msg/v1/msg.proto"; import "amino/amino.proto"; +import "cosmos/base/v1beta1/coin.proto"; option go_package = "cosmossdk.io/x/bank/v2/types"; @@ -23,4 +24,42 @@ message MsgUpdateParams { } // MsgUpdateParamsResponse defines the response structure for executing a MsgUpdateParams message. -message MsgUpdateParamsResponse {} \ No newline at end of file +message MsgUpdateParamsResponse {} + +// MsgSend represents a message to send coins from one account to another. +message MsgSend { + option (cosmos.msg.v1.signer) = "from_address"; + option (amino.name) = "cosmos-sdk/x/bank/v2/MsgSend"; + + string from_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string to_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + repeated cosmos.base.v1beta1.Coin amount = 3 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +// MsgSendResponse defines the response structure for executing a MsgSend message. +message MsgSendResponse {} + +// MsgMint is the Msg/Mint request type. +message MsgMint { + option (cosmos.msg.v1.signer) = "authority"; + option (amino.name) = "cosmos-sdk/x/bank/v2/MsgMint"; + + // authority is the address that controls the module (defaults to x/gov unless overwritten). + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + string to_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + repeated cosmos.base.v1beta1.Coin amount = 3 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +// MsgMint defines the response structure for executing a MsgMint message. +message MsgMintResponse {} diff --git a/x/bank/v2/client/cli/query.go b/x/bank/v2/client/cli/query.go new file mode 100644 index 000000000000..2bc0af45f35e --- /dev/null +++ b/x/bank/v2/client/cli/query.go @@ -0,0 +1,79 @@ +package cli + +import ( + "errors" + + gogoproto "github.com/cosmos/gogoproto/proto" + "github.com/spf13/cobra" + + "cosmossdk.io/x/bank/v2/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + FlagDenom = "denom" +) + +// GetQueryCmd returns the parent command for all x/bank CLi query commands. The +// provided clientCtx should have, at a minimum, a verifier, Tendermint RPC client, +// and marshaler set. +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the bank module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + GetBalanceCmd(), + ) + + return cmd +} + +func GetBalanceCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "balance [address] [denom]", + Short: "Query an account balance by address and denom", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + denom := args[1] + if denom == "" { + return errors.New("empty denom") + } + + addr, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err + } + + ctx := cmd.Context() + + req := types.NewQueryBalanceRequest(addr.String(), denom) + out := new(types.QueryBalanceResponse) + + err = clientCtx.Invoke(ctx, gogoproto.MessageName(&types.QueryBalanceRequest{}), req, out) + if err != nil { + return err + } + + return clientCtx.PrintProto(out) + }, + } + + cmd.Flags().String(FlagDenom, "", "The specific balance denomination to query for") + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "all balances") + + return cmd +} diff --git a/x/bank/v2/client/cli/tx.go b/x/bank/v2/client/cli/tx.go new file mode 100644 index 000000000000..b131c7b62b01 --- /dev/null +++ b/x/bank/v2/client/cli/tx.go @@ -0,0 +1,65 @@ +package cli + +import ( + "github.com/spf13/cobra" + + "cosmossdk.io/x/bank/v2/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// TODO: Use AutoCLI commands +// https://github.com/cosmos/cosmos-sdk/issues/21682 +func NewTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Bank v2 transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand( + NewSendTxCmd(), + ) + + return txCmd +} + +// NewSendTxCmd returns a CLI command handler for creating a MsgSend transaction. +func NewSendTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "send [from_key_or_address] [to_address] [amount]", + Short: "Send funds from one account to another.", + Long: `Send funds from one account to another. +Note, the '--from' flag is ignored as it is implied from [from_key_or_address]. +When using '--dry-run' a key name cannot be used, only a bech32 address. +`, + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + if err := cmd.Flags().Set(flags.FlagFrom, args[0]); err != nil { + return err + } + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + coins, err := sdk.ParseCoinsNormalized(args[2]) + if err != nil { + return err + } + + msg := types.NewMsgSend(clientCtx.GetFromAddress().String(), args[1], coins) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/bank/v2/keeper/genesis.go b/x/bank/v2/keeper/genesis.go index 05f2abbe5f3b..ac03c9c1331e 100644 --- a/x/bank/v2/keeper/genesis.go +++ b/x/bank/v2/keeper/genesis.go @@ -4,7 +4,10 @@ import ( "context" "fmt" + "cosmossdk.io/collections" "cosmossdk.io/x/bank/v2/types" + + sdk "github.com/cosmos/cosmos-sdk/types" ) // InitGenesis initializes the bank/v2 module genesis state. @@ -13,6 +16,34 @@ func (k *Keeper) InitGenesis(ctx context.Context, state *types.GenesisState) err return fmt.Errorf("failed to set params: %w", err) } + totalSupplyMap := sdk.NewMapCoins(sdk.Coins{}) + + for _, balance := range state.Balances { + addr := balance.Address + bz, err := k.addressCodec.StringToBytes(addr) + if err != nil { + return err + } + + for _, coin := range balance.Coins { + err := k.balances.Set(ctx, collections.Join(bz, coin.Denom), coin.Amount) + if err != nil { + return err + } + } + + totalSupplyMap.Add(balance.Coins...) + } + totalSupply := totalSupplyMap.ToCoins() + + if !state.Supply.Empty() && !state.Supply.Equal(totalSupply) { + return fmt.Errorf("genesis supply is incorrect, expected %v, got %v", state.Supply, totalSupply) + } + + for _, supply := range totalSupply { + k.setSupply(ctx, supply) + } + return nil } diff --git a/x/bank/v2/keeper/handlers.go b/x/bank/v2/keeper/handlers.go index c26b7e4f9cb6..561b15306ed2 100644 --- a/x/bank/v2/keeper/handlers.go +++ b/x/bank/v2/keeper/handlers.go @@ -6,7 +6,16 @@ import ( "errors" "fmt" + "github.com/hashicorp/go-metrics" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + errorsmod "cosmossdk.io/errors" "cosmossdk.io/x/bank/v2/types" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) type handlers struct { @@ -45,6 +54,89 @@ func (h handlers) MsgUpdateParams(ctx context.Context, msg *types.MsgUpdateParam return &types.MsgUpdateParamsResponse{}, nil } +func (h handlers) MsgSend(ctx context.Context, msg *types.MsgSend) (*types.MsgSendResponse, error) { + var ( + from, to []byte + err error + ) + + from, err = h.addressCodec.StringToBytes(msg.FromAddress) + if err != nil { + return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid from address: %s", err) + } + + to, err = h.addressCodec.StringToBytes(msg.ToAddress) + if err != nil { + return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid to address: %s", err) + } + + if !msg.Amount.IsValid() { + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidCoins, msg.Amount.String()) + } + + if !msg.Amount.IsAllPositive() { + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidCoins, msg.Amount.String()) + } + + // TODO: Check denom enable + + err = h.SendCoins(ctx, from, to, msg.Amount) + if err != nil { + return nil, err + } + + defer func() { + for _, a := range msg.Amount { + if a.Amount.IsInt64() { + telemetry.SetGaugeWithLabels( + []string{"tx", "msg", "send"}, + float32(a.Amount.Int64()), + []metrics.Label{telemetry.NewLabel("denom", a.Denom)}, + ) + } + } + }() + + return &types.MsgSendResponse{}, nil +} + +func (h handlers) MsgMint(ctx context.Context, msg *types.MsgMint) (*types.MsgMintResponse, error) { + authorityBytes, err := h.addressCodec.StringToBytes(msg.Authority) + if err != nil { + return nil, err + } + + if !bytes.Equal(h.authority, authorityBytes) { + expectedAuthority, err := h.addressCodec.BytesToString(h.authority) + if err != nil { + return nil, err + } + + return nil, fmt.Errorf("invalid authority; expected %s, got %s", expectedAuthority, msg.Authority) + } + + to, err := h.addressCodec.StringToBytes(msg.ToAddress) + if err != nil { + return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid to address: %s", err) + } + + if !msg.Amount.IsValid() { + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidCoins, msg.Amount.String()) + } + + if !msg.Amount.IsAllPositive() { + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidCoins, msg.Amount.String()) + } + + // TODO: should mint to mint module then transfer? + err = h.MintCoins(ctx, to, msg.Amount) + if err != nil { + return nil, err + } + + return &types.MsgMintResponse{}, nil +} + // QueryParams queries the parameters of the bank/v2 module. func (h handlers) QueryParams(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { if req == nil { @@ -58,3 +150,23 @@ func (h handlers) QueryParams(ctx context.Context, req *types.QueryParamsRequest return &types.QueryParamsResponse{Params: params}, nil } + +// QueryBalance queries the parameters of the bank/v2 module. +func (h handlers) QueryBalance(ctx context.Context, req *types.QueryBalanceRequest) (*types.QueryBalanceResponse, error) { + if req == nil { + return nil, errors.New("empty request") + } + + if err := sdk.ValidateDenom(req.Denom); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + addr, err := h.addressCodec.StringToBytes(req.Address) + if err != nil { + return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid address: %s", err) + } + + balance := h.Keeper.GetBalance(ctx, addr, req.Denom) + + return &types.QueryBalanceResponse{Balance: &balance}, nil +} diff --git a/x/bank/v2/module.go b/x/bank/v2/module.go index 55cd87d9b4e6..822ef438f433 100644 --- a/x/bank/v2/module.go +++ b/x/bank/v2/module.go @@ -5,11 +5,14 @@ import ( "encoding/json" "errors" "fmt" + "reflect" gogoproto "github.com/cosmos/gogoproto/proto" + "github.com/spf13/cobra" appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/core/registry" + "cosmossdk.io/x/bank/v2/client/cli" "cosmossdk.io/x/bank/v2/keeper" "cosmossdk.io/x/bank/v2/types" @@ -102,6 +105,18 @@ func (am AppModule) RegisterMsgHandlers(router appmodulev2.MsgRouter) { errs = errors.Join(errs, err) } + if err := appmodulev2.RegisterHandler( + router, gogoproto.MessageName(&types.MsgSend{}), handlers.MsgSend, + ); err != nil { + errs = errors.Join(errs, err) + } + + if err := appmodulev2.RegisterHandler( + router, gogoproto.MessageName(&types.MsgMint{}), handlers.MsgMint, + ); err != nil { + errs = errors.Join(errs, err) + } + if errs != nil { panic(errs) } @@ -118,7 +133,52 @@ func (am AppModule) RegisterQueryHandlers(router appmodulev2.QueryRouter) { errs = errors.Join(errs, err) } + if err := appmodulev2.RegisterHandler( + router, gogoproto.MessageName(&types.QueryBalanceRequest{}), handlers.QueryBalance, + ); err != nil { + errs = errors.Join(errs, err) + } + + if errs != nil { + panic(errs) + } +} + +// GetQueryDecoders returns grpc request and the corresponding decoder. +func (am AppModule) GetQueryDecoders() map[string]func() gogoproto.Message { + decodeMaps := make(map[string]func() gogoproto.Message) + var errs error + + typ := gogoproto.MessageType(gogoproto.MessageName(&types.QueryParamsRequest{})) + if typ == nil { + errs = errors.Join(errs, fmt.Errorf("unable to find message in gogotype registry")) + } + decodeMaps[gogoproto.MessageName(&types.QueryParamsRequest{})] = func() gogoproto.Message { + return reflect.New(typ.Elem()).Interface().(gogoproto.Message) + } + + typ = gogoproto.MessageType(gogoproto.MessageName(&types.QueryBalanceRequest{})) + if typ == nil { + errs = errors.Join(errs, fmt.Errorf("unable to find message in gogotype registry")) + } + decodeMaps[gogoproto.MessageName(&types.QueryBalanceRequest{})] = func() gogoproto.Message { + return reflect.New(typ.Elem()).Interface().(gogoproto.Message) + } + if errs != nil { panic(errs) } + return decodeMaps +} + +// GetTxCmd returns the root tx command for the bank/v2 module. +// TODO: Remove & use autocli +func (AppModule) GetTxCmd() *cobra.Command { + return cli.NewTxCmd() +} + +// GetTxCmd returns the root query command for the bank/v2 module. +// TODO: Remove & use autocli +func (AppModule) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() } diff --git a/x/bank/v2/types/codec.go b/x/bank/v2/types/codec.go index 75104bbfd0cb..78bca6f3b34b 100644 --- a/x/bank/v2/types/codec.go +++ b/x/bank/v2/types/codec.go @@ -8,5 +8,6 @@ import ( func RegisterInterfaces(registrar registry.InterfaceRegistrar) { registrar.RegisterImplementations((*transaction.Msg)(nil), &MsgUpdateParams{}, + &MsgSend{}, ) } diff --git a/x/bank/v2/types/genesis.pb.go b/x/bank/v2/types/genesis.pb.go index 43432b9f83c2..d2c5e38249e4 100644 --- a/x/bank/v2/types/genesis.pb.go +++ b/x/bank/v2/types/genesis.pb.go @@ -5,6 +5,9 @@ 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/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -28,6 +31,11 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { // params defines all the parameters of the module. Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // balances is an array containing the balances of all the accounts. + Balances []Balance `protobuf:"bytes,2,rep,name=balances,proto3" json:"balances"` + // supply represents the total supply. If it is left empty, then supply will be calculated based on the provided + // 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"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -70,27 +78,97 @@ func (m *GenesisState) GetParams() Params { return Params{} } +func (m *GenesisState) GetBalances() []Balance { + if m != nil { + return m.Balances + } + return nil +} + +func (m *GenesisState) GetSupply() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Supply + } + return nil +} + +// Balance defines an account address and balance pair used in the bank module's +// genesis state. +type Balance struct { + // address is the address of the balance holder. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // coins defines the different coins this balance holds. + Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins"` +} + +func (m *Balance) Reset() { *m = Balance{} } +func (m *Balance) String() string { return proto.CompactTextString(m) } +func (*Balance) ProtoMessage() {} +func (*Balance) Descriptor() ([]byte, []int) { + return fileDescriptor_bc2b1daa12dfd4fc, []int{1} +} +func (m *Balance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Balance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Balance.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 *Balance) XXX_Merge(src proto.Message) { + xxx_messageInfo_Balance.Merge(m, src) +} +func (m *Balance) XXX_Size() int { + return m.Size() +} +func (m *Balance) XXX_DiscardUnknown() { + xxx_messageInfo_Balance.DiscardUnknown(m) +} + +var xxx_messageInfo_Balance proto.InternalMessageInfo + func init() { proto.RegisterType((*GenesisState)(nil), "cosmos.bank.v2.GenesisState") + proto.RegisterType((*Balance)(nil), "cosmos.bank.v2.Balance") } func init() { proto.RegisterFile("cosmos/bank/v2/genesis.proto", fileDescriptor_bc2b1daa12dfd4fc) } var fileDescriptor_bc2b1daa12dfd4fc = []byte{ - // 198 bytes of a gzipped FileDescriptorProto + // 401 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4a, 0xcc, 0xcb, 0xd6, 0x2f, 0x33, 0xd2, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xc8, 0xea, 0x81, 0x64, 0xf5, 0xca, 0x8c, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0x95, 0x94, 0x24, 0x9a, 0x19, 0x60, 0xd5, 0x10, 0x29, 0xc1, 0xc4, 0xdc, 0xcc, 0xbc, 0x7c, 0x7d, 0x30, 0x09, - 0x11, 0x52, 0xf2, 0xe4, 0xe2, 0x71, 0x87, 0x58, 0x12, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0x64, 0xc9, - 0xc5, 0x56, 0x90, 0x58, 0x94, 0x98, 0x5b, 0x2c, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xa6, - 0x87, 0x6a, 0xa9, 0x5e, 0x00, 0x58, 0xd6, 0x89, 0xf3, 0xc4, 0x3d, 0x79, 0x86, 0x15, 0xcf, 0x37, - 0x68, 0x31, 0x06, 0x41, 0x35, 0x38, 0x99, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, - 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, - 0x43, 0x14, 0xd4, 0x5b, 0xc5, 0x29, 0xd9, 0x7a, 0x99, 0xf9, 0xfa, 0x15, 0x70, 0xa7, 0x95, 0x54, - 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x5d, 0x62, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x29, 0x0d, - 0x99, 0xe2, 0xfd, 0x00, 0x00, 0x00, + 0x15, 0x92, 0x83, 0xab, 0x2e, 0x4e, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, + 0xce, 0xcf, 0xcc, 0x43, 0x35, 0x2d, 0x1e, 0x62, 0x0d, 0xd4, 0x01, 0x60, 0x8e, 0x52, 0x0b, 0x13, + 0x17, 0x8f, 0x3b, 0xc4, 0x81, 0xc1, 0x25, 0x89, 0x25, 0xa9, 0x42, 0x96, 0x5c, 0x6c, 0x05, 0x89, + 0x45, 0x89, 0xb9, 0xc5, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x62, 0x7a, 0xa8, 0x0e, 0xd6, + 0x0b, 0x00, 0xcb, 0x3a, 0x71, 0x9e, 0xb8, 0x27, 0xcf, 0xb0, 0xe2, 0xf9, 0x06, 0x2d, 0xc6, 0x20, + 0xa8, 0x06, 0x21, 0x3b, 0x2e, 0x8e, 0xa4, 0xc4, 0x9c, 0xc4, 0xbc, 0xe4, 0xd4, 0x62, 0x09, 0x26, + 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x71, 0x74, 0xcd, 0x4e, 0x10, 0x79, 0x64, 0xdd, 0x70, 0x3d, 0x42, + 0x95, 0x5c, 0x6c, 0xc5, 0xa5, 0x05, 0x05, 0x39, 0x95, 0x12, 0xcc, 0x60, 0xdd, 0x92, 0x08, 0xdd, + 0xc5, 0xa9, 0x7a, 0x50, 0x7f, 0xe9, 0x39, 0xe7, 0x67, 0xe6, 0x39, 0xb9, 0x81, 0xf4, 0xaf, 0xba, + 0x2f, 0xaf, 0x91, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0x0b, 0xf5, 0x17, 0x94, + 0xd2, 0x2d, 0x4e, 0xc9, 0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x06, 0x6b, 0x28, 0x9e, 0xf5, 0x7c, + 0x83, 0x16, 0x4f, 0x4e, 0x6a, 0x7a, 0x62, 0x72, 0x65, 0x3c, 0x28, 0x64, 0x8a, 0xa1, 0x4e, 0x87, + 0x58, 0xa8, 0x74, 0x80, 0x91, 0x8b, 0x1d, 0xea, 0x36, 0x21, 0x23, 0x2e, 0xf6, 0xc4, 0x94, 0x94, + 0xa2, 0xd4, 0x62, 0x48, 0x10, 0x70, 0x3a, 0x49, 0x5c, 0xda, 0xa2, 0x2b, 0x02, 0x75, 0x8a, 0x23, + 0x44, 0x26, 0xb8, 0xa4, 0x28, 0x33, 0x2f, 0x3d, 0x08, 0xa6, 0x50, 0xa8, 0x9c, 0x8b, 0x15, 0x6c, + 0x2a, 0xd4, 0xdf, 0x74, 0x70, 0x39, 0xc4, 0x3e, 0x2b, 0x8e, 0x8e, 0x05, 0xf2, 0x0c, 0x2f, 0x16, + 0xc8, 0x33, 0x38, 0x99, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, + 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x14, 0x34, + 0x41, 0x16, 0xa7, 0x64, 0xeb, 0x65, 0xe6, 0xeb, 0x57, 0xc0, 0x13, 0x15, 0xd8, 0x92, 0x24, 0x36, + 0x70, 0x42, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xa0, 0x29, 0x0f, 0xca, 0xb7, 0x02, 0x00, + 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -113,6 +191,34 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Supply) > 0 { + for iNdEx := len(m.Supply) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Supply[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Balances) > 0 { + for iNdEx := len(m.Balances) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Balances[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -126,6 +232,50 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Balance) 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 *Balance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Balance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Coins) > 0 { + for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -145,6 +295,37 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.Balances) > 0 { + for _, e := range m.Balances { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Supply) > 0 { + for _, e := range m.Supply { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *Balance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Coins) > 0 { + for _, e := range m.Coins { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -216,6 +397,190 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Balances", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Balances = append(m.Balances, Balance{}) + if err := m.Balances[len(m.Balances)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Supply", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Supply = append(m.Supply, types.Coin{}) + if err := m.Supply[len(m.Supply)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Balance) 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 ErrIntOverflowGenesis + } + 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: Balance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Balance: 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 ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + 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 Coins", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Coins = append(m.Coins, types.Coin{}) + if err := m.Coins[len(m.Coins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/bank/v2/types/msgs.go b/x/bank/v2/types/msgs.go new file mode 100644 index 000000000000..5b536672eae0 --- /dev/null +++ b/x/bank/v2/types/msgs.go @@ -0,0 +1,14 @@ +package types + +import ( + coretransaction "cosmossdk.io/core/transaction" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ coretransaction.Msg = &MsgSend{} + +// NewMsgSend constructs a msg to send coins from one account to another. +func NewMsgSend(fromAddr, toAddr string, amount sdk.Coins) *MsgSend { + return &MsgSend{FromAddress: fromAddr, ToAddress: toAddr, Amount: amount} +} diff --git a/x/bank/v2/types/query.go b/x/bank/v2/types/query.go new file mode 100644 index 000000000000..b7e932ba5eeb --- /dev/null +++ b/x/bank/v2/types/query.go @@ -0,0 +1,6 @@ +package types + +// NewQueryBalanceRequest creates a new instance of QueryBalanceRequest. +func NewQueryBalanceRequest(addr, denom string) *QueryBalanceRequest { + return &QueryBalanceRequest{Address: addr, Denom: denom} +} diff --git a/x/bank/v2/types/query.pb.go b/x/bank/v2/types/query.pb.go index 9a84957f973c..da09cfc83a44 100644 --- a/x/bank/v2/types/query.pb.go +++ b/x/bank/v2/types/query.pb.go @@ -5,6 +5,8 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -107,29 +109,126 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +// QueryBalanceRequest is the request type for the Query/Balance RPC method. +type QueryBalanceRequest struct { + // address is the address to query balances for. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // denom is the coin denom to query balances for. + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *QueryBalanceRequest) Reset() { *m = QueryBalanceRequest{} } +func (m *QueryBalanceRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBalanceRequest) ProtoMessage() {} +func (*QueryBalanceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_bf35183cd83cb842, []int{2} +} +func (m *QueryBalanceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBalanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBalanceRequest.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 *QueryBalanceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBalanceRequest.Merge(m, src) +} +func (m *QueryBalanceRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryBalanceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBalanceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBalanceRequest proto.InternalMessageInfo + +// QueryBalanceResponse is the response type for the Query/Balance RPC method. +type QueryBalanceResponse struct { + // balance is the balance of the coin. + Balance *types.Coin `protobuf:"bytes,1,opt,name=balance,proto3" json:"balance,omitempty"` +} + +func (m *QueryBalanceResponse) Reset() { *m = QueryBalanceResponse{} } +func (m *QueryBalanceResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBalanceResponse) ProtoMessage() {} +func (*QueryBalanceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_bf35183cd83cb842, []int{3} +} +func (m *QueryBalanceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBalanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBalanceResponse.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 *QueryBalanceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBalanceResponse.Merge(m, src) +} +func (m *QueryBalanceResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryBalanceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBalanceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBalanceResponse proto.InternalMessageInfo + +func (m *QueryBalanceResponse) GetBalance() *types.Coin { + if m != nil { + return m.Balance + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "cosmos.bank.v2.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "cosmos.bank.v2.QueryParamsResponse") + proto.RegisterType((*QueryBalanceRequest)(nil), "cosmos.bank.v2.QueryBalanceRequest") + proto.RegisterType((*QueryBalanceResponse)(nil), "cosmos.bank.v2.QueryBalanceResponse") } func init() { proto.RegisterFile("cosmos/bank/v2/query.proto", fileDescriptor_bf35183cd83cb842) } var fileDescriptor_bf35183cd83cb842 = []byte{ - // 213 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4a, 0xcc, 0xcb, 0xd6, 0x2f, 0x33, 0xd2, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, - 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xc8, 0xe9, 0x81, 0xe4, 0xf4, 0xca, 0x8c, - 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0x95, 0x94, 0x60, 0x62, - 0x6e, 0x66, 0x5e, 0xbe, 0x3e, 0x98, 0x84, 0x0a, 0x49, 0xa2, 0x19, 0x0a, 0x36, 0x00, 0x2c, 0xa5, - 0x24, 0xc2, 0x25, 0x14, 0x08, 0xb2, 0x22, 0x20, 0xb1, 0x28, 0x31, 0xb7, 0x38, 0x28, 0xb5, 0xb0, - 0x34, 0xb5, 0xb8, 0x44, 0x29, 0x80, 0x4b, 0x18, 0x45, 0xb4, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, - 0xc8, 0x92, 0x8b, 0xad, 0x00, 0x2c, 0x22, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xa6, 0x87, - 0xea, 0x22, 0x3d, 0x88, 0x7a, 0x27, 0xce, 0x13, 0xf7, 0xe4, 0x19, 0x56, 0x3c, 0xdf, 0xa0, 0xc5, - 0x18, 0x04, 0xd5, 0xe0, 0x64, 0x76, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, - 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, - 0x32, 0x10, 0x33, 0x8a, 0x53, 0xb2, 0xf5, 0x32, 0xf3, 0xf5, 0x2b, 0xe0, 0x8e, 0x2c, 0xa9, 0x2c, - 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x3b, 0xd3, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xa7, 0x47, 0xcc, - 0x3c, 0x18, 0x01, 0x00, 0x00, + // 345 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x51, 0x3f, 0x4b, 0xf3, 0x40, + 0x18, 0x4f, 0x5e, 0x78, 0x5b, 0x7b, 0x82, 0x60, 0x0c, 0xd2, 0x16, 0xb9, 0x4a, 0x26, 0x11, 0xbc, + 0xa3, 0x29, 0x08, 0xba, 0x19, 0x47, 0x97, 0x1a, 0x37, 0x17, 0xb9, 0x34, 0x47, 0x09, 0x35, 0xf7, + 0xa4, 0xb9, 0xb4, 0xd8, 0x6f, 0xe0, 0xe8, 0x47, 0xe8, 0xe8, 0xe8, 0xe0, 0x87, 0xe8, 0x58, 0x9c, + 0x9c, 0x44, 0x9a, 0x41, 0x3f, 0x86, 0x24, 0x77, 0xad, 0xc4, 0x25, 0xe4, 0xf9, 0xfd, 0x7b, 0x7e, + 0x79, 0x82, 0xda, 0x03, 0x90, 0x31, 0x48, 0x1a, 0x30, 0x31, 0xa2, 0x53, 0x97, 0x8e, 0x27, 0x3c, + 0x9d, 0x91, 0x24, 0x85, 0x0c, 0xac, 0x1d, 0xc5, 0x91, 0x82, 0x23, 0x53, 0xb7, 0x6d, 0x0f, 0x61, + 0x08, 0x25, 0x45, 0x8b, 0x37, 0xa5, 0x6a, 0xef, 0xb2, 0x38, 0x12, 0x40, 0xcb, 0xa7, 0x86, 0x5a, + 0x7f, 0x42, 0xcb, 0x00, 0x45, 0xe1, 0x0d, 0x25, 0x39, 0x9d, 0x76, 0x03, 0x9e, 0xb1, 0x2e, 0x1d, + 0x40, 0x24, 0xaa, 0xd6, 0x3b, 0xb5, 0x46, 0x17, 0x28, 0x07, 0xc7, 0x46, 0xd6, 0x75, 0xd1, 0xae, + 0xcf, 0x52, 0x16, 0x4b, 0x9f, 0x8f, 0x27, 0x5c, 0x66, 0x4e, 0x1f, 0xed, 0x55, 0x50, 0x99, 0x80, + 0x90, 0xdc, 0x3a, 0x43, 0xb5, 0xa4, 0x44, 0x9a, 0xe6, 0xa1, 0x79, 0xb4, 0xed, 0xee, 0x93, 0xea, + 0xc7, 0x10, 0xa5, 0xf7, 0x1a, 0x8b, 0x8f, 0x8e, 0xf1, 0xfc, 0xf5, 0x72, 0x6c, 0xfa, 0xda, 0xe0, + 0x44, 0x3a, 0xd1, 0x63, 0xf7, 0x4c, 0x0c, 0xb8, 0x5e, 0x64, 0xb9, 0xa8, 0xce, 0xc2, 0x30, 0xe5, + 0x52, 0x45, 0x36, 0xbc, 0xe6, 0xdb, 0xeb, 0x89, 0xad, 0x53, 0x2f, 0x14, 0x73, 0x93, 0xa5, 0x91, + 0x18, 0xfa, 0x6b, 0xa1, 0x65, 0xa3, 0xff, 0x21, 0x17, 0x10, 0x37, 0xff, 0x15, 0x0e, 0x5f, 0x0d, + 0xe7, 0x5b, 0x8f, 0xf3, 0x8e, 0xf1, 0x3d, 0xef, 0x18, 0xce, 0x15, 0xb2, 0xab, 0xab, 0x74, 0xfb, + 0x1e, 0xaa, 0x07, 0x0a, 0xd2, 0xf5, 0x5b, 0xbf, 0xf5, 0x25, 0x27, 0xfa, 0x6e, 0xe4, 0x12, 0x22, + 0xe1, 0xaf, 0x95, 0xde, 0xe9, 0x62, 0x85, 0xcd, 0xe5, 0x0a, 0x9b, 0x9f, 0x2b, 0x6c, 0x3e, 0xe5, + 0xd8, 0x58, 0xe6, 0xd8, 0x78, 0xcf, 0xb1, 0x71, 0x7b, 0xa0, 0xcc, 0x32, 0x1c, 0x91, 0x08, 0xe8, + 0xc3, 0xe6, 0xbf, 0x64, 0xb3, 0x84, 0xcb, 0xa0, 0x56, 0x9e, 0xb7, 0xf7, 0x13, 0x00, 0x00, 0xff, + 0xff, 0x4a, 0x63, 0x62, 0x68, 0x0b, 0x02, 0x00, 0x00, } func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { @@ -188,6 +287,78 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryBalanceRequest) 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 *QueryBalanceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBalanceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + 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] = 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 *QueryBalanceResponse) 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 *QueryBalanceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBalanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Balance != nil { + { + size, err := m.Balance.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 @@ -219,6 +390,36 @@ func (m *QueryParamsResponse) Size() (n int) { return n } +func (m *QueryBalanceRequest) 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 = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryBalanceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Balance != nil { + l = m.Balance.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -358,6 +559,206 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryBalanceRequest) 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: QueryBalanceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBalanceRequest: 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 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 + 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 *QueryBalanceResponse) 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: QueryBalanceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBalanceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 m.Balance == nil { + m.Balance = &types.Coin{} + } + 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 skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/bank/v2/types/tx.pb.go b/x/bank/v2/types/tx.pb.go index 95736d2a721c..3867bdf64c84 100644 --- a/x/bank/v2/types/tx.pb.go +++ b/x/bank/v2/types/tx.pb.go @@ -6,6 +6,8 @@ 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/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" @@ -119,34 +121,247 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo +// 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"` + 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"` +} + +func (m *MsgSend) Reset() { *m = MsgSend{} } +func (m *MsgSend) String() string { return proto.CompactTextString(m) } +func (*MsgSend) ProtoMessage() {} +func (*MsgSend) Descriptor() ([]byte, []int) { + return fileDescriptor_14123aa47d73c00a, []int{2} +} +func (m *MsgSend) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSend) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSend.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 *MsgSend) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSend.Merge(m, src) +} +func (m *MsgSend) XXX_Size() int { + return m.Size() +} +func (m *MsgSend) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSend.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSend proto.InternalMessageInfo + +func (m *MsgSend) GetFromAddress() string { + if m != nil { + return m.FromAddress + } + return "" +} + +func (m *MsgSend) GetToAddress() string { + if m != nil { + return m.ToAddress + } + return "" +} + +func (m *MsgSend) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +// MsgSendResponse defines the response structure for executing a MsgSend message. +type MsgSendResponse struct { +} + +func (m *MsgSendResponse) Reset() { *m = MsgSendResponse{} } +func (m *MsgSendResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSendResponse) ProtoMessage() {} +func (*MsgSendResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_14123aa47d73c00a, []int{3} +} +func (m *MsgSendResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSendResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSendResponse.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 *MsgSendResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSendResponse.Merge(m, src) +} +func (m *MsgSendResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSendResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSendResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSendResponse proto.InternalMessageInfo + +// MsgMint is the Msg/Mint request type. +type MsgMint struct { + // authority is the address that controls the module (defaults to x/gov unless overwritten). + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + ToAddress string `protobuf:"bytes,2,opt,name=to_address,json=toAddress,proto3" json:"to_address,omitempty"` + 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"` +} + +func (m *MsgMint) Reset() { *m = MsgMint{} } +func (m *MsgMint) String() string { return proto.CompactTextString(m) } +func (*MsgMint) ProtoMessage() {} +func (*MsgMint) Descriptor() ([]byte, []int) { + return fileDescriptor_14123aa47d73c00a, []int{4} +} +func (m *MsgMint) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMint.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 *MsgMint) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMint.Merge(m, src) +} +func (m *MsgMint) XXX_Size() int { + return m.Size() +} +func (m *MsgMint) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMint.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMint proto.InternalMessageInfo + +func (m *MsgMint) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgMint) GetToAddress() string { + if m != nil { + return m.ToAddress + } + return "" +} + +func (m *MsgMint) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +// MsgMint defines the response structure for executing a MsgMint message. +type MsgMintResponse struct { +} + +func (m *MsgMintResponse) Reset() { *m = MsgMintResponse{} } +func (m *MsgMintResponse) String() string { return proto.CompactTextString(m) } +func (*MsgMintResponse) ProtoMessage() {} +func (*MsgMintResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_14123aa47d73c00a, []int{5} +} +func (m *MsgMintResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintResponse.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 *MsgMintResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintResponse.Merge(m, src) +} +func (m *MsgMintResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgMintResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgUpdateParams)(nil), "cosmos.bank.v2.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "cosmos.bank.v2.MsgUpdateParamsResponse") + proto.RegisterType((*MsgSend)(nil), "cosmos.bank.v2.MsgSend") + proto.RegisterType((*MsgSendResponse)(nil), "cosmos.bank.v2.MsgSendResponse") + proto.RegisterType((*MsgMint)(nil), "cosmos.bank.v2.MsgMint") + proto.RegisterType((*MsgMintResponse)(nil), "cosmos.bank.v2.MsgMintResponse") } func init() { proto.RegisterFile("cosmos/bank/v2/tx.proto", fileDescriptor_14123aa47d73c00a) } var fileDescriptor_14123aa47d73c00a = []byte{ - // 299 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4f, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4a, 0xcc, 0xcb, 0xd6, 0x2f, 0x33, 0xd2, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, - 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0x48, 0xe8, 0x81, 0x24, 0xf4, 0xca, 0x8c, 0xa4, 0x44, 0xd2, - 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0x95, 0x94, 0x24, 0x9a, 0x76, 0xb0, 0x6a, - 0x14, 0xa9, 0x78, 0x88, 0x1e, 0xa8, 0x69, 0x10, 0x29, 0x98, 0xa5, 0xb9, 0xc5, 0xe9, 0xfa, 0x65, - 0x86, 0x20, 0x0a, 0x2a, 0x21, 0x98, 0x98, 0x9b, 0x99, 0x97, 0xaf, 0x0f, 0x26, 0x21, 0x42, 0x4a, - 0x7b, 0x19, 0xb9, 0xf8, 0x7d, 0x8b, 0xd3, 0x43, 0x0b, 0x52, 0x12, 0x4b, 0x52, 0x03, 0x12, 0x8b, - 0x12, 0x73, 0x8b, 0x85, 0xcc, 0xb8, 0x38, 0x13, 0x4b, 0x4b, 0x32, 0xf2, 0x8b, 0x32, 0x4b, 0x2a, - 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x9d, 0x24, 0x2e, 0x6d, 0xd1, 0x15, 0x81, 0x5a, 0xe2, 0x98, - 0x92, 0x52, 0x94, 0x5a, 0x5c, 0x1c, 0x5c, 0x52, 0x94, 0x99, 0x97, 0x1e, 0x84, 0x50, 0x2a, 0x64, - 0xc9, 0xc5, 0x56, 0x00, 0x36, 0x41, 0x82, 0x49, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x4c, 0x0f, 0xd5, - 0x93, 0x7a, 0x10, 0xf3, 0x9d, 0x38, 0x4f, 0xdc, 0x93, 0x67, 0x58, 0xf1, 0x7c, 0x83, 0x16, 0x63, - 0x10, 0x54, 0x83, 0x95, 0x79, 0xd3, 0xf3, 0x0d, 0x5a, 0x08, 0xa3, 0xba, 0x9e, 0x6f, 0xd0, 0x52, - 0x81, 0x68, 0xd6, 0x2d, 0x4e, 0xc9, 0xd6, 0xaf, 0x80, 0x87, 0x00, 0x9a, 0x5b, 0x95, 0x24, 0xb9, - 0xc4, 0xd1, 0x84, 0x82, 0x52, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x9d, 0xcc, 0x4e, 0x3c, 0x92, - 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, - 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x06, 0x62, 0x74, 0x71, 0x4a, 0xb6, 0x5e, 0x66, - 0x3e, 0x92, 0xe1, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0x90, 0x31, 0x06, 0x04, 0x00, - 0x00, 0xff, 0xff, 0xbd, 0xd0, 0xd5, 0x76, 0xbc, 0x01, 0x00, 0x00, + // 492 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x93, 0xb1, 0x8b, 0x13, 0x41, + 0x14, 0xc6, 0xb3, 0x39, 0x88, 0x64, 0x72, 0x28, 0xb7, 0x1c, 0x5e, 0x72, 0xc8, 0x5e, 0x08, 0x16, + 0x21, 0x70, 0x33, 0x64, 0x85, 0x3b, 0x3c, 0x2b, 0x23, 0xd8, 0x05, 0x24, 0x87, 0x8d, 0x4d, 0x98, + 0x64, 0xc7, 0xbd, 0x25, 0xee, 0xbc, 0x65, 0xdf, 0x24, 0x5c, 0x5a, 0x4b, 0x2b, 0x6b, 0xff, 0x00, + 0x11, 0x0b, 0x49, 0x61, 0x6b, 0x7f, 0xe5, 0x61, 0x65, 0xa5, 0x92, 0x14, 0xf9, 0x37, 0x64, 0x76, + 0x26, 0xc9, 0x25, 0x72, 0x04, 0xec, 0x6c, 0x92, 0x61, 0xbe, 0xf7, 0x7d, 0xf3, 0xe6, 0x37, 0x6f, + 0xc9, 0x41, 0x1f, 0x30, 0x06, 0x64, 0x3d, 0x2e, 0x07, 0x6c, 0xe4, 0x33, 0x75, 0x49, 0x93, 0x14, + 0x14, 0xb8, 0x77, 0x8d, 0x40, 0xb5, 0x40, 0x47, 0xfe, 0xe1, 0x7e, 0x08, 0x21, 0x64, 0x12, 0xd3, + 0x2b, 0x53, 0x75, 0x58, 0xd9, 0xb0, 0x67, 0xd5, 0x6b, 0x52, 0xd7, 0x78, 0x6c, 0x9a, 0x91, 0x16, + 0x87, 0xc6, 0x18, 0xb2, 0x51, 0x53, 0xff, 0x59, 0x61, 0x8f, 0xc7, 0x91, 0x04, 0x96, 0xfd, 0xda, + 0x2d, 0x6f, 0x79, 0x02, 0x0a, 0x36, 0x6a, 0xf6, 0x84, 0xe2, 0x4d, 0xd6, 0x87, 0x48, 0x1a, 0xbd, + 0xf6, 0xcd, 0x21, 0xf7, 0xda, 0x18, 0xbe, 0x4c, 0x02, 0xae, 0xc4, 0x0b, 0x9e, 0xf2, 0x18, 0xdd, + 0x13, 0x52, 0xe4, 0x43, 0x75, 0x01, 0x69, 0xa4, 0xc6, 0x65, 0xa7, 0xea, 0xd4, 0x8b, 0xad, 0xf2, + 0xf7, 0xaf, 0xc7, 0xfb, 0xb6, 0x89, 0xa7, 0x41, 0x90, 0x0a, 0xc4, 0x73, 0x95, 0x46, 0x32, 0xec, + 0xac, 0x4a, 0xdd, 0xc7, 0xa4, 0x90, 0x64, 0x09, 0xe5, 0x7c, 0xd5, 0xa9, 0x97, 0xfc, 0xfb, 0x74, + 0x1d, 0x02, 0x35, 0xf9, 0xad, 0xe2, 0xd5, 0xcf, 0xa3, 0xdc, 0xa7, 0xf9, 0xa4, 0xe1, 0x74, 0xac, + 0xe1, 0xec, 0xf4, 0xed, 0x7c, 0xd2, 0x58, 0x45, 0xbd, 0x9b, 0x4f, 0x1a, 0x0f, 0x8d, 0xf9, 0x18, + 0x83, 0x01, 0xbb, 0x5c, 0x12, 0xda, 0xe8, 0xb5, 0x56, 0x21, 0x07, 0x1b, 0x5b, 0x1d, 0x81, 0x09, + 0x48, 0x14, 0xb5, 0x2f, 0x79, 0x72, 0xa7, 0x8d, 0xe1, 0xb9, 0x90, 0x81, 0xfb, 0x84, 0xec, 0xbe, + 0x4e, 0x21, 0xee, 0x72, 0xd3, 0xfb, 0xd6, 0x5b, 0x95, 0x74, 0xb5, 0xdd, 0x72, 0x4f, 0x09, 0x51, + 0xb0, 0xb4, 0xe6, 0xb7, 0x01, 0x51, 0xb0, 0x30, 0x8e, 0x49, 0x81, 0xc7, 0x30, 0x94, 0xaa, 0xbc, + 0x53, 0xdd, 0xa9, 0x97, 0xfc, 0xca, 0x0a, 0x08, 0x0a, 0x6a, 0x5f, 0x83, 0x3e, 0x83, 0x48, 0xb6, + 0x9e, 0x6b, 0x26, 0x9f, 0x7f, 0x1d, 0xd5, 0xc3, 0x48, 0x5d, 0x0c, 0x7b, 0xb4, 0x0f, 0xb1, 0x7d, + 0x74, 0x76, 0x83, 0x83, 0x1a, 0x27, 0x02, 0x33, 0x03, 0x7e, 0x98, 0x4f, 0x1a, 0xbb, 0x6f, 0x44, + 0xc8, 0xfb, 0xe3, 0xae, 0x7e, 0x4f, 0xb4, 0x40, 0xcd, 0x81, 0x67, 0xbe, 0x06, 0xba, 0x76, 0x67, + 0xcd, 0xf4, 0xc1, 0x6d, 0x4c, 0x35, 0xa4, 0xda, 0x5e, 0x36, 0x0a, 0x7a, 0xb9, 0x64, 0xf8, 0xd1, + 0x30, 0x6c, 0x47, 0x52, 0xfd, 0xf3, 0x58, 0xfc, 0x8f, 0xf8, 0xd8, 0xdf, 0xf3, 0x78, 0x2b, 0x3b, + 0x0d, 0xc7, 0xb2, 0xd3, 0xcb, 0x05, 0xbb, 0xd6, 0xc9, 0xd5, 0xd4, 0x73, 0xae, 0xa7, 0x9e, 0xf3, + 0x7b, 0xea, 0x39, 0xef, 0x67, 0x5e, 0xee, 0x7a, 0xe6, 0xe5, 0x7e, 0xcc, 0xbc, 0xdc, 0x2b, 0x1b, + 0x85, 0xc1, 0x80, 0x46, 0x70, 0x23, 0x2c, 0xeb, 0xaf, 0x57, 0xc8, 0xbe, 0xcc, 0x47, 0x7f, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x9a, 0xff, 0x7c, 0x62, 0x5c, 0x04, 0x00, 0x00, } func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { @@ -212,48 +427,623 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *MsgSend) 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 *MsgSend) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSend) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.ToAddress) > 0 { + i -= len(m.ToAddress) + copy(dAtA[i:], m.ToAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ToAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.FromAddress) > 0 { + i -= len(m.FromAddress) + copy(dAtA[i:], m.FromAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSendResponse) 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 *MsgSendResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSendResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgMint) 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 *MsgMint) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMint) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.ToAddress) > 0 { + i -= len(m.ToAddress) + copy(dAtA[i:], m.ToAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ToAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgMintResponse) 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 *MsgMintResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSend) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FromAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ToAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgSendResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgMint) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ToAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgMintResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUpdateParams) 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 ErrIntOverflowTx + } + 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF } - dAtA[offset] = uint8(v) - return base + return nil } -func (m *MsgUpdateParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) +func (m *MsgSend) 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 ErrIntOverflowTx + } + 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: MsgSend: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSend: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FromAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FromAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ToAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ToAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } - l = m.Params.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} -func (m *MsgUpdateParamsResponse) Size() (n int) { - if m == nil { - return 0 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - return n + return nil } +func (m *MsgSendResponse) 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 ErrIntOverflowTx + } + 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: MsgSendResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSendResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } -func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { +func (m *MsgMint) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -276,10 +1066,10 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + return fmt.Errorf("proto: MsgMint: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgMint: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -316,7 +1106,39 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ToAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ToAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -343,7 +1165,8 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -368,7 +1191,7 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { +func (m *MsgMintResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -391,10 +1214,10 @@ func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgMintResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgMintResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: