diff --git a/codecov.yml b/codecov.yml index 229d9511a1..2f528a2598 100644 --- a/codecov.yml +++ b/codecov.yml @@ -57,8 +57,8 @@ ignore: - "*.sh" - "*.png" - "*_test.go" - - "*.pb.go" - - "*.pb.gw.go" + - "x/**/*.pb.go" + - "x/**/*.pb.gw.go" - "scripts/" - "x/**/test_common.go" - "*_cmd.go" diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 883ccb883d..91acc46cfc 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -240,6 +240,12 @@ - [Query](#lbm.auth.v1beta1.Query) +- [lbm/auth/v1beta1/tx.proto](#lbm/auth/v1beta1/tx.proto) + - [MsgEmpty](#lbm.auth.v1beta1.MsgEmpty) + - [MsgEmptyResponse](#lbm.auth.v1beta1.MsgEmptyResponse) + + - [Msg](#lbm.auth.v1beta1.Msg) + - [lbm/bank/v1beta1/bank.proto](#lbm/bank/v1beta1/bank.proto) - [DenomUnit](#lbm.bank.v1beta1.DenomUnit) - [Input](#lbm.bank.v1beta1.Input) @@ -4018,6 +4024,57 @@ Query defines the gRPC querier service. + +

Top

+ +## lbm/auth/v1beta1/tx.proto + + + + + +### MsgEmpty +MsgEmpty represents a message that doesn't do anything. Used to measure performance. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `from_address` | [string](#string) | | | + + + + + + + + +### MsgEmptyResponse +MsgEmptyResponse defines the Msg/Empty response type. + + + + + + + + + + + + + + +### Msg +Msg defines the auth Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Empty` | [MsgEmpty](#lbm.auth.v1beta1.MsgEmpty) | [MsgEmptyResponse](#lbm.auth.v1beta1.MsgEmptyResponse) | Empty defines a method that doesn't do anything. Used to measure performance. | | + + + + +

Top

diff --git a/go.mod b/go.mod index 2b3ef9ad3a..8b3cb61129 100644 --- a/go.mod +++ b/go.mod @@ -28,11 +28,13 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/kr/text v0.2.0 // indirect github.com/line/iavl/v2 v2.0.0-init.1.0.20210507092458-8331d3daef36 github.com/line/ostracon v0.34.9-0.20210429084710-ef4fe0a40c7d github.com/line/tm-db/v2 v2.0.0-init.1.0.20210413083915-5bb60e117524 github.com/magiconair/properties v1.8.4 github.com/mattn/go-isatty v0.0.12 + github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/nxadm/tail v1.4.8 // indirect github.com/onsi/ginkgo v1.15.0 // indirect github.com/onsi/gomega v1.10.5 // indirect @@ -54,12 +56,13 @@ require ( github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 github.com/tendermint/go-amino v0.16.0 golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 - golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect - golang.org/x/sys v0.0.0-20210228012217-479acdf4ea46 // indirect + golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect + golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 // indirect golang.org/x/text v0.3.5 // indirect google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f google.golang.org/grpc v1.35.0 google.golang.org/protobuf v1.25.0 + gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index 8b022e0b5e..2797f68d75 100644 --- a/go.sum +++ b/go.sum @@ -113,6 +113,7 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe23fU= github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -260,6 +261,7 @@ github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBt github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -312,6 +314,7 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8 github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+NVZZA= @@ -324,6 +327,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= @@ -380,6 +385,8 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -650,8 +657,8 @@ golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -704,8 +711,9 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210228012217-479acdf4ea46 h1:V066+OYJ66oTjnhm4Yrn7SXIwSCiDQJxpBxmvqb1N1c= -golang.org/x/sys v0.0.0-20210228012217-479acdf4ea46/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 h1:F5Gozwx4I1xtr/sr/8CFbb57iKi3297KFs0QDbGN60A= +golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -795,6 +803,8 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= diff --git a/proto/lbm/auth/v1beta1/tx.proto b/proto/lbm/auth/v1beta1/tx.proto new file mode 100644 index 0000000000..2a915288f0 --- /dev/null +++ b/proto/lbm/auth/v1beta1/tx.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; +package lbm.auth.v1beta1; + +import "gogoproto/gogo.proto"; +import "lbm/auth/v1beta1/auth.proto"; + +option go_package = "github.com/line/lbm-sdk/v2/x/auth/types"; + +// Msg defines the auth Msg service. +service Msg { + // Empty defines a method that doesn't do anything. Used to measure performance. + rpc Empty(MsgEmpty) returns (MsgEmptyResponse); +} + +// MsgEmpty represents a message that doesn't do anything. Used to measure performance. +message MsgEmpty { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; +} + +// MsgEmptyResponse defines the Msg/Empty response type. +message MsgEmptyResponse {} diff --git a/x/auth/client/cli/cli_test.go b/x/auth/client/cli/cli_test.go index f12effb25f..6216052f4c 100644 --- a/x/auth/client/cli/cli_test.go +++ b/x/auth/client/cli/cli_test.go @@ -9,6 +9,8 @@ import ( "strings" "testing" + "github.com/gogo/protobuf/proto" + sdkerrors "github.com/line/lbm-sdk/v2/types/errors" ostcli "github.com/line/ostracon/libs/cli" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -1150,6 +1152,87 @@ func (s *IntegrationTestSuite) createBankMsg(val *network.Validator, toAddr sdk. return res } +func (s *IntegrationTestSuite) TestNewEmptyTxCmd() { + val := s.network.Validators[0] + + testCases := []struct { + name string + from sdk.AccAddress + args []string + expectErr bool + respType proto.Message + expectedCode uint32 + }{ + { + "valid transaction", + val.Address, + []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + }, + false, + &sdk.TxResponse{}, + 0, + }, + { + "not enough fees", + val.Address, + []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1))).String()), + }, + false, + &sdk.TxResponse{}, + sdkerrors.ErrInsufficientFee.ABCICode(), + }, + { + "not enough gas", + val.Address, + []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + "--gas=10", + }, + false, + &sdk.TxResponse{}, + sdkerrors.ErrOutOfGas.ABCICode(), + }, + { + "no from", + sdk.AccAddress{}, + []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + }, + true, + &sdk.TxResponse{}, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + bz, err := clitestutil.ExecTestCLICmd(val.ClientCtx, authcli.NewEmptyTxCmd(), + append([]string{tc.from.String()}, tc.args...)) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + + s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(bz.Bytes(), tc.respType), bz.String()) + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code) + } + }) + } +} + func TestIntegrationTestSuite(t *testing.T) { suite.Run(t, new(IntegrationTestSuite)) } diff --git a/x/auth/client/cli/tx.go b/x/auth/client/cli/tx.go new file mode 100644 index 0000000000..3262927896 --- /dev/null +++ b/x/auth/client/cli/tx.go @@ -0,0 +1,53 @@ +package cli + +import ( + "github.com/line/lbm-sdk/v2/client" + "github.com/line/lbm-sdk/v2/client/flags" + "github.com/line/lbm-sdk/v2/client/tx" + "github.com/line/lbm-sdk/v2/x/auth/types" + "github.com/spf13/cobra" +) + +// NewTxCmd returns a root CLI command handler for all x/auth transaction commands. +func NewTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Auth transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand(NewEmptyTxCmd()) + + return txCmd +} + +// NewEmptyTxCmd returns a CLI command handler for creating a MsgEmpty transaction. +func NewEmptyTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "empty [from_key_or_address]", + Short: `Empty doesn't do anything. Used to measure performance.`, + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[0]) + if err != nil { + return err + } + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewServiceMsgEmpty(clientCtx.GetFromAddress()) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/auth/keeper/msg_server.go b/x/auth/keeper/msg_server.go new file mode 100644 index 0000000000..5eaef2b84f --- /dev/null +++ b/x/auth/keeper/msg_server.go @@ -0,0 +1,31 @@ +package keeper + +import ( + "context" + + sdk "github.com/line/lbm-sdk/v2/types" + "github.com/line/lbm-sdk/v2/x/auth/types" +) + +type msgServer struct { + AccountKeeper +} + +// NewMsgServerImpl returns an implementation of the auth MsgServer interface for the provided Keeper. +func NewMsgServerImpl(keeper AccountKeeper) types.MsgServer { + return &msgServer{AccountKeeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +func (k msgServer) Empty(goCtx context.Context, msg *types.MsgEmpty) (*types.MsgEmptyResponse, error) { + sdk.UnwrapSDKContext(goCtx).EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeySender, msg.FromAddress), + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyAction, types.EventEmpty), + ), + ) + return &types.MsgEmptyResponse{}, nil +} diff --git a/x/auth/module.go b/x/auth/module.go index 9b035ae029..0f29fd4315 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -128,6 +128,7 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.accountKeeper)) types.RegisterQueryServer(cfg.QueryServer(), am.accountKeeper) } diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index 12754fa11b..34a355177c 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -4,6 +4,8 @@ import ( "github.com/line/lbm-sdk/v2/codec" "github.com/line/lbm-sdk/v2/codec/types" cryptocodec "github.com/line/lbm-sdk/v2/crypto/codec" + sdk "github.com/line/lbm-sdk/v2/types" + "github.com/line/lbm-sdk/v2/types/msgservice" "github.com/line/lbm-sdk/v2/x/auth/legacy/legacytx" ) @@ -15,6 +17,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*AccountI)(nil), nil) cdc.RegisterConcrete(&BaseAccount{}, "lbm-sdk/BaseAccount", nil) cdc.RegisterConcrete(&ModuleAccount{}, "lbm-sdk/ModuleAccount", nil) + cdc.RegisterConcrete(&MsgEmpty{}, "lbm-sdk/MsgEmpty", nil) legacytx.RegisterLegacyAminoCodec(cdc) } @@ -22,6 +25,11 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { // RegisterInterfaces associates protoName with AccountI interface // and creates a registry of it's concrete implementations func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgEmpty{}, + ) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) + registry.RegisterInterface( "lbm.auth.v1beta1.AccountI", (*AccountI)(nil), diff --git a/x/auth/types/events.go b/x/auth/types/events.go new file mode 100644 index 0000000000..1b28854da5 --- /dev/null +++ b/x/auth/types/events.go @@ -0,0 +1,7 @@ +package types + +var ( + EventEmpty = "empty" + + AttributeValueCategory = ModuleName +) diff --git a/x/auth/types/keys.go b/x/auth/types/keys.go index a5d4ba37af..f68abc134a 100644 --- a/x/auth/types/keys.go +++ b/x/auth/types/keys.go @@ -11,6 +11,9 @@ const ( // StoreKey is string representation of the store key for auth StoreKey = "acc" + // RouterKey defines the module's message routing key + RouterKey = ModuleName + // FeeCollectorName the root string for the fee collector account address FeeCollectorName = "fee_collector" diff --git a/x/auth/types/msgs.go b/x/auth/types/msgs.go new file mode 100644 index 0000000000..9840483d87 --- /dev/null +++ b/x/auth/types/msgs.go @@ -0,0 +1,52 @@ +package types + +import ( + sdk "github.com/line/lbm-sdk/v2/types" + sdkerrors "github.com/line/lbm-sdk/v2/types/errors" +) + +// auth message types +const ( + TypeMsgEmpty = "empty" +) + +var _ sdk.Msg = &MsgEmpty{} + +// NewMsgEmpty creates a new MsgEmpty object +//nolint:interfacer +func NewMsgEmpty(fromAddr sdk.AccAddress) *MsgEmpty { + return &MsgEmpty{FromAddress: fromAddr.String()} +} + +func NewServiceMsgEmpty(fromAddr sdk.AccAddress) sdk.ServiceMsg { + return sdk.ServiceMsg{ + MethodName: "/lbm.auth.v1beta1.Msg/Empty", + Request: NewMsgEmpty(fromAddr), + } +} + +func (msg MsgEmpty) Route() string { return ModuleName } + +func (msg MsgEmpty) Type() string { return TypeMsgEmpty } + +func (msg MsgEmpty) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + return nil +} + +// GetSignBytes Implements Msg. +func (msg MsgEmpty) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// GetSigners Implements Msg. +func (msg MsgEmpty) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} diff --git a/x/auth/types/msgs_test.go b/x/auth/types/msgs_test.go new file mode 100644 index 0000000000..d0ef424d2e --- /dev/null +++ b/x/auth/types/msgs_test.go @@ -0,0 +1,60 @@ +package types + +import ( + "fmt" + "testing" + + sdk "github.com/line/lbm-sdk/v2/types" + "github.com/stretchr/testify/require" +) + +func TestMsgSendRoute(t *testing.T) { + msg := NewMsgEmpty(sdk.AccAddress("from")) + + require.Equal(t, ModuleName, msg.Route()) + require.Equal(t, "empty", msg.Type()) + + srvMsg := NewServiceMsgEmpty(sdk.AccAddress("from")) + require.Equal(t, "/lbm.auth.v1beta1.Msg/Empty", srvMsg.Route()) + require.Equal(t, "/lbm.auth.v1beta1.Msg/Empty", srvMsg.Type()) +} + +func TestMsgSendValidation(t *testing.T) { + addr1 := sdk.AccAddress("from________________") + addrEmpty := sdk.AccAddress("") + addrTooLong := sdk.AccAddress("Accidentally used 33 bytes pubkey") + + cases := []struct { + expectedErr string // empty means no error expected + msg *MsgEmpty + }{ + {"", NewMsgEmpty(addr1)}, // valid + {"Invalid sender address (empty address string is not allowed): invalid address", NewMsgEmpty(addrEmpty)}, + {"Invalid sender address (incorrect address length (expected: 20, actual: 33)): invalid address", NewMsgEmpty(addrTooLong)}, + } + + for _, tc := range cases { + err := tc.msg.ValidateBasic() + if tc.expectedErr == "" { + require.Nil(t, err) + } else { + require.EqualError(t, err, tc.expectedErr) + } + } +} + +func TestMsgSendGetSignBytes(t *testing.T) { + res := NewMsgEmpty(sdk.AccAddress("input")).GetSignBytes() + + expected := `{"type":"lbm-sdk/MsgEmpty","value":{"from_address":"link1d9h8qat5fnwd3e"}}` + require.Equal(t, expected, string(res)) +} + +func TestMsgSendGetSigners(t *testing.T) { + res := NewMsgEmpty(sdk.AccAddress("input111111111111111")).GetSigners() + require.Equal(t, fmt.Sprintf("%v", res), "[696E707574313131313131313131313131313131]") + + require.Panics(t, func() { + NewMsgEmpty(sdk.AccAddress("input")).GetSigners() + }) +} diff --git a/x/auth/types/tx.pb.go b/x/auth/types/tx.pb.go new file mode 100644 index 0000000000..bb3dd2bf44 --- /dev/null +++ b/x/auth/types/tx.pb.go @@ -0,0 +1,523 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lbm/auth/v1beta1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgEmpty represents a message that doesn't do anything. Used to measure performance. +type MsgEmpty struct { + FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty" yaml:"from_address"` +} + +func (m *MsgEmpty) Reset() { *m = MsgEmpty{} } +func (m *MsgEmpty) String() string { return proto.CompactTextString(m) } +func (*MsgEmpty) ProtoMessage() {} +func (*MsgEmpty) Descriptor() ([]byte, []int) { + return fileDescriptor_8daee694c69402a3, []int{0} +} +func (m *MsgEmpty) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgEmpty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgEmpty.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 *MsgEmpty) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEmpty.Merge(m, src) +} +func (m *MsgEmpty) XXX_Size() int { + return m.Size() +} +func (m *MsgEmpty) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEmpty.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgEmpty proto.InternalMessageInfo + +// MsgEmptyResponse defines the Msg/Empty response type. +type MsgEmptyResponse struct { +} + +func (m *MsgEmptyResponse) Reset() { *m = MsgEmptyResponse{} } +func (m *MsgEmptyResponse) String() string { return proto.CompactTextString(m) } +func (*MsgEmptyResponse) ProtoMessage() {} +func (*MsgEmptyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8daee694c69402a3, []int{1} +} +func (m *MsgEmptyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgEmptyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgEmptyResponse.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 *MsgEmptyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEmptyResponse.Merge(m, src) +} +func (m *MsgEmptyResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgEmptyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEmptyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgEmptyResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgEmpty)(nil), "lbm.auth.v1beta1.MsgEmpty") + proto.RegisterType((*MsgEmptyResponse)(nil), "lbm.auth.v1beta1.MsgEmptyResponse") +} + +func init() { proto.RegisterFile("lbm/auth/v1beta1/tx.proto", fileDescriptor_8daee694c69402a3) } + +var fileDescriptor_8daee694c69402a3 = []byte{ + // 260 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0x49, 0xca, 0xd5, + 0x4f, 0x2c, 0x2d, 0xc9, 0xd0, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xc8, 0x49, 0xca, 0xd5, 0x03, 0x49, 0xe9, 0x41, 0xa5, + 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44, 0x9d, 0x94, 0x34, 0x86, + 0x11, 0x60, 0x4d, 0x60, 0x49, 0xa5, 0x00, 0x2e, 0x0e, 0xdf, 0xe2, 0x74, 0xd7, 0xdc, 0x82, 0x92, + 0x4a, 0x21, 0x2b, 0x2e, 0x9e, 0xb4, 0xa2, 0xfc, 0xdc, 0xf8, 0xc4, 0x94, 0x94, 0xa2, 0xd4, 0xe2, + 0x62, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x4e, 0x27, 0xf1, 0x4f, 0xf7, 0xe4, 0x85, 0x2b, 0x13, 0x73, + 0x73, 0xac, 0x94, 0x90, 0x65, 0x95, 0x82, 0xb8, 0x41, 0x5c, 0x47, 0x08, 0xcf, 0x8a, 0xa3, 0x63, + 0x81, 0x3c, 0xc3, 0x8b, 0x05, 0xf2, 0x0c, 0x4a, 0x42, 0x5c, 0x02, 0x30, 0x13, 0x83, 0x52, 0x8b, + 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x8d, 0xfc, 0xb8, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0xdc, 0xb9, 0x58, + 0x21, 0x36, 0x49, 0xe9, 0xa1, 0xbb, 0x5d, 0x0f, 0xa6, 0x47, 0x4a, 0x09, 0xb7, 0x1c, 0xcc, 0x3c, + 0x27, 0xc7, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, + 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x52, 0x4f, 0xcf, 0x2c, + 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xcf, 0xc9, 0xcc, 0x4b, 0xd5, 0xcf, 0x49, 0xca, + 0xd5, 0x2d, 0x4e, 0xc9, 0xd6, 0x2f, 0x33, 0xd2, 0xaf, 0x80, 0x84, 0x42, 0x49, 0x65, 0x41, 0x6a, + 0x71, 0x12, 0x1b, 0xd8, 0xff, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x63, 0xbc, 0x35, 0x50, + 0x61, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // Empty defines a method that doesn't do anything. Used to measure performance. + Empty(ctx context.Context, in *MsgEmpty, opts ...grpc.CallOption) (*MsgEmptyResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) Empty(ctx context.Context, in *MsgEmpty, opts ...grpc.CallOption) (*MsgEmptyResponse, error) { + out := new(MsgEmptyResponse) + err := c.cc.Invoke(ctx, "/lbm.auth.v1beta1.Msg/Empty", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // Empty defines a method that doesn't do anything. Used to measure performance. + Empty(context.Context, *MsgEmpty) (*MsgEmptyResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) Empty(ctx context.Context, req *MsgEmpty) (*MsgEmptyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Empty not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_Empty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgEmpty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Empty(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lbm.auth.v1beta1.Msg/Empty", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Empty(ctx, req.(*MsgEmpty)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "lbm.auth.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Empty", + Handler: _Msg_Empty_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "lbm/auth/v1beta1/tx.proto", +} + +func (m *MsgEmpty) 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 *MsgEmpty) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEmpty) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + 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 *MsgEmptyResponse) 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 *MsgEmptyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEmptyResponse) 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 *MsgEmpty) 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)) + } + return n +} + +func (m *MsgEmptyResponse) 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 *MsgEmpty) 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: MsgEmpty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEmpty: 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 + 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 *MsgEmptyResponse) 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: MsgEmptyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEmptyResponse: 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 + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +)