From 9bf8089776d197320f01e02781375d69b037c427 Mon Sep 17 00:00:00 2001 From: Cory Levinson Date: Mon, 9 Aug 2021 18:13:30 -0700 Subject: [PATCH 1/9] add MsgCreatePermanentLockedVestingAccount --- docs/core/proto-docs.md | 31 ++ proto/cosmos/vesting/v1beta1/tx.proto | 19 +- x/auth/vesting/client/cli/tx.go | 36 ++ x/auth/vesting/client/testutil/cli_test.go | 2 +- x/auth/vesting/client/testutil/suite.go | 67 ++- x/auth/vesting/handler.go | 3 + x/auth/vesting/msg_server.go | 66 +++ x/auth/vesting/types/codec.go | 1 + x/auth/vesting/types/msgs.go | 65 +++ x/auth/vesting/types/tx.pb.go | 540 +++++++++++++++++++-- 10 files changed, 800 insertions(+), 30 deletions(-) diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 6b2ddbe1e46..30e112ef578 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -572,6 +572,8 @@ - [Query](#cosmos.upgrade.v1beta1.Query) - [cosmos/vesting/v1beta1/tx.proto](#cosmos/vesting/v1beta1/tx.proto) + - [MsgCreatePermanentLockedAccount](#cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount) + - [MsgCreatePermanentLockedAccountResponse](#cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccountResponse) - [MsgCreateVestingAccount](#cosmos.vesting.v1beta1.MsgCreateVestingAccount) - [MsgCreateVestingAccountResponse](#cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse) @@ -8070,6 +8072,34 @@ Query defines the gRPC upgrade querier service. + + +### MsgCreatePermanentLockedAccount +MsgCreatePermanentLockedAccount defines a message that enables creating a permanent +locked account. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `from_address` | [string](#string) | | | +| `to_address` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | + + + + + + + + +### MsgCreatePermanentLockedAccountResponse +MsgCreatePermanentLockedAccountResponse defines the Msg/CreatePermanentLockedAccount response type. + + + + + + ### MsgCreateVestingAccount @@ -8114,6 +8144,7 @@ Msg defines the bank Msg service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `CreateVestingAccount` | [MsgCreateVestingAccount](#cosmos.vesting.v1beta1.MsgCreateVestingAccount) | [MsgCreateVestingAccountResponse](#cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse) | CreateVestingAccount defines a method that enables creating a vesting account. | | +| `CreatePermanentLockedAccount` | [MsgCreatePermanentLockedAccount](#cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount) | [MsgCreatePermanentLockedAccountResponse](#cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccountResponse) | CreatePermanentLockedAccount defines a method that enables creating a permanent locked account. | | diff --git a/proto/cosmos/vesting/v1beta1/tx.proto b/proto/cosmos/vesting/v1beta1/tx.proto index c49be802a76..9b0c81a8a53 100644 --- a/proto/cosmos/vesting/v1beta1/tx.proto +++ b/proto/cosmos/vesting/v1beta1/tx.proto @@ -11,6 +11,9 @@ service Msg { // CreateVestingAccount defines a method that enables creating a vesting // account. rpc CreateVestingAccount(MsgCreateVestingAccount) returns (MsgCreateVestingAccountResponse); + // CreatePermanentLockedAccount defines a method that enables creating a permanent + // locked account. + rpc CreatePermanentLockedAccount(MsgCreatePermanentLockedAccount) returns (MsgCreatePermanentLockedAccountResponse); } // MsgCreateVestingAccount defines a message that enables creating a vesting @@ -28,4 +31,18 @@ message MsgCreateVestingAccount { } // MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type. -message MsgCreateVestingAccountResponse {} \ No newline at end of file +message MsgCreateVestingAccountResponse {} + +// MsgCreatePermanentLockedAccount defines a message that enables creating a permanent +// locked account. +message MsgCreatePermanentLockedAccount { + option (gogoproto.equal) = true; + + string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; + string to_address = 2 [(gogoproto.moretags) = "yaml:\"to_address\""]; + repeated cosmos.base.v1beta1.Coin amount = 3 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// MsgCreatePermanentLockedAccountResponse defines the Msg/CreatePermanentLockedAccount response type. +message MsgCreatePermanentLockedAccountResponse {} \ No newline at end of file diff --git a/x/auth/vesting/client/cli/tx.go b/x/auth/vesting/client/cli/tx.go index 686a941e5de..1e1d13d338e 100644 --- a/x/auth/vesting/client/cli/tx.go +++ b/x/auth/vesting/client/cli/tx.go @@ -29,6 +29,7 @@ func GetTxCmd() *cobra.Command { txCmd.AddCommand( NewMsgCreateVestingAccountCmd(), + NewMsgCreatePermanentLockedAccountCmd(), ) return txCmd @@ -79,3 +80,38 @@ timestamp.`, return cmd } +// NewMsgCreatePermanentLockedAccountCmd returns a CLI command handler for creating a +// MsgCreatePermanentLockedAccount transaction. +func NewMsgCreatePermanentLockedAccountCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-permanent-locked-account [to_address] [amount]", + Short: "Create a new permanently locked account funded with an allocation of tokens.", + Long: `Create a new account funded with an allocation of permanently locked tokens. These +tokens may be used for staking but are non-transferable. Staking rewards will acrue as liquid and transferable +tokens.`, + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + toAddr, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err + } + + amount, err := sdk.ParseCoinsNormalized(args[1]) + if err != nil { + return err + } + + msg := types.NewMsgCreatePermanentLockedAccount(clientCtx.GetFromAddress(), toAddr, amount) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/auth/vesting/client/testutil/cli_test.go b/x/auth/vesting/client/testutil/cli_test.go index dd36a6af2d3..124a366c1ba 100644 --- a/x/auth/vesting/client/testutil/cli_test.go +++ b/x/auth/vesting/client/testutil/cli_test.go @@ -14,4 +14,4 @@ func TestIntegrationTestSuite(t *testing.T) { cfg := network.DefaultConfig() cfg.NumValidators = 1 suite.Run(t, NewIntegrationTestSuite(cfg)) -} +} \ No newline at end of file diff --git a/x/auth/vesting/client/testutil/suite.go b/x/auth/vesting/client/testutil/suite.go index f619f31165c..7a7ddb6da1c 100644 --- a/x/auth/vesting/client/testutil/suite.go +++ b/x/auth/vesting/client/testutil/suite.go @@ -115,7 +115,7 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { tc := tc s.Run(name, func() { - clientCtx := val.ClientCtx + clientCtx := val.ClientCtx bw, err := clitestutil.ExecTestCLICmd(clientCtx, cli.NewMsgCreateVestingAccountCmd(), tc.args) if tc.expectErr { @@ -124,6 +124,71 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(bw.Bytes(), tc.respType), bw.String()) + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code) + } + }) + } +} +func (s *IntegrationTestSuite) TestNewMsgCreatePermanentLockedAccountCmd() { + val := s.network.Validators[0] + + testCases := map[string]struct { + args []string + expectErr bool + expectedCode uint32 + respType proto.Message + }{ + "create a permanent locked account": { + args: []string{ + sdk.AccAddress("addr4_______________").String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), + 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()), + }, + expectErr: false, + expectedCode: 0, + respType: &sdk.TxResponse{}, + }, + "invalid address": { + args: []string{ + sdk.AccAddress("addr4").String(), + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), + "4070908800", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), + }, + expectErr: true, + expectedCode: 0, + respType: &sdk.TxResponse{}, + }, + "invalid coins": { + args: []string{ + sdk.AccAddress("addr4_______________").String(), + "fooo", + "4070908800", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), + }, + expectErr: true, + expectedCode: 0, + respType: &sdk.TxResponse{}, + }, + } + + for name, tc := range testCases { + tc := tc + + s.Run(name, func() { + clientCtx := val.ClientCtx + + bw, err := clitestutil.ExecTestCLICmd(clientCtx, cli.NewMsgCreatePermanentLockedAccountCmd(), tc.args) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(bw.Bytes(), tc.respType), bw.String()) + txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code) } diff --git a/x/auth/vesting/handler.go b/x/auth/vesting/handler.go index 1d32e9969bb..c2cb17fc9c6 100644 --- a/x/auth/vesting/handler.go +++ b/x/auth/vesting/handler.go @@ -18,6 +18,9 @@ func NewHandler(ak keeper.AccountKeeper, bk types.BankKeeper) sdk.Handler { case *types.MsgCreateVestingAccount: res, err := msgServer.CreateVestingAccount(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgCreatePermanentLockedAccount: + res, err := msgServer.CreatePermanentLockedAccount(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) default: return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) diff --git a/x/auth/vesting/msg_server.go b/x/auth/vesting/msg_server.go index 795fc2c6058..6154695fbf7 100644 --- a/x/auth/vesting/msg_server.go +++ b/x/auth/vesting/msg_server.go @@ -98,3 +98,69 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCre return &types.MsgCreateVestingAccountResponse{}, nil } +func (s msgServer) CreatePermanentLockedAccount(goCtx context.Context, msg *types.MsgCreatePermanentLockedAccount) (*types.MsgCreatePermanentLockedAccountResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + ak := s.AccountKeeper + bk := s.BankKeeper + + if err := bk.IsSendEnabledCoins(ctx, msg.Amount...); err != nil { + return nil, err + } + + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + return nil, err + } + to, err := sdk.AccAddressFromBech32(msg.ToAddress) + if err != nil { + return nil, err + } + + if bk.BlockedAddr(to) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", msg.ToAddress) + } + + if acc := ak.GetAccount(ctx, to); acc != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "account %s already exists", msg.ToAddress) + } + + baseAccountI := ak.NewAccountWithAddress(ctx, to) + + baseAcc, ok := baseAccountI.(*authtypes.BaseAccount) + if !ok { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid account type; expected: BaseAccount, got: %T", baseAccountI) + } + + var acc authtypes.AccountI + acc = types.NewPermanentLockedAccount(baseAcc, msg.Amount) + + ak.SetAccount(ctx, acc) + + defer func() { + telemetry.IncrCounter(1, "new", "account") + + for _, a := range msg.Amount { + if a.Amount.IsInt64() { + telemetry.SetGaugeWithLabels( + []string{"tx", "msg", "create_permanent_locked_account"}, + float32(a.Amount.Int64()), + []metrics.Label{telemetry.NewLabel("denom", a.Denom)}, + ) + } + } + }() + + err = bk.SendCoins(ctx, from, to, msg.Amount) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + return &types.MsgCreatePermanentLockedAccountResponse{}, nil +} diff --git a/x/auth/vesting/types/codec.go b/x/auth/vesting/types/codec.go index 6a4b795107d..c5f33d891d5 100644 --- a/x/auth/vesting/types/codec.go +++ b/x/auth/vesting/types/codec.go @@ -53,6 +53,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgCreateVestingAccount{}, + &MsgCreatePermanentLockedAccount{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/auth/vesting/types/msgs.go b/x/auth/vesting/types/msgs.go index 3308e030488..e777a6aa198 100644 --- a/x/auth/vesting/types/msgs.go +++ b/x/auth/vesting/types/msgs.go @@ -8,8 +8,13 @@ import ( // TypeMsgCreateVestingAccount defines the type value for a MsgCreateVestingAccount. const TypeMsgCreateVestingAccount = "msg_create_vesting_account" +// TypeMsgCreatePermanentLockedAccount defines the type value for a MsgCreatePermanentLockedAccount. +const TypeMsgCreatePermanentLockedAccount = "msg_create_permanent_locked_account" + var _ sdk.Msg = &MsgCreateVestingAccount{} +var _ sdk.Msg = &MsgCreatePermanentLockedAccount{} + // NewMsgCreateVestingAccount returns a reference to a new MsgCreateVestingAccount. //nolint:interfacer func NewMsgCreateVestingAccount(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins, endTime int64, delayed bool) *MsgCreateVestingAccount { @@ -75,3 +80,63 @@ func (msg MsgCreateVestingAccount) GetSigners() []sdk.AccAddress { } return []sdk.AccAddress{from} } + +// NewMsgCreatePermanentLockedAccount returns a reference to a new MsgCreatePermanentLockedAccount. +//nolint:interfacer +func NewMsgCreatePermanentLockedAccount(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins) *MsgCreatePermanentLockedAccount { + return &MsgCreatePermanentLockedAccount{ + FromAddress: fromAddr.String(), + ToAddress: toAddr.String(), + Amount: amount, + } +} + +// Route returns the message route for a MsgCreatePermanentLockedAccount. +func (msg MsgCreatePermanentLockedAccount) Route() string { return RouterKey } + +// Type returns the message type for a MsgCreatePermanentLockedAccount. +func (msg MsgCreatePermanentLockedAccount) Type() string { return TypeMsgCreatePermanentLockedAccount } + +// ValidateBasic Implements Msg. +func (msg MsgCreatePermanentLockedAccount) ValidateBasic() error { + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + return err + } + to, err := sdk.AccAddressFromBech32(msg.ToAddress) + if err != nil { + return err + } + if err := sdk.VerifyAddressFormat(from); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address: %s", err) + } + + if err := sdk.VerifyAddressFormat(to); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid recipient address: %s", err) + } + + if !msg.Amount.IsValid() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.Amount.String()) + } + + if !msg.Amount.IsAllPositive() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.Amount.String()) + } + + return nil +} + +// GetSignBytes returns the bytes all expected signers must sign over for a +// MsgCreatePermanentLockedAccount. +func (msg MsgCreatePermanentLockedAccount) GetSignBytes() []byte { + return sdk.MustSortJSON(amino.MustMarshalJSON(&msg)) +} + +// GetSigners returns the expected signers for a MsgCreatePermanentLockedAccount. +func (msg MsgCreatePermanentLockedAccount) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} diff --git a/x/auth/vesting/types/tx.pb.go b/x/auth/vesting/types/tx.pb.go index d07a154dd32..68353366703 100644 --- a/x/auth/vesting/types/tx.pb.go +++ b/x/auth/vesting/types/tx.pb.go @@ -145,41 +145,148 @@ func (m *MsgCreateVestingAccountResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateVestingAccountResponse proto.InternalMessageInfo +// MsgCreatePermanentLockedAccount defines a message that enables creating a permanent +// locked account. +type MsgCreatePermanentLockedAccount struct { + FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty" yaml:"from_address"` + ToAddress string `protobuf:"bytes,2,opt,name=to_address,json=toAddress,proto3" json:"to_address,omitempty" yaml:"to_address"` + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *MsgCreatePermanentLockedAccount) Reset() { *m = MsgCreatePermanentLockedAccount{} } +func (m *MsgCreatePermanentLockedAccount) String() string { return proto.CompactTextString(m) } +func (*MsgCreatePermanentLockedAccount) ProtoMessage() {} +func (*MsgCreatePermanentLockedAccount) Descriptor() ([]byte, []int) { + return fileDescriptor_5338ca97811f9792, []int{2} +} +func (m *MsgCreatePermanentLockedAccount) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreatePermanentLockedAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreatePermanentLockedAccount.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 *MsgCreatePermanentLockedAccount) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreatePermanentLockedAccount.Merge(m, src) +} +func (m *MsgCreatePermanentLockedAccount) XXX_Size() int { + return m.Size() +} +func (m *MsgCreatePermanentLockedAccount) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreatePermanentLockedAccount.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreatePermanentLockedAccount proto.InternalMessageInfo + +func (m *MsgCreatePermanentLockedAccount) GetFromAddress() string { + if m != nil { + return m.FromAddress + } + return "" +} + +func (m *MsgCreatePermanentLockedAccount) GetToAddress() string { + if m != nil { + return m.ToAddress + } + return "" +} + +func (m *MsgCreatePermanentLockedAccount) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +// MsgCreatePermanentLockedAccountResponse defines the Msg/CreatePermanentLockedAccount response type. +type MsgCreatePermanentLockedAccountResponse struct { +} + +func (m *MsgCreatePermanentLockedAccountResponse) Reset() { + *m = MsgCreatePermanentLockedAccountResponse{} +} +func (m *MsgCreatePermanentLockedAccountResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreatePermanentLockedAccountResponse) ProtoMessage() {} +func (*MsgCreatePermanentLockedAccountResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5338ca97811f9792, []int{3} +} +func (m *MsgCreatePermanentLockedAccountResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreatePermanentLockedAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreatePermanentLockedAccountResponse.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 *MsgCreatePermanentLockedAccountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreatePermanentLockedAccountResponse.Merge(m, src) +} +func (m *MsgCreatePermanentLockedAccountResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreatePermanentLockedAccountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreatePermanentLockedAccountResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreatePermanentLockedAccountResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgCreateVestingAccount)(nil), "cosmos.vesting.v1beta1.MsgCreateVestingAccount") proto.RegisterType((*MsgCreateVestingAccountResponse)(nil), "cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse") + proto.RegisterType((*MsgCreatePermanentLockedAccount)(nil), "cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount") + proto.RegisterType((*MsgCreatePermanentLockedAccountResponse)(nil), "cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccountResponse") } func init() { proto.RegisterFile("cosmos/vesting/v1beta1/tx.proto", fileDescriptor_5338ca97811f9792) } var fileDescriptor_5338ca97811f9792 = []byte{ - // 410 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0xbd, 0xae, 0xd3, 0x30, - 0x14, 0x8e, 0x6f, 0x2e, 0xf7, 0xc7, 0x17, 0x09, 0x91, 0x16, 0x1a, 0x3a, 0xc4, 0x21, 0x53, 0x16, - 0x6c, 0x5a, 0x90, 0x90, 0xba, 0x35, 0x1d, 0x51, 0x97, 0x08, 0x31, 0xb0, 0x54, 0x4e, 0x62, 0xd2, - 0x88, 0x26, 0xae, 0x62, 0xb7, 0x6a, 0x37, 0x46, 0x46, 0x1e, 0x81, 0x99, 0xa7, 0x60, 0xec, 0xd8, - 0x91, 0x29, 0xa0, 0x76, 0x61, 0xee, 0x13, 0xa0, 0xc4, 0x49, 0x61, 0x68, 0x91, 0x98, 0xec, 0xa3, - 0xef, 0xc7, 0xe7, 0x7c, 0x3e, 0x10, 0x85, 0x5c, 0xa4, 0x5c, 0x90, 0x25, 0x13, 0x32, 0xc9, 0x62, - 0xb2, 0xec, 0x05, 0x4c, 0xd2, 0x1e, 0x91, 0x2b, 0x3c, 0xcf, 0xb9, 0xe4, 0xc6, 0x63, 0x45, 0xc0, - 0x35, 0x01, 0xd7, 0x84, 0x6e, 0x3b, 0xe6, 0x31, 0xaf, 0x28, 0xa4, 0xbc, 0x29, 0x76, 0xd7, 0xaa, - 0xed, 0x02, 0x2a, 0xd8, 0xd1, 0x2b, 0xe4, 0x49, 0xa6, 0x70, 0xe7, 0xdb, 0x05, 0xec, 0x8c, 0x45, - 0x3c, 0xca, 0x19, 0x95, 0xec, 0xad, 0xb2, 0x1c, 0x86, 0x21, 0x5f, 0x64, 0xd2, 0x18, 0xc0, 0xfb, - 0xef, 0x73, 0x9e, 0x4e, 0x68, 0x14, 0xe5, 0x4c, 0x08, 0x13, 0xd8, 0xc0, 0xbd, 0xf5, 0x3a, 0x87, - 0x02, 0xb5, 0xd6, 0x34, 0x9d, 0x0d, 0x9c, 0xbf, 0x51, 0xc7, 0xbf, 0x2b, 0xcb, 0xa1, 0xaa, 0x8c, - 0x97, 0x10, 0x4a, 0x7e, 0x54, 0x5e, 0x54, 0xca, 0x47, 0x87, 0x02, 0x3d, 0x54, 0xca, 0x3f, 0x98, - 0xe3, 0xdf, 0x4a, 0xde, 0xa8, 0x42, 0x78, 0x45, 0xd3, 0xf2, 0x6d, 0x53, 0xb7, 0x75, 0xf7, 0xae, - 0xff, 0x04, 0xd7, 0xc3, 0x96, 0xed, 0x37, 0x93, 0xe2, 0x11, 0x4f, 0x32, 0xef, 0xf9, 0xa6, 0x40, - 0xda, 0xd7, 0x1f, 0xc8, 0x8d, 0x13, 0x39, 0x5d, 0x04, 0x38, 0xe4, 0x29, 0xa9, 0x67, 0x55, 0xc7, - 0x33, 0x11, 0x7d, 0x20, 0x72, 0x3d, 0x67, 0xa2, 0x12, 0x08, 0xbf, 0xb6, 0x36, 0x30, 0xbc, 0x61, - 0x59, 0x34, 0x91, 0x49, 0xca, 0xcc, 0x4b, 0x1b, 0xb8, 0xba, 0xd7, 0x3a, 0x14, 0xe8, 0x81, 0x6a, - 0xac, 0x41, 0x1c, 0xff, 0x9a, 0x65, 0xd1, 0x9b, 0x24, 0x65, 0x86, 0x09, 0xaf, 0x23, 0x36, 0xa3, - 0x6b, 0x16, 0x99, 0xf7, 0x6c, 0xe0, 0xde, 0xf8, 0x4d, 0x39, 0xb8, 0xfc, 0xf5, 0x05, 0x01, 0xe7, - 0x29, 0x44, 0x67, 0x12, 0xf4, 0x99, 0x98, 0xf3, 0x4c, 0xb0, 0xfe, 0x27, 0x00, 0xf5, 0xb1, 0x88, - 0x8d, 0x8f, 0x00, 0xb6, 0x4f, 0x46, 0x4d, 0xf0, 0xe9, 0x5f, 0xc5, 0x67, 0x9c, 0xbb, 0xaf, 0xfe, - 0x53, 0xd0, 0xb4, 0xe2, 0xbd, 0xde, 0xec, 0x2c, 0xb0, 0xdd, 0x59, 0xe0, 0xe7, 0xce, 0x02, 0x9f, - 0xf7, 0x96, 0xb6, 0xdd, 0x5b, 0xda, 0xf7, 0xbd, 0xa5, 0xbd, 0xeb, 0xfd, 0x33, 0xc9, 0x15, 0xa1, - 0x0b, 0x39, 0x3d, 0xae, 0x65, 0x15, 0x6c, 0x70, 0x55, 0x2d, 0xd1, 0x8b, 0xdf, 0x01, 0x00, 0x00, - 0xff, 0xff, 0xe7, 0x28, 0xaf, 0xe5, 0xb5, 0x02, 0x00, 0x00, + // 468 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x94, 0x3d, 0x6f, 0xd3, 0x40, + 0x18, 0xc7, 0x73, 0x49, 0xe9, 0xcb, 0x15, 0x09, 0xe1, 0x16, 0x6a, 0x22, 0xe4, 0x0b, 0x5e, 0x30, + 0x03, 0x77, 0xa4, 0x20, 0x21, 0x65, 0x41, 0x4d, 0x47, 0xa8, 0x84, 0x2c, 0xc4, 0xc0, 0x52, 0x5d, + 0x7c, 0x0f, 0xae, 0xd5, 0xde, 0x5d, 0xe4, 0xbb, 0x54, 0xcd, 0xc6, 0x47, 0x60, 0x64, 0x44, 0x62, + 0xe3, 0x53, 0x30, 0x76, 0xec, 0xc8, 0x14, 0x50, 0xb2, 0x30, 0xe7, 0x03, 0x20, 0x14, 0x9f, 0x1d, + 0x3a, 0xa4, 0xad, 0x60, 0xec, 0x64, 0x3f, 0x7a, 0xfe, 0xbf, 0xbf, 0x9f, 0x17, 0xdf, 0x61, 0x92, + 0x68, 0x23, 0xb5, 0x61, 0xc7, 0x60, 0x6c, 0xa6, 0x52, 0x76, 0xdc, 0xee, 0x81, 0xe5, 0x6d, 0x66, + 0x4f, 0x68, 0x3f, 0xd7, 0x56, 0x7b, 0x77, 0x9d, 0x80, 0x96, 0x02, 0x5a, 0x0a, 0x9a, 0x9b, 0xa9, + 0x4e, 0x75, 0x21, 0x61, 0xb3, 0x37, 0xa7, 0x6e, 0x06, 0xa5, 0x5d, 0x8f, 0x1b, 0x98, 0x7b, 0x25, + 0x3a, 0x53, 0x2e, 0x1f, 0x7e, 0xab, 0xe3, 0xad, 0x3d, 0x93, 0xee, 0xe6, 0xc0, 0x2d, 0xbc, 0x75, + 0x96, 0x3b, 0x49, 0xa2, 0x07, 0xca, 0x7a, 0x1d, 0x7c, 0xf3, 0x7d, 0xae, 0xe5, 0x3e, 0x17, 0x22, + 0x07, 0x63, 0x7c, 0xd4, 0x42, 0xd1, 0x5a, 0x77, 0x6b, 0x3a, 0x22, 0x1b, 0x43, 0x2e, 0x8f, 0x3a, + 0xe1, 0xf9, 0x6c, 0x18, 0xaf, 0xcf, 0xc2, 0x1d, 0x17, 0x79, 0xcf, 0x30, 0xb6, 0x7a, 0x4e, 0xd6, + 0x0b, 0xf2, 0xce, 0x74, 0x44, 0x6e, 0x3b, 0xf2, 0x6f, 0x2e, 0x8c, 0xd7, 0xac, 0xae, 0xa8, 0x04, + 0x2f, 0x73, 0x39, 0xfb, 0xb6, 0xdf, 0x68, 0x35, 0xa2, 0xf5, 0xed, 0x7b, 0xb4, 0x6c, 0x76, 0x56, + 0x7e, 0xd5, 0x29, 0xdd, 0xd5, 0x99, 0xea, 0x3e, 0x39, 0x1d, 0x91, 0xda, 0xd7, 0x1f, 0x24, 0x4a, + 0x33, 0x7b, 0x30, 0xe8, 0xd1, 0x44, 0x4b, 0x56, 0xf6, 0xea, 0x1e, 0x8f, 0x8d, 0x38, 0x64, 0x76, + 0xd8, 0x07, 0x53, 0x00, 0x26, 0x2e, 0xad, 0x3d, 0x8a, 0x57, 0x41, 0x89, 0x7d, 0x9b, 0x49, 0xf0, + 0x97, 0x5a, 0x28, 0x6a, 0x74, 0x37, 0xa6, 0x23, 0x72, 0xcb, 0x15, 0x56, 0x65, 0xc2, 0x78, 0x05, + 0x94, 0x78, 0x93, 0x49, 0xf0, 0x7c, 0xbc, 0x22, 0xe0, 0x88, 0x0f, 0x41, 0xf8, 0x37, 0x5a, 0x28, + 0x5a, 0x8d, 0xab, 0xb0, 0xb3, 0xf4, 0xeb, 0x33, 0x41, 0xe1, 0x03, 0x4c, 0x2e, 0x98, 0x60, 0x0c, + 0xa6, 0xaf, 0x95, 0x81, 0xf0, 0x37, 0x3a, 0xa7, 0x79, 0x0d, 0xb9, 0xe4, 0x0a, 0x94, 0x7d, 0xa5, + 0x93, 0x43, 0x10, 0xd7, 0x7b, 0xda, 0xe5, 0x8c, 0x1e, 0xe1, 0x87, 0x57, 0xf4, 0x5f, 0xcd, 0x6a, + 0xfb, 0x4b, 0x1d, 0x37, 0xf6, 0x4c, 0xea, 0x7d, 0x40, 0x78, 0x73, 0xe1, 0x6f, 0xc9, 0xe8, 0xe2, + 0x13, 0x40, 0x2f, 0xd8, 0x42, 0xf3, 0xf9, 0x3f, 0x02, 0x55, 0x29, 0xde, 0x27, 0x84, 0xef, 0x5f, + 0xba, 0xb3, 0xab, 0x9d, 0x17, 0x83, 0xcd, 0x17, 0xff, 0x09, 0x56, 0xa5, 0x75, 0x5f, 0x9e, 0x8e, + 0x03, 0x74, 0x36, 0x0e, 0xd0, 0xcf, 0x71, 0x80, 0x3e, 0x4e, 0x82, 0xda, 0xd9, 0x24, 0xa8, 0x7d, + 0x9f, 0x04, 0xb5, 0x77, 0xed, 0x4b, 0x57, 0x74, 0xc2, 0xf8, 0xc0, 0x1e, 0xcc, 0x6f, 0x97, 0x62, + 0x63, 0xbd, 0xe5, 0xe2, 0x2e, 0x78, 0xfa, 0x27, 0x00, 0x00, 0xff, 0xff, 0x30, 0x2a, 0x91, 0x89, + 0x7c, 0x04, 0x00, 0x00, } func (this *MsgCreateVestingAccount) Equal(that interface{}) bool { @@ -223,6 +330,41 @@ func (this *MsgCreateVestingAccount) Equal(that interface{}) bool { } return true } +func (this *MsgCreatePermanentLockedAccount) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgCreatePermanentLockedAccount) + if !ok { + that2, ok := that.(MsgCreatePermanentLockedAccount) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.FromAddress != that1.FromAddress { + return false + } + if this.ToAddress != that1.ToAddress { + return false + } + if len(this.Amount) != len(that1.Amount) { + return false + } + for i := range this.Amount { + if !this.Amount[i].Equal(&that1.Amount[i]) { + return false + } + } + return true +} // Reference imports to suppress errors if they are not otherwise used. var _ context.Context @@ -239,6 +381,9 @@ type MsgClient interface { // CreateVestingAccount defines a method that enables creating a vesting // account. CreateVestingAccount(ctx context.Context, in *MsgCreateVestingAccount, opts ...grpc.CallOption) (*MsgCreateVestingAccountResponse, error) + // CreatePermanentLockedAccount defines a method that enables creating a permanent + // locked account. + CreatePermanentLockedAccount(ctx context.Context, in *MsgCreatePermanentLockedAccount, opts ...grpc.CallOption) (*MsgCreatePermanentLockedAccountResponse, error) } type msgClient struct { @@ -258,11 +403,23 @@ func (c *msgClient) CreateVestingAccount(ctx context.Context, in *MsgCreateVesti return out, nil } +func (c *msgClient) CreatePermanentLockedAccount(ctx context.Context, in *MsgCreatePermanentLockedAccount, opts ...grpc.CallOption) (*MsgCreatePermanentLockedAccountResponse, error) { + out := new(MsgCreatePermanentLockedAccountResponse) + err := c.cc.Invoke(ctx, "/cosmos.vesting.v1beta1.Msg/CreatePermanentLockedAccount", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // CreateVestingAccount defines a method that enables creating a vesting // account. CreateVestingAccount(context.Context, *MsgCreateVestingAccount) (*MsgCreateVestingAccountResponse, error) + // CreatePermanentLockedAccount defines a method that enables creating a permanent + // locked account. + CreatePermanentLockedAccount(context.Context, *MsgCreatePermanentLockedAccount) (*MsgCreatePermanentLockedAccountResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -272,6 +429,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) CreateVestingAccount(ctx context.Context, req *MsgCreateVestingAccount) (*MsgCreateVestingAccountResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateVestingAccount not implemented") } +func (*UnimplementedMsgServer) CreatePermanentLockedAccount(ctx context.Context, req *MsgCreatePermanentLockedAccount) (*MsgCreatePermanentLockedAccountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreatePermanentLockedAccount not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -295,6 +455,24 @@ func _Msg_CreateVestingAccount_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_CreatePermanentLockedAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreatePermanentLockedAccount) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreatePermanentLockedAccount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.vesting.v1beta1.Msg/CreatePermanentLockedAccount", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreatePermanentLockedAccount(ctx, req.(*MsgCreatePermanentLockedAccount)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.vesting.v1beta1.Msg", HandlerType: (*MsgServer)(nil), @@ -303,6 +481,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CreateVestingAccount", Handler: _Msg_CreateVestingAccount_Handler, }, + { + MethodName: "CreatePermanentLockedAccount", + Handler: _Msg_CreatePermanentLockedAccount_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/vesting/v1beta1/tx.proto", @@ -397,6 +579,80 @@ func (m *MsgCreateVestingAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } +func (m *MsgCreatePermanentLockedAccount) 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 *MsgCreatePermanentLockedAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreatePermanentLockedAccount) 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 *MsgCreatePermanentLockedAccountResponse) 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 *MsgCreatePermanentLockedAccountResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreatePermanentLockedAccountResponse) 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 @@ -446,6 +702,38 @@ func (m *MsgCreateVestingAccountResponse) Size() (n int) { return n } +func (m *MsgCreatePermanentLockedAccount) 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 *MsgCreatePermanentLockedAccountResponse) 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 } @@ -689,6 +977,204 @@ func (m *MsgCreateVestingAccountResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgCreatePermanentLockedAccount) 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: MsgCreatePermanentLockedAccount: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreatePermanentLockedAccount: 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 + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreatePermanentLockedAccountResponse) 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: MsgCreatePermanentLockedAccountResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreatePermanentLockedAccountResponse: 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 From 717d11869ab20c63f7bad4bf429d7d714e75761a Mon Sep 17 00:00:00 2001 From: Cory Levinson Date: Mon, 9 Aug 2021 18:21:21 -0700 Subject: [PATCH 2/9] run lint-fix --- docs/core/upgrade.md | 2 +- x/auth/vesting/client/cli/tx.go | 1 + x/auth/vesting/client/testutil/suite.go | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/core/upgrade.md b/docs/core/upgrade.md index 717013b7c4c..145615408a1 100644 --- a/docs/core/upgrade.md +++ b/docs/core/upgrade.md @@ -95,7 +95,7 @@ if err != nil { if upgradeInfo.Name == "my-plan" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { storeUpgrades := storetypes.StoreUpgrades{ // add store upgrades for new modules - // Example: + // Example: // Added: []string{"foo", "bar"}, // ... } diff --git a/x/auth/vesting/client/cli/tx.go b/x/auth/vesting/client/cli/tx.go index 1e1d13d338e..1ed647c321b 100644 --- a/x/auth/vesting/client/cli/tx.go +++ b/x/auth/vesting/client/cli/tx.go @@ -80,6 +80,7 @@ timestamp.`, return cmd } + // NewMsgCreatePermanentLockedAccountCmd returns a CLI command handler for creating a // MsgCreatePermanentLockedAccount transaction. func NewMsgCreatePermanentLockedAccountCmd() *cobra.Command { diff --git a/x/auth/vesting/client/testutil/suite.go b/x/auth/vesting/client/testutil/suite.go index 7a7ddb6da1c..d447720007c 100644 --- a/x/auth/vesting/client/testutil/suite.go +++ b/x/auth/vesting/client/testutil/suite.go @@ -115,7 +115,7 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { tc := tc s.Run(name, func() { - clientCtx := val.ClientCtx + clientCtx := val.ClientCtx bw, err := clitestutil.ExecTestCLICmd(clientCtx, cli.NewMsgCreateVestingAccountCmd(), tc.args) if tc.expectErr { @@ -127,7 +127,7 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code) } - }) + }) } } func (s *IntegrationTestSuite) TestNewMsgCreatePermanentLockedAccountCmd() { From 2be6cfdc26bbbfaadac61d623052e39a6a517f02 Mon Sep 17 00:00:00 2001 From: Cory Levinson Date: Mon, 9 Aug 2021 21:18:44 -0700 Subject: [PATCH 3/9] lint fix --- x/auth/vesting/msg_server.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x/auth/vesting/msg_server.go b/x/auth/vesting/msg_server.go index 6154695fbf7..fc125e60f25 100644 --- a/x/auth/vesting/msg_server.go +++ b/x/auth/vesting/msg_server.go @@ -131,8 +131,7 @@ func (s msgServer) CreatePermanentLockedAccount(goCtx context.Context, msg *type return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid account type; expected: BaseAccount, got: %T", baseAccountI) } - var acc authtypes.AccountI - acc = types.NewPermanentLockedAccount(baseAcc, msg.Amount) + var acc authtypes.AccountI = types.NewPermanentLockedAccount(baseAcc, msg.Amount) ak.SetAccount(ctx, acc) From e05955e2946f1e4c65ce4e782651457dd8dae1e7 Mon Sep 17 00:00:00 2001 From: Cory Levinson Date: Wed, 11 Aug 2021 19:44:34 -0700 Subject: [PATCH 4/9] add LegacyAmino codec registration for MsgCreateVestingAccount & MsgCreatePermanentLockedAccount --- x/auth/vesting/types/codec.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/auth/vesting/types/codec.go b/x/auth/vesting/types/codec.go index c5f33d891d5..6cd11a27b56 100644 --- a/x/auth/vesting/types/codec.go +++ b/x/auth/vesting/types/codec.go @@ -18,6 +18,8 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&DelayedVestingAccount{}, "cosmos-sdk/DelayedVestingAccount", nil) cdc.RegisterConcrete(&PeriodicVestingAccount{}, "cosmos-sdk/PeriodicVestingAccount", nil) cdc.RegisterConcrete(&PermanentLockedAccount{}, "cosmos-sdk/PermanentLockedAccount", nil) + cdc.RegisterConcrete(&MsgCreateVestingAccount{}, "cosmos-sdk/MsgCreateVestingAccount", nil) + cdc.RegisterConcrete(&MsgCreatePermanentLockedAccount{}, "cosmos-sdk/MsgCreatePermLockedAccount", nil) } // RegisterInterface associates protoName with AccountI and VestingAccount From 48b6e625ea2f49a874065e80c45350a005ccfa6f Mon Sep 17 00:00:00 2001 From: Cory Levinson Date: Wed, 11 Aug 2021 20:57:19 -0700 Subject: [PATCH 5/9] update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbbbeee9c48..a4414974081 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,13 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog +## v0.43.0-regen-1 + +## Features + +- [#42](https://github.com/regen-network/cosmos-sdk/pull/42) Add `MsgCreatePermanentLockedAccount` and CLI method +for creating permanent locked account + ## [Unreleased] ### Client-Breaking Changes From e8a40de65dda351ecd5695f47add5a3fc421eb76 Mon Sep 17 00:00:00 2001 From: Cory Date: Thu, 12 Aug 2021 11:22:38 -0700 Subject: [PATCH 6/9] Update CHANGELOG.md Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5e9e270b50..aa92f6a6d7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog -<<<<<<< HEAD ## v0.43.0-regen-1 ### Features From 601f2ac8f25dd3a7d8ea030d804a2d71f12dd9f7 Mon Sep 17 00:00:00 2001 From: Cory Date: Mon, 16 Aug 2021 15:16:59 -0700 Subject: [PATCH 7/9] Update x/auth/vesting/types/msgs.go Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> --- x/auth/vesting/types/msgs.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/x/auth/vesting/types/msgs.go b/x/auth/vesting/types/msgs.go index e777a6aa198..904f9aa2314 100644 --- a/x/auth/vesting/types/msgs.go +++ b/x/auth/vesting/types/msgs.go @@ -99,20 +99,11 @@ func (msg MsgCreatePermanentLockedAccount) Type() string { return TypeMsgCreateP // ValidateBasic Implements Msg. func (msg MsgCreatePermanentLockedAccount) ValidateBasic() error { - from, err := sdk.AccAddressFromBech32(msg.FromAddress) - if err != nil { - return err - } - to, err := sdk.AccAddressFromBech32(msg.ToAddress) - if err != nil { - return err + if _, err := sdk.AccAddressFromBech32(msg.FromAddress); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address: %s", err) } - if err := sdk.VerifyAddressFormat(from); err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address: %s", err) - } - - if err := sdk.VerifyAddressFormat(to); err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid recipient address: %s", err) + if _, err := sdk.AccAddressFromBech32(msg.ToAddress); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid recipient address: %s", err) } if !msg.Amount.IsValid() { From 590b983cc3f6c5b3d33dc86ff940139f1361443c Mon Sep 17 00:00:00 2001 From: Cory Date: Mon, 16 Aug 2021 15:29:16 -0700 Subject: [PATCH 8/9] Update x/auth/vesting/types/msgs.go Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> --- x/auth/vesting/types/msgs.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x/auth/vesting/types/msgs.go b/x/auth/vesting/types/msgs.go index 904f9aa2314..6fb726aaea5 100644 --- a/x/auth/vesting/types/msgs.go +++ b/x/auth/vesting/types/msgs.go @@ -125,9 +125,6 @@ func (msg MsgCreatePermanentLockedAccount) GetSignBytes() []byte { // GetSigners returns the expected signers for a MsgCreatePermanentLockedAccount. func (msg MsgCreatePermanentLockedAccount) GetSigners() []sdk.AccAddress { - from, err := sdk.AccAddressFromBech32(msg.FromAddress) - if err != nil { - panic(err) - } + from, _ := sdk.AccAddressFromBech32(msg.FromAddress) return []sdk.AccAddress{from} } From 70b40b4b033b3a27a9d201ab68b07f68e39fbc1b Mon Sep 17 00:00:00 2001 From: Cory Levinson Date: Mon, 16 Aug 2021 15:47:37 -0700 Subject: [PATCH 9/9] gofmt --- x/auth/vesting/types/msgs.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/auth/vesting/types/msgs.go b/x/auth/vesting/types/msgs.go index 6fb726aaea5..a34e9ed63c8 100644 --- a/x/auth/vesting/types/msgs.go +++ b/x/auth/vesting/types/msgs.go @@ -100,10 +100,10 @@ func (msg MsgCreatePermanentLockedAccount) Type() string { return TypeMsgCreateP // ValidateBasic Implements Msg. func (msg MsgCreatePermanentLockedAccount) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.FromAddress); err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address: %s", err) + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address: %s", err) } if _, err := sdk.AccAddressFromBech32(msg.ToAddress); err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid recipient address: %s", err) + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid recipient address: %s", err) } if !msg.Amount.IsValid() {