From e24324d6386216c6185deb3188ca6c581683962f Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Thu, 11 Apr 2024 14:19:35 +0700 Subject: [PATCH 01/22] use branch service --- x/accounts/defaults/lockup/lockup.go | 168 +++++++++++++++++---------- 1 file changed, 106 insertions(+), 62 deletions(-) diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index 71e7687c842..9a85be2236d 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -11,6 +11,7 @@ import ( "cosmossdk.io/collections" collcodec "cosmossdk.io/collections/codec" "cosmossdk.io/core/address" + "cosmossdk.io/core/branch" "cosmossdk.io/core/header" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" @@ -53,6 +54,7 @@ func newBaseLockup(d accountstd.Dependencies) *BaseLockup { WithdrawedCoins: collections.NewMap(d.SchemaBuilder, WithdrawedCoinsPrefix, "withdrawed_coins", collections.StringKey, sdk.IntValue), addressCodec: d.AddressCodec, headerService: d.Environment.HeaderService, + branchService: d.Environment.BranchService, EndTime: collections.NewItem(d.SchemaBuilder, EndTimePrefix, "end_time", collcodec.KeyToValueCodec[time.Time](sdk.TimeKey)), } @@ -66,6 +68,7 @@ type BaseLockup struct { DelegatedFree collections.Map[string, math.Int] DelegatedLocking collections.Map[string, math.Int] WithdrawedCoins collections.Map[string, math.Int] + branchService branch.Service addressCodec address.Codec headerService header.Service // lockup end time. @@ -146,18 +149,29 @@ func (bva *BaseLockup) Delegate( return nil, err } - err = bva.TrackDelegation( - ctx, - sdk.Coins{*balance}, - lockedCoins, - sdk.Coins{msg.Amount}, - ) - if err != nil { - return nil, err - } + responses := []*codectypes.Any{} + + err = bva.branchService.Execute(ctx, func(ctx context.Context) error { + err = bva.TrackDelegation( + ctx, + sdk.Coins{*balance}, + lockedCoins, + sdk.Coins{msg.Amount}, + ) + if err != nil { + return err + } + + msgDelegate := makeMsgDelegate(delegatorAddress, msg.ValidatorAddress, msg.Amount) + resp, err := sendMessage(ctx, msgDelegate) + if err != nil { + return err + } - msgDelegate := makeMsgDelegate(delegatorAddress, msg.ValidatorAddress, msg.Amount) - responses, err := sendMessage(ctx, msgDelegate) + responses = append(responses, resp...) + + return nil + }) if err != nil { return nil, err } @@ -180,13 +194,24 @@ func (bva *BaseLockup) Undelegate( return nil, err } - err = bva.TrackUndelegation(ctx, sdk.Coins{msg.Amount}) - if err != nil { - return nil, err - } + responses := []*codectypes.Any{} - msgUndelegate := makeMsgUndelegate(delegatorAddress, msg.ValidatorAddress, msg.Amount) - responses, err := sendMessage(ctx, msgUndelegate) + err = bva.branchService.Execute(ctx, func(ctx context.Context) error { + err = bva.TrackUndelegation(ctx, sdk.Coins{msg.Amount}) + if err != nil { + return err + } + + msgUndelegate := makeMsgUndelegate(delegatorAddress, msg.ValidatorAddress, msg.Amount) + resp, err := sendMessage(ctx, msgUndelegate) + if err != nil { + return err + } + + responses = append(responses, resp...) + + return nil + }) if err != nil { return nil, err } @@ -221,8 +246,19 @@ func (bva *BaseLockup) SendCoins( return nil, err } - msgSend := makeMsgSend(fromAddress, msg.ToAddress, msg.Amount) - responses, err := sendMessage(ctx, msgSend) + responses := []*codectypes.Any{} + + err = bva.branchService.Execute(ctx, func(ctx context.Context) error { + msgSend := makeMsgSend(fromAddress, msg.ToAddress, msg.Amount) + resp, err := sendMessage(ctx, msgSend) + if err != nil { + return err + } + + responses = append(responses, resp...) + + return nil + }) if err != nil { return nil, err } @@ -254,59 +290,67 @@ func (bva *BaseLockup) WithdrawUnlockedCoins( } amount := sdk.Coins{} - for _, denom := range msg.Denoms { - balance, err := bva.getBalance(ctx, fromAddress, denom) - if err != nil { - return nil, err - } - lockedAmt := lockedCoins.AmountOf(denom) - // get lockedCoin from that are not bonded for the sent denom - notBondedLockedCoin, err := bva.GetNotBondedLockedCoin(ctx, sdk.NewCoin(denom, lockedAmt), denom) - if err != nil { - return nil, err - } + err = bva.branchService.Execute(ctx, func(ctx context.Context) error { + for _, denom := range msg.Denoms { + balance, err := bva.getBalance(ctx, fromAddress, denom) + if err != nil { + return err + } + lockedAmt := lockedCoins.AmountOf(denom) - spendable, err := balance.SafeSub(notBondedLockedCoin) - if err != nil { - return nil, errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, - "locked amount exceeds account balance funds: %s > %s", notBondedLockedCoin, balance) - } + // get lockedCoin from that are not bonded for the sent denom + notBondedLockedCoin, err := bva.GetNotBondedLockedCoin(ctx, sdk.NewCoin(denom, lockedAmt), denom) + if err != nil { + return err + } - withdrawedAmt, err := bva.WithdrawedCoins.Get(ctx, denom) - if err != nil { - return nil, err - } - originalLockingAmt, err := bva.OriginalLocking.Get(ctx, denom) - if err != nil { - return nil, err - } + spendable, err := balance.SafeSub(notBondedLockedCoin) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, + "locked amount exceeds account balance funds: %s > %s", notBondedLockedCoin, balance) + } - // withdrawable amount is equal to original locking amount subtract already withdrawed amount - withdrawableAmt, err := originalLockingAmt.SafeSub(withdrawedAmt) - if err != nil { - return nil, err - } + withdrawedAmt, err := bva.WithdrawedCoins.Get(ctx, denom) + if err != nil { + return err + } + originalLockingAmt, err := bva.OriginalLocking.Get(ctx, denom) + if err != nil { + return err + } + + // withdrawable amount is equal to original locking amount subtract already withdrawed amount + withdrawableAmt, err := originalLockingAmt.SafeSub(withdrawedAmt) + if err != nil { + return err + } + + withdrawAmt := math.MinInt(withdrawableAmt, spendable.Amount) + // if zero amount go to the next iteration + if withdrawAmt.IsZero() { + continue + } + amount = append(amount, sdk.NewCoin(denom, withdrawAmt)) - withdrawAmt := math.MinInt(withdrawableAmt, spendable.Amount) - // if zero amount go to the next iteration - if withdrawAmt.IsZero() { - continue + // update the withdrawed amount + err = bva.WithdrawedCoins.Set(ctx, denom, withdrawedAmt.Add(withdrawAmt)) + if err != nil { + return err + } + } + if len(amount) == 0 { + return fmt.Errorf("no tokens available for withdrawing") } - amount = append(amount, sdk.NewCoin(denom, withdrawAmt)) - // update the withdrawed amount - err = bva.WithdrawedCoins.Set(ctx, denom, withdrawedAmt.Add(withdrawAmt)) + msgSend := makeMsgSend(fromAddress, msg.ToAddress, amount) + _, err = sendMessage(ctx, msgSend) if err != nil { - return nil, err + return err } - } - if len(amount) == 0 { - return nil, fmt.Errorf("no tokens available for withdrawing") - } - msgSend := makeMsgSend(fromAddress, msg.ToAddress, amount) - _, err = sendMessage(ctx, msgSend) + return nil + }) if err != nil { return nil, err } From d58b8587d9d5c176e35a4b9bd6a28faecdfa7817 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Thu, 11 Apr 2024 14:37:02 +0700 Subject: [PATCH 02/22] add withdraw reward --- .../accounts/defaults/lockup/tx.pulsar.go | 748 +++++++++++++++--- .../lockup/continuous_locking_account.go | 7 + .../lockup/delayed_locking_account.go | 7 + x/accounts/defaults/lockup/go.mod | 3 + x/accounts/defaults/lockup/lockup.go | 39 + .../lockup/periodic_locking_account.go | 7 + .../lockup/permanent_locking_account.go | 7 + x/accounts/defaults/lockup/types/tx.pb.go | 319 ++++++-- .../cosmos/accounts/defaults/lockup/tx.proto | 11 + 9 files changed, 995 insertions(+), 153 deletions(-) diff --git a/api/cosmos/accounts/defaults/lockup/tx.pulsar.go b/api/cosmos/accounts/defaults/lockup/tx.pulsar.go index 082db8883c5..2786e8373a3 100644 --- a/api/cosmos/accounts/defaults/lockup/tx.pulsar.go +++ b/api/cosmos/accounts/defaults/lockup/tx.pulsar.go @@ -3072,6 +3072,490 @@ func (x *fastReflection_MsgUndelegate) ProtoMethods() *protoiface.Methods { } } +var ( + md_MsgWithdrawReward protoreflect.MessageDescriptor + fd_MsgWithdrawReward_sender protoreflect.FieldDescriptor + fd_MsgWithdrawReward_validator_address protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_accounts_defaults_lockup_tx_proto_init() + md_MsgWithdrawReward = File_cosmos_accounts_defaults_lockup_tx_proto.Messages().ByName("MsgWithdrawReward") + fd_MsgWithdrawReward_sender = md_MsgWithdrawReward.Fields().ByName("sender") + fd_MsgWithdrawReward_validator_address = md_MsgWithdrawReward.Fields().ByName("validator_address") +} + +var _ protoreflect.Message = (*fastReflection_MsgWithdrawReward)(nil) + +type fastReflection_MsgWithdrawReward MsgWithdrawReward + +func (x *MsgWithdrawReward) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgWithdrawReward)(x) +} + +func (x *MsgWithdrawReward) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_MsgWithdrawReward_messageType fastReflection_MsgWithdrawReward_messageType +var _ protoreflect.MessageType = fastReflection_MsgWithdrawReward_messageType{} + +type fastReflection_MsgWithdrawReward_messageType struct{} + +func (x fastReflection_MsgWithdrawReward_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgWithdrawReward)(nil) +} +func (x fastReflection_MsgWithdrawReward_messageType) New() protoreflect.Message { + return new(fastReflection_MsgWithdrawReward) +} +func (x fastReflection_MsgWithdrawReward_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgWithdrawReward +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgWithdrawReward) Descriptor() protoreflect.MessageDescriptor { + return md_MsgWithdrawReward +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_MsgWithdrawReward) Type() protoreflect.MessageType { + return _fastReflection_MsgWithdrawReward_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgWithdrawReward) New() protoreflect.Message { + return new(fastReflection_MsgWithdrawReward) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgWithdrawReward) Interface() protoreflect.ProtoMessage { + return (*MsgWithdrawReward)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_MsgWithdrawReward) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Sender != "" { + value := protoreflect.ValueOfString(x.Sender) + if !f(fd_MsgWithdrawReward_sender, value) { + return + } + } + if x.ValidatorAddress != "" { + value := protoreflect.ValueOfString(x.ValidatorAddress) + if !f(fd_MsgWithdrawReward_validator_address, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_MsgWithdrawReward) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + return x.Sender != "" + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + return x.ValidatorAddress != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgWithdrawReward) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + x.Sender = "" + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + x.ValidatorAddress = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_MsgWithdrawReward) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + value := x.Sender + return protoreflect.ValueOfString(value) + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + value := x.ValidatorAddress + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgWithdrawReward) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + x.Sender = value.Interface().(string) + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + x.ValidatorAddress = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgWithdrawReward) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + panic(fmt.Errorf("field sender of message cosmos.accounts.defaults.lockup.MsgWithdrawReward is not mutable")) + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + panic(fmt.Errorf("field validator_address of message cosmos.accounts.defaults.lockup.MsgWithdrawReward is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_MsgWithdrawReward) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + return protoreflect.ValueOfString("") + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_MsgWithdrawReward) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.defaults.lockup.MsgWithdrawReward", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_MsgWithdrawReward) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgWithdrawReward) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_MsgWithdrawReward) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_MsgWithdrawReward) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgWithdrawReward) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Sender) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.ValidatorAddress) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgWithdrawReward) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.ValidatorAddress) > 0 { + i -= len(x.ValidatorAddress) + copy(dAtA[i:], x.ValidatorAddress) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(x.Sender) > 0 { + i -= len(x.Sender) + copy(dAtA[i:], x.Sender) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Sender))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*MsgWithdrawReward) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgWithdrawReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgWithdrawReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + var _ protoreflect.List = (*_MsgSend_3_list)(nil) type _MsgSend_3_list struct { @@ -3147,7 +3631,7 @@ func (x *MsgSend) ProtoReflect() protoreflect.Message { } func (x *MsgSend) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3765,7 +4249,7 @@ func (x *MsgExecuteMessagesResponse) ProtoReflect() protoreflect.Message { } func (x *MsgExecuteMessagesResponse) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4258,7 +4742,7 @@ func (x *MsgWithdraw) ProtoReflect() protoreflect.Message { } func (x *MsgWithdraw) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4869,7 +5353,7 @@ func (x *MsgWithdrawResponse) ProtoReflect() protoreflect.Message { } func (x *MsgWithdrawResponse) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -5638,6 +6122,50 @@ func (x *MsgUndelegate) GetAmount() *v1beta1.Coin { return nil } +// MsgWithdrawReward defines a message that enable lockup account to withdraw staking reward +type MsgWithdrawReward struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` +} + +func (x *MsgWithdrawReward) Reset() { + *x = MsgWithdrawReward{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgWithdrawReward) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgWithdrawReward) ProtoMessage() {} + +// Deprecated: Use MsgWithdrawReward.ProtoReflect.Descriptor instead. +func (*MsgWithdrawReward) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{6} +} + +func (x *MsgWithdrawReward) GetSender() string { + if x != nil { + return x.Sender + } + return "" +} + +func (x *MsgWithdrawReward) GetValidatorAddress() string { + if x != nil { + return x.ValidatorAddress + } + return "" +} + // MsgSend defines a message that enable lockup account to execute send message type MsgSend struct { state protoimpl.MessageState @@ -5652,7 +6180,7 @@ type MsgSend struct { func (x *MsgSend) Reset() { *x = MsgSend{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5666,7 +6194,7 @@ func (*MsgSend) ProtoMessage() {} // Deprecated: Use MsgSend.ProtoReflect.Descriptor instead. func (*MsgSend) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{6} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{7} } func (x *MsgSend) GetSender() string { @@ -5702,7 +6230,7 @@ type MsgExecuteMessagesResponse struct { func (x *MsgExecuteMessagesResponse) Reset() { *x = MsgExecuteMessagesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5716,7 +6244,7 @@ func (*MsgExecuteMessagesResponse) ProtoMessage() {} // Deprecated: Use MsgExecuteMessagesResponse.ProtoReflect.Descriptor instead. func (*MsgExecuteMessagesResponse) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{7} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{8} } func (x *MsgExecuteMessagesResponse) GetResponses() []*anypb.Any { @@ -5741,7 +6269,7 @@ type MsgWithdraw struct { func (x *MsgWithdraw) Reset() { *x = MsgWithdraw{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5755,7 +6283,7 @@ func (*MsgWithdraw) ProtoMessage() {} // Deprecated: Use MsgWithdraw.ProtoReflect.Descriptor instead. func (*MsgWithdraw) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{8} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{9} } func (x *MsgWithdraw) GetWithdrawer() string { @@ -5792,7 +6320,7 @@ type MsgWithdrawResponse struct { func (x *MsgWithdrawResponse) Reset() { *x = MsgWithdrawResponse{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5806,7 +6334,7 @@ func (*MsgWithdrawResponse) ProtoMessage() {} // Deprecated: Use MsgWithdrawResponse.ProtoReflect.Descriptor instead. func (*MsgWithdrawResponse) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{9} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{10} } func (x *MsgWithdrawResponse) GetReceiver() string { @@ -5913,70 +6441,81 @@ var file_cosmos_accounts_defaults_lockup_tx_proto_rawDesc = []byte{ 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x13, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x65, 0x6e, - 0x64, 0x65, 0x72, 0x22, 0x84, 0x02, 0x0a, 0x07, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x6e, 0x64, 0x12, - 0x30, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, - 0x72, 0x12, 0x37, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, - 0x09, 0x74, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x79, 0x0a, 0x06, 0x61, 0x6d, - 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, - 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, - 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, - 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x13, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, - 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x1a, 0x4d, 0x73, - 0x67, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, - 0x79, 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0xb1, 0x01, 0x0a, - 0x0b, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x12, 0x38, 0x0a, 0x0a, - 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x0a, 0x77, 0x69, 0x74, 0x68, - 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x74, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, - 0x16, 0x0a, 0x06, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x06, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x73, 0x3a, 0x17, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, - 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x0a, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, - 0x22, 0xd8, 0x01, 0x0a, 0x13, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, - 0x69, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x12, 0x8a, - 0x01, 0x0a, 0x0f, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, - 0x65, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, - 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, - 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, - 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0e, 0x61, 0x6d, 0x6f, - 0x75, 0x6e, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x42, 0x80, 0x02, 0x0a, 0x23, - 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x73, 0x2e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x6c, 0x6f, 0x63, - 0x6b, 0x75, 0x70, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, - 0x2f, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2f, 0x6c, 0x6f, 0x63, 0x6b, 0x75, 0x70, - 0xa2, 0x02, 0x04, 0x43, 0x41, 0x44, 0x4c, 0xaa, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, - 0x74, 0x73, 0x2e, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xca, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xe2, 0x02, 0x2b, 0x43, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, - 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x22, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, 0x44, 0x65, - 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x3a, 0x3a, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x65, 0x72, 0x22, 0xaa, 0x01, 0x0a, 0x11, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, + 0x72, 0x61, 0x77, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x12, 0x30, 0x0a, 0x06, 0x73, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x4e, 0x0a, 0x11, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x21, 0xd2, 0xb4, 0x2d, 0x1d, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x3a, 0x13, 0x88, 0xa0, 0x1f, + 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, + 0x22, 0x84, 0x02, 0x0a, 0x07, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x6e, 0x64, 0x12, 0x30, 0x0a, 0x06, + 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, + 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x37, + 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x74, 0x6f, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x79, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, + 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, + 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, + 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, + 0x6e, 0x74, 0x3a, 0x13, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, + 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x1a, 0x4d, 0x73, 0x67, 0x45, 0x78, + 0x65, 0x63, 0x75, 0x74, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x09, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0xb1, 0x01, 0x0a, 0x0b, 0x4d, 0x73, + 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x12, 0x38, 0x0a, 0x0a, 0x77, 0x69, 0x74, + 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, + 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x0a, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, + 0x77, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x52, 0x09, 0x74, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, + 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x64, 0x65, + 0x6e, 0x6f, 0x6d, 0x73, 0x3a, 0x17, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, + 0xb0, 0x2a, 0x0a, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x22, 0xd8, 0x01, + 0x0a, 0x13, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x12, 0x8a, 0x01, 0x0a, 0x0f, + 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, + 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, + 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, + 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x63, 0x6f, + 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0e, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x42, 0x80, 0x02, 0x0a, 0x23, 0x63, 0x6f, 0x6d, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, + 0x2e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x75, 0x70, + 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x64, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2f, 0x6c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xa2, 0x02, 0x04, + 0x43, 0x41, 0x44, 0x4c, 0xaa, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, + 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xca, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, + 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xe2, 0x02, 0x2b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x22, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, + 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, 0x44, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x73, 0x3a, 0x3a, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -5991,7 +6530,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP() []byte { return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescData } -var file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_cosmos_accounts_defaults_lockup_tx_proto_goTypes = []interface{}{ (*MsgInitLockupAccount)(nil), // 0: cosmos.accounts.defaults.lockup.MsgInitLockupAccount (*MsgInitLockupAccountResponse)(nil), // 1: cosmos.accounts.defaults.lockup.MsgInitLockupAccountResponse @@ -5999,25 +6538,26 @@ var file_cosmos_accounts_defaults_lockup_tx_proto_goTypes = []interface{}{ (*MsgInitPeriodicLockingAccountResponse)(nil), // 3: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccountResponse (*MsgDelegate)(nil), // 4: cosmos.accounts.defaults.lockup.MsgDelegate (*MsgUndelegate)(nil), // 5: cosmos.accounts.defaults.lockup.MsgUndelegate - (*MsgSend)(nil), // 6: cosmos.accounts.defaults.lockup.MsgSend - (*MsgExecuteMessagesResponse)(nil), // 7: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse - (*MsgWithdraw)(nil), // 8: cosmos.accounts.defaults.lockup.MsgWithdraw - (*MsgWithdrawResponse)(nil), // 9: cosmos.accounts.defaults.lockup.MsgWithdrawResponse - (*timestamppb.Timestamp)(nil), // 10: google.protobuf.Timestamp - (*Period)(nil), // 11: cosmos.accounts.defaults.lockup.Period - (*v1beta1.Coin)(nil), // 12: cosmos.base.v1beta1.Coin - (*anypb.Any)(nil), // 13: google.protobuf.Any + (*MsgWithdrawReward)(nil), // 6: cosmos.accounts.defaults.lockup.MsgWithdrawReward + (*MsgSend)(nil), // 7: cosmos.accounts.defaults.lockup.MsgSend + (*MsgExecuteMessagesResponse)(nil), // 8: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse + (*MsgWithdraw)(nil), // 9: cosmos.accounts.defaults.lockup.MsgWithdraw + (*MsgWithdrawResponse)(nil), // 10: cosmos.accounts.defaults.lockup.MsgWithdrawResponse + (*timestamppb.Timestamp)(nil), // 11: google.protobuf.Timestamp + (*Period)(nil), // 12: cosmos.accounts.defaults.lockup.Period + (*v1beta1.Coin)(nil), // 13: cosmos.base.v1beta1.Coin + (*anypb.Any)(nil), // 14: google.protobuf.Any } var file_cosmos_accounts_defaults_lockup_tx_proto_depIdxs = []int32{ - 10, // 0: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.end_time:type_name -> google.protobuf.Timestamp - 10, // 1: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.start_time:type_name -> google.protobuf.Timestamp - 10, // 2: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.start_time:type_name -> google.protobuf.Timestamp - 11, // 3: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.locking_periods:type_name -> cosmos.accounts.defaults.lockup.Period - 12, // 4: cosmos.accounts.defaults.lockup.MsgDelegate.amount:type_name -> cosmos.base.v1beta1.Coin - 12, // 5: cosmos.accounts.defaults.lockup.MsgUndelegate.amount:type_name -> cosmos.base.v1beta1.Coin - 12, // 6: cosmos.accounts.defaults.lockup.MsgSend.amount:type_name -> cosmos.base.v1beta1.Coin - 13, // 7: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse.responses:type_name -> google.protobuf.Any - 12, // 8: cosmos.accounts.defaults.lockup.MsgWithdrawResponse.amount_received:type_name -> cosmos.base.v1beta1.Coin + 11, // 0: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.end_time:type_name -> google.protobuf.Timestamp + 11, // 1: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.start_time:type_name -> google.protobuf.Timestamp + 11, // 2: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.start_time:type_name -> google.protobuf.Timestamp + 12, // 3: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.locking_periods:type_name -> cosmos.accounts.defaults.lockup.Period + 13, // 4: cosmos.accounts.defaults.lockup.MsgDelegate.amount:type_name -> cosmos.base.v1beta1.Coin + 13, // 5: cosmos.accounts.defaults.lockup.MsgUndelegate.amount:type_name -> cosmos.base.v1beta1.Coin + 13, // 6: cosmos.accounts.defaults.lockup.MsgSend.amount:type_name -> cosmos.base.v1beta1.Coin + 14, // 7: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse.responses:type_name -> google.protobuf.Any + 13, // 8: cosmos.accounts.defaults.lockup.MsgWithdrawResponse.amount_received:type_name -> cosmos.base.v1beta1.Coin 9, // [9:9] is the sub-list for method output_type 9, // [9:9] is the sub-list for method input_type 9, // [9:9] is the sub-list for extension type_name @@ -6105,7 +6645,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { } } file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MsgSend); i { + switch v := v.(*MsgWithdrawReward); i { case 0: return &v.state case 1: @@ -6117,7 +6657,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { } } file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MsgExecuteMessagesResponse); i { + switch v := v.(*MsgSend); i { case 0: return &v.state case 1: @@ -6129,7 +6669,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { } } file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MsgWithdraw); i { + switch v := v.(*MsgExecuteMessagesResponse); i { case 0: return &v.state case 1: @@ -6141,6 +6681,18 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { } } file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgWithdraw); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MsgWithdrawResponse); i { case 0: return &v.state @@ -6159,7 +6711,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_accounts_defaults_lockup_tx_proto_rawDesc, NumEnums: 0, - NumMessages: 10, + NumMessages: 11, NumExtensions: 0, NumServices: 0, }, diff --git a/x/accounts/defaults/lockup/continuous_locking_account.go b/x/accounts/defaults/lockup/continuous_locking_account.go index c38a48d4ee0..a5917b73e4a 100644 --- a/x/accounts/defaults/lockup/continuous_locking_account.go +++ b/x/accounts/defaults/lockup/continuous_locking_account.go @@ -72,6 +72,12 @@ func (cva *ContinuousLockingAccount) Undelegate(ctx context.Context, msg *lockup return cva.BaseLockup.Undelegate(ctx, msg) } +func (cva *ContinuousLockingAccount) WithdrawReward(ctx context.Context, msg *lockuptypes.MsgWithdrawReward) ( + *lockuptypes.MsgExecuteMessagesResponse, error, +) { + return cva.BaseLockup.WithdrawReward(ctx, msg) +} + func (cva *ContinuousLockingAccount) SendCoins(ctx context.Context, msg *lockuptypes.MsgSend) ( *lockuptypes.MsgExecuteMessagesResponse, error, ) { @@ -217,6 +223,7 @@ func (cva ContinuousLockingAccount) RegisterExecuteHandlers(builder *accountstd. accountstd.RegisterExecuteHandler(builder, cva.Delegate) accountstd.RegisterExecuteHandler(builder, cva.Undelegate) accountstd.RegisterExecuteHandler(builder, cva.SendCoins) + accountstd.RegisterExecuteHandler(builder, cva.WithdrawReward) accountstd.RegisterExecuteHandler(builder, cva.WithdrawUnlockedCoins) } diff --git a/x/accounts/defaults/lockup/delayed_locking_account.go b/x/accounts/defaults/lockup/delayed_locking_account.go index dbc19d96008..f5bd455e7db 100644 --- a/x/accounts/defaults/lockup/delayed_locking_account.go +++ b/x/accounts/defaults/lockup/delayed_locking_account.go @@ -49,6 +49,12 @@ func (dva *DelayedLockingAccount) Undelegate(ctx context.Context, msg *lockuptyp return dva.BaseLockup.Undelegate(ctx, msg) } +func (dva *DelayedLockingAccount) WithdrawReward(ctx context.Context, msg *lockuptypes.MsgWithdrawReward) ( + *lockuptypes.MsgExecuteMessagesResponse, error, +) { + return dva.BaseLockup.WithdrawReward(ctx, msg) +} + func (dva *DelayedLockingAccount) SendCoins(ctx context.Context, msg *lockuptypes.MsgSend) ( *lockuptypes.MsgExecuteMessagesResponse, error, ) { @@ -149,6 +155,7 @@ func (dva DelayedLockingAccount) RegisterInitHandler(builder *accountstd.InitBui func (dva DelayedLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, dva.Delegate) accountstd.RegisterExecuteHandler(builder, dva.Undelegate) + accountstd.RegisterExecuteHandler(builder, dva.WithdrawReward) accountstd.RegisterExecuteHandler(builder, dva.SendCoins) accountstd.RegisterExecuteHandler(builder, dva.WithdrawUnlockedCoins) } diff --git a/x/accounts/defaults/lockup/go.mod b/x/accounts/defaults/lockup/go.mod index ca699d48ebd..1e5b80b38c4 100644 --- a/x/accounts/defaults/lockup/go.mod +++ b/x/accounts/defaults/lockup/go.mod @@ -11,6 +11,8 @@ require ( github.com/cosmos/gogoproto v1.4.12 ) +require cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect + require ( buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.32.0-20240130113600-88ef6483f90f.1 // indirect buf.build/gen/go/tendermint/tendermint/protocolbuffers/go v1.32.0-20231117195010-33ed361a9051.1 // indirect @@ -20,6 +22,7 @@ require ( cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.0.2 // indirect cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 // indirect + cosmossdk.io/x/distribution v0.0.0-20240410222740-c56152dfac35 cosmossdk.io/x/tx v0.13.1 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index 9a85be2236d..6adde2160b9 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -18,6 +18,7 @@ import ( "cosmossdk.io/x/accounts/accountstd" lockuptypes "cosmossdk.io/x/accounts/defaults/lockup/types" banktypes "cosmossdk.io/x/bank/types" + distrtypes "cosmossdk.io/x/distribution/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -219,6 +220,44 @@ func (bva *BaseLockup) Undelegate( return &lockuptypes.MsgExecuteMessagesResponse{Responses: responses}, nil } +func (bva *BaseLockup) WithdrawReward( + ctx context.Context, msg *lockuptypes.MsgWithdrawReward, +) ( + *lockuptypes.MsgExecuteMessagesResponse, error, +) { + err := bva.checkSender(ctx, msg.Sender) + if err != nil { + return nil, err + } + whoami := accountstd.Whoami(ctx) + delegatorAddress, err := bva.addressCodec.BytesToString(whoami) + if err != nil { + return nil, err + } + + responses := []*codectypes.Any{} + + err = bva.branchService.Execute(ctx, func(ctx context.Context) error { + msgWithdraw := &distrtypes.MsgWithdrawDelegatorReward{ + DelegatorAddress: delegatorAddress, + ValidatorAddress: msg.ValidatorAddress, + } + resp, err := sendMessage(ctx, msgWithdraw) + if err != nil { + return err + } + + responses = append(responses, resp...) + + return nil + }) + if err != nil { + return nil, err + } + + return &lockuptypes.MsgExecuteMessagesResponse{Responses: responses}, nil +} + func (bva *BaseLockup) SendCoins( ctx context.Context, msg *lockuptypes.MsgSend, getLockedCoinsFunc getLockedCoinsFunc, ) ( diff --git a/x/accounts/defaults/lockup/periodic_locking_account.go b/x/accounts/defaults/lockup/periodic_locking_account.go index be3ce30c153..d894b82d04e 100644 --- a/x/accounts/defaults/lockup/periodic_locking_account.go +++ b/x/accounts/defaults/lockup/periodic_locking_account.go @@ -111,6 +111,12 @@ func (pva *PeriodicLockingAccount) Undelegate(ctx context.Context, msg *lockupty return pva.BaseLockup.Undelegate(ctx, msg) } +func (pva *PeriodicLockingAccount) WithdrawReward(ctx context.Context, msg *lockuptypes.MsgWithdrawReward) ( + *lockuptypes.MsgExecuteMessagesResponse, error, +) { + return pva.BaseLockup.WithdrawReward(ctx, msg) +} + func (pva *PeriodicLockingAccount) SendCoins(ctx context.Context, msg *lockuptypes.MsgSend) ( *lockuptypes.MsgExecuteMessagesResponse, error, ) { @@ -325,6 +331,7 @@ func (pva PeriodicLockingAccount) RegisterInitHandler(builder *accountstd.InitBu func (pva PeriodicLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, pva.Delegate) accountstd.RegisterExecuteHandler(builder, pva.Undelegate) + accountstd.RegisterExecuteHandler(builder, pva.WithdrawReward) accountstd.RegisterExecuteHandler(builder, pva.SendCoins) accountstd.RegisterExecuteHandler(builder, pva.WithdrawUnlockedCoins) } diff --git a/x/accounts/defaults/lockup/permanent_locking_account.go b/x/accounts/defaults/lockup/permanent_locking_account.go index 70a8b98dd1d..dfeabaef34a 100644 --- a/x/accounts/defaults/lockup/permanent_locking_account.go +++ b/x/accounts/defaults/lockup/permanent_locking_account.go @@ -66,6 +66,12 @@ func (plva *PermanentLockingAccount) Undelegate(ctx context.Context, msg *lockup return plva.BaseLockup.Undelegate(ctx, msg) } +func (plva *PermanentLockingAccount) WithdrawReward(ctx context.Context, msg *lockuptypes.MsgWithdrawReward) ( + *lockuptypes.MsgExecuteMessagesResponse, error, +) { + return plva.BaseLockup.WithdrawReward(ctx, msg) +} + func (plva *PermanentLockingAccount) SendCoins(ctx context.Context, msg *lockuptypes.MsgSend) ( *lockuptypes.MsgExecuteMessagesResponse, error, ) { @@ -101,6 +107,7 @@ func (plva PermanentLockingAccount) RegisterInitHandler(builder *accountstd.Init func (plva PermanentLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, plva.Delegate) accountstd.RegisterExecuteHandler(builder, plva.Undelegate) + accountstd.RegisterExecuteHandler(builder, plva.WithdrawReward) accountstd.RegisterExecuteHandler(builder, plva.SendCoins) } diff --git a/x/accounts/defaults/lockup/types/tx.pb.go b/x/accounts/defaults/lockup/types/tx.pb.go index c50ab2f5c36..61d7f96d024 100644 --- a/x/accounts/defaults/lockup/types/tx.pb.go +++ b/x/accounts/defaults/lockup/types/tx.pb.go @@ -318,6 +318,45 @@ func (m *MsgUndelegate) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUndelegate proto.InternalMessageInfo +// MsgWithdrawReward defines a message that enable lockup account to withdraw staking reward +type MsgWithdrawReward struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` +} + +func (m *MsgWithdrawReward) Reset() { *m = MsgWithdrawReward{} } +func (m *MsgWithdrawReward) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawReward) ProtoMessage() {} +func (*MsgWithdrawReward) Descriptor() ([]byte, []int) { + return fileDescriptor_e5f39108a4d67f92, []int{6} +} +func (m *MsgWithdrawReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawReward.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 *MsgWithdrawReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawReward.Merge(m, src) +} +func (m *MsgWithdrawReward) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawReward) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawReward.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawReward proto.InternalMessageInfo + // MsgSend defines a message that enable lockup account to execute send message type MsgSend struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` @@ -329,7 +368,7 @@ 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_e5f39108a4d67f92, []int{6} + return fileDescriptor_e5f39108a4d67f92, []int{7} } func (m *MsgSend) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -367,7 +406,7 @@ func (m *MsgExecuteMessagesResponse) Reset() { *m = MsgExecuteMessagesRe func (m *MsgExecuteMessagesResponse) String() string { return proto.CompactTextString(m) } func (*MsgExecuteMessagesResponse) ProtoMessage() {} func (*MsgExecuteMessagesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e5f39108a4d67f92, []int{7} + return fileDescriptor_e5f39108a4d67f92, []int{8} } func (m *MsgExecuteMessagesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -415,7 +454,7 @@ func (m *MsgWithdraw) Reset() { *m = MsgWithdraw{} } func (m *MsgWithdraw) String() string { return proto.CompactTextString(m) } func (*MsgWithdraw) ProtoMessage() {} func (*MsgWithdraw) Descriptor() ([]byte, []int) { - return fileDescriptor_e5f39108a4d67f92, []int{8} + return fileDescriptor_e5f39108a4d67f92, []int{9} } func (m *MsgWithdraw) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -454,7 +493,7 @@ func (m *MsgWithdrawResponse) Reset() { *m = MsgWithdrawResponse{} } func (m *MsgWithdrawResponse) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawResponse) ProtoMessage() {} func (*MsgWithdrawResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e5f39108a4d67f92, []int{9} + return fileDescriptor_e5f39108a4d67f92, []int{10} } func (m *MsgWithdrawResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -504,6 +543,7 @@ func init() { proto.RegisterType((*MsgInitPeriodicLockingAccountResponse)(nil), "cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccountResponse") proto.RegisterType((*MsgDelegate)(nil), "cosmos.accounts.defaults.lockup.MsgDelegate") proto.RegisterType((*MsgUndelegate)(nil), "cosmos.accounts.defaults.lockup.MsgUndelegate") + proto.RegisterType((*MsgWithdrawReward)(nil), "cosmos.accounts.defaults.lockup.MsgWithdrawReward") proto.RegisterType((*MsgSend)(nil), "cosmos.accounts.defaults.lockup.MsgSend") proto.RegisterType((*MsgExecuteMessagesResponse)(nil), "cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse") proto.RegisterType((*MsgWithdraw)(nil), "cosmos.accounts.defaults.lockup.MsgWithdraw") @@ -515,57 +555,58 @@ func init() { } var fileDescriptor_e5f39108a4d67f92 = []byte{ - // 797 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0x3d, 0x4f, 0x1b, 0x49, - 0x18, 0xf6, 0xda, 0x3a, 0x83, 0x87, 0x03, 0x8e, 0xc5, 0x3a, 0x8c, 0x75, 0xec, 0x72, 0x96, 0x10, - 0x96, 0x75, 0xde, 0x3d, 0xb8, 0x93, 0xee, 0x64, 0x5d, 0x83, 0x8f, 0x7c, 0x49, 0x71, 0x84, 0x4c, - 0x3e, 0xa4, 0xa4, 0xb0, 0xd6, 0xbb, 0xc3, 0xb0, 0xc2, 0x3b, 0x63, 0xed, 0x8c, 0x0d, 0xee, 0xa2, - 0x28, 0x45, 0x44, 0x45, 0x9d, 0x8a, 0x2a, 0x8a, 0x52, 0x39, 0x12, 0x3f, 0x82, 0x12, 0x51, 0x51, - 0x85, 0xc8, 0x44, 0x32, 0x3f, 0x23, 0x9a, 0x9d, 0x59, 0x62, 0x3e, 0x02, 0x8e, 0x8b, 0x14, 0x69, - 0xbc, 0x33, 0xf3, 0x3e, 0xef, 0xfb, 0x3e, 0xcf, 0x33, 0x1f, 0x32, 0xc8, 0xda, 0x84, 0x7a, 0x84, - 0x9a, 0x96, 0x6d, 0x93, 0x06, 0x66, 0xd4, 0x74, 0xe0, 0x9a, 0xd5, 0xa8, 0x31, 0x6a, 0xd6, 0x88, - 0xbd, 0xd1, 0xa8, 0x9b, 0x6c, 0xcb, 0xa8, 0xfb, 0x84, 0x11, 0x55, 0x17, 0x48, 0x23, 0x44, 0x1a, - 0x21, 0xd2, 0x10, 0xc8, 0xf4, 0x84, 0xe5, 0xb9, 0x98, 0x98, 0xc1, 0xaf, 0xc8, 0x49, 0x6b, 0xb2, - 0x7a, 0xd5, 0xa2, 0xd0, 0x6c, 0x2e, 0x54, 0x21, 0xb3, 0x16, 0x4c, 0x9b, 0xb8, 0x58, 0xc6, 0xff, - 0xb8, 0xa9, 0xbb, 0xf8, 0x48, 0xf4, 0x94, 0x44, 0x7b, 0x14, 0x99, 0xcd, 0x05, 0xfe, 0x91, 0x81, - 0x69, 0x11, 0xa8, 0x04, 0x33, 0x53, 0xf2, 0x14, 0xa1, 0x24, 0x22, 0x88, 0x88, 0x75, 0x3e, 0x0a, - 0x13, 0x10, 0x21, 0xa8, 0x06, 0xcd, 0x60, 0x56, 0x6d, 0xac, 0x99, 0x16, 0x6e, 0xc9, 0x90, 0x7e, - 0x31, 0xc4, 0x5c, 0x0f, 0x52, 0x66, 0x79, 0x92, 0x45, 0xe6, 0x79, 0x14, 0x24, 0x4b, 0x14, 0xdd, - 0xc3, 0x2e, 0xbb, 0x1f, 0xb0, 0x5b, 0x12, 0xe4, 0x55, 0x03, 0xfc, 0x44, 0x36, 0x31, 0xf4, 0x53, - 0xca, 0xac, 0x92, 0x4d, 0x14, 0x53, 0x87, 0x7b, 0xf9, 0xa4, 0xe4, 0xb2, 0xe4, 0x38, 0x3e, 0xa4, - 0x74, 0x95, 0xf9, 0x2e, 0x46, 0x65, 0x01, 0x53, 0x97, 0xc1, 0x30, 0xc4, 0x4e, 0x85, 0xd7, 0x4f, - 0x45, 0x67, 0x95, 0xec, 0xc8, 0x62, 0xda, 0x10, 0xcd, 0x8d, 0xb0, 0xb9, 0xf1, 0x30, 0x6c, 0x5e, - 0x1c, 0xdd, 0xff, 0xa0, 0x47, 0x76, 0x8e, 0x75, 0xe5, 0x6d, 0xb7, 0x9d, 0x53, 0xca, 0x43, 0x10, - 0x3b, 0x3c, 0xa8, 0xde, 0x05, 0x80, 0x32, 0xcb, 0x67, 0xa2, 0x4e, 0xec, 0x5b, 0xeb, 0x24, 0x82, - 0x64, 0x1e, 0x2e, 0x64, 0x4f, 0x77, 0x75, 0x65, 0xbb, 0xdb, 0xce, 0xc9, 0x9d, 0xce, 0x53, 0x67, - 0xc3, 0xbc, 0x4a, 0x69, 0x46, 0x03, 0xbf, 0x5d, 0xb5, 0x5e, 0x86, 0xb4, 0x4e, 0x30, 0x85, 0x99, - 0x37, 0x51, 0x30, 0x23, 0x01, 0x2b, 0xd0, 0x77, 0x89, 0xe3, 0xda, 0x1c, 0xe8, 0x62, 0x34, 0xa8, - 0x57, 0xe7, 0x55, 0x46, 0x07, 0x57, 0xa9, 0x3e, 0x03, 0xe3, 0x35, 0xc1, 0xa5, 0x52, 0x0f, 0xb8, - 0xd1, 0x54, 0x6c, 0x36, 0x96, 0x1d, 0x59, 0x9c, 0x37, 0x6e, 0x38, 0xe0, 0x86, 0xd0, 0x52, 0x4c, - 0xf0, 0xda, 0xa2, 0xee, 0x98, 0x2c, 0x25, 0x22, 0xb4, 0x60, 0x9c, 0xee, 0xea, 0x11, 0x6e, 0xe1, - 0xdc, 0x65, 0x0b, 0x05, 0xe6, 0xbc, 0x91, 0xf3, 0x60, 0xee, 0x5a, 0x9f, 0xce, 0x1c, 0xed, 0x28, - 0x60, 0xa4, 0x44, 0xd1, 0x32, 0xac, 0x41, 0x64, 0x31, 0xa8, 0xfe, 0x09, 0xe2, 0x14, 0x62, 0xa7, - 0x0f, 0x03, 0x25, 0x4e, 0x7d, 0x00, 0x26, 0x9a, 0x56, 0xcd, 0x75, 0x2c, 0x46, 0xfc, 0x8a, 0x25, - 0x20, 0x81, 0x91, 0x89, 0xe2, 0xef, 0x87, 0x7b, 0xf9, 0x19, 0x99, 0xfc, 0x38, 0xc4, 0x9c, 0xaf, - 0xf2, 0x4b, 0xf3, 0xc2, 0xba, 0xfa, 0x1f, 0x88, 0x5b, 0x1e, 0xe7, 0x28, 0xcf, 0xdc, 0x74, 0x68, - 0x1f, 0xbf, 0xeb, 0x86, 0xbc, 0xeb, 0xc6, 0xff, 0xc4, 0xc5, 0xbd, 0x86, 0xc9, 0x9c, 0xc2, 0xe4, - 0xab, 0x5d, 0x3d, 0xc2, 0xcd, 0x7a, 0xd1, 0x6d, 0xe7, 0x24, 0xc5, 0xcc, 0x27, 0x05, 0x8c, 0x96, - 0x28, 0x7a, 0x84, 0x9d, 0x1f, 0x5a, 0xe6, 0xcb, 0x28, 0x18, 0x2a, 0x51, 0xb4, 0x0a, 0xb1, 0x33, - 0x80, 0xc0, 0x7f, 0x00, 0x60, 0xe4, 0x82, 0xb2, 0xaf, 0x67, 0x25, 0x18, 0x09, 0x95, 0xb4, 0x7a, - 0x94, 0xc4, 0xae, 0x57, 0x72, 0x9b, 0x2b, 0x79, 0x77, 0xac, 0x67, 0x91, 0xcb, 0xd6, 0x1b, 0x55, - 0xc3, 0x26, 0x9e, 0x7c, 0x55, 0xcd, 0x9e, 0x73, 0xcd, 0x5a, 0x75, 0x48, 0x83, 0x04, 0xfa, 0xba, - 0xdb, 0xce, 0xfd, 0xcc, 0xf7, 0xcc, 0x6e, 0x55, 0xf8, 0xf3, 0x4e, 0xfb, 0xb0, 0x61, 0x05, 0xa4, - 0x4b, 0x14, 0xdd, 0xda, 0x82, 0x76, 0x83, 0xc1, 0x12, 0xa4, 0xd4, 0x42, 0x90, 0x86, 0x07, 0x5e, - 0x5d, 0x04, 0x09, 0x5f, 0x8e, 0x69, 0x4a, 0x09, 0x08, 0x27, 0x2f, 0xdd, 0xf7, 0x25, 0xdc, 0x2a, - 0x7f, 0x81, 0x65, 0xde, 0x8b, 0x4b, 0xf2, 0xc4, 0x65, 0xeb, 0x8e, 0x6f, 0x6d, 0xaa, 0xff, 0x02, - 0xb0, 0x29, 0xc7, 0x7d, 0x18, 0xdc, 0x83, 0x1d, 0xdc, 0xe4, 0x5f, 0x41, 0xdc, 0x81, 0x98, 0x78, - 0xe2, 0x51, 0x49, 0x94, 0xe5, 0xac, 0x30, 0xd5, 0xeb, 0x40, 0x4f, 0xa7, 0xcc, 0x91, 0x02, 0x26, - 0x7b, 0x38, 0x9f, 0xe9, 0xff, 0x1b, 0x0c, 0xfb, 0xd0, 0x86, 0x6e, 0xb3, 0x0f, 0xe6, 0x67, 0x48, - 0x75, 0x5b, 0x01, 0xe3, 0xc2, 0xf3, 0x8a, 0x5c, 0x73, 0x52, 0xd1, 0xef, 0xb5, 0xdb, 0x63, 0xa2, - 0x73, 0x59, 0x36, 0x2e, 0xde, 0xd9, 0xef, 0x68, 0xca, 0x41, 0x47, 0x53, 0x3e, 0x76, 0x34, 0x65, - 0xe7, 0x44, 0x8b, 0x1c, 0x9c, 0x68, 0x91, 0xa3, 0x13, 0x2d, 0xf2, 0x34, 0x2f, 0xea, 0x52, 0x67, - 0xc3, 0x70, 0x89, 0xb9, 0x75, 0xcd, 0x9f, 0x0f, 0xde, 0xb4, 0x1a, 0x0f, 0x36, 0xfc, 0xaf, 0xcf, - 0x01, 0x00, 0x00, 0xff, 0xff, 0xf7, 0xd7, 0x1d, 0x22, 0xac, 0x08, 0x00, 0x00, + // 816 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0xcf, 0x4f, 0x1b, 0x47, + 0x14, 0xf6, 0xda, 0xaa, 0xc1, 0x43, 0x81, 0xb2, 0x58, 0xc5, 0x58, 0x65, 0x97, 0x5a, 0x42, 0x58, + 0x56, 0xbd, 0x5b, 0x68, 0xa5, 0x56, 0x56, 0x2f, 0xb8, 0xf4, 0x97, 0x54, 0x57, 0xc8, 0xf4, 0x87, + 0xd4, 0x1c, 0xac, 0xf1, 0xee, 0x30, 0xac, 0xf0, 0xce, 0x58, 0x3b, 0x63, 0x1b, 0xdf, 0xa2, 0x28, + 0x87, 0x88, 0x13, 0xe7, 0x9c, 0x38, 0x45, 0x11, 0x27, 0x47, 0xe2, 0x8f, 0xe0, 0x88, 0x38, 0x71, + 0x0a, 0x91, 0x89, 0x64, 0xfe, 0x8c, 0x68, 0x77, 0x66, 0x89, 0x0d, 0x04, 0x1c, 0x1f, 0x12, 0x29, + 0x17, 0xef, 0xcc, 0xbc, 0xef, 0xbd, 0xf7, 0xbd, 0x6f, 0xde, 0xdb, 0x35, 0xc8, 0x5a, 0x94, 0xb9, + 0x94, 0x99, 0xd0, 0xb2, 0x68, 0x83, 0x70, 0x66, 0xda, 0x68, 0x0b, 0x36, 0x6a, 0x9c, 0x99, 0x35, + 0x6a, 0xed, 0x34, 0xea, 0x26, 0xdf, 0x35, 0xea, 0x1e, 0xe5, 0x54, 0xd5, 0x05, 0xd2, 0x08, 0x91, + 0x46, 0x88, 0x34, 0x04, 0x32, 0x3d, 0x03, 0x5d, 0x87, 0x50, 0x33, 0xf8, 0x15, 0x3e, 0x69, 0x4d, + 0x46, 0xaf, 0x42, 0x86, 0xcc, 0xe6, 0x4a, 0x15, 0x71, 0xb8, 0x62, 0x5a, 0xd4, 0x21, 0xd2, 0xfe, + 0xcd, 0x7d, 0xd9, 0xc5, 0x43, 0xa2, 0xe7, 0x24, 0xda, 0x65, 0xd8, 0x6c, 0xae, 0xf8, 0x0f, 0x69, + 0x98, 0x17, 0x86, 0x4a, 0xb0, 0x33, 0x25, 0x4f, 0x61, 0x4a, 0x62, 0x8a, 0xa9, 0x38, 0xf7, 0x57, + 0xa1, 0x03, 0xa6, 0x14, 0xd7, 0x90, 0x19, 0xec, 0xaa, 0x8d, 0x2d, 0x13, 0x92, 0xb6, 0x34, 0xe9, + 0xd7, 0x4d, 0xdc, 0x71, 0x11, 0xe3, 0xd0, 0x95, 0x2c, 0x32, 0x0f, 0xa3, 0x20, 0x59, 0x62, 0xf8, + 0x0f, 0xe2, 0xf0, 0x3f, 0x03, 0x76, 0x6b, 0x82, 0xbc, 0x6a, 0x80, 0xcf, 0x68, 0x8b, 0x20, 0x2f, + 0xa5, 0x2c, 0x2a, 0xd9, 0x44, 0x31, 0x75, 0x7a, 0x94, 0x4f, 0x4a, 0x2e, 0x6b, 0xb6, 0xed, 0x21, + 0xc6, 0x36, 0xb9, 0xe7, 0x10, 0x5c, 0x16, 0x30, 0x75, 0x1d, 0x8c, 0x23, 0x62, 0x57, 0xfc, 0xf8, + 0xa9, 0xe8, 0xa2, 0x92, 0x9d, 0x58, 0x4d, 0x1b, 0x22, 0xb9, 0x11, 0x26, 0x37, 0xfe, 0x0e, 0x93, + 0x17, 0x27, 0x8f, 0x5f, 0xea, 0x91, 0xfd, 0x73, 0x5d, 0x79, 0xde, 0xeb, 0xe4, 0x94, 0xf2, 0x18, + 0x22, 0xb6, 0x6f, 0x54, 0x7f, 0x07, 0x80, 0x71, 0xe8, 0x71, 0x11, 0x27, 0xf6, 0xbe, 0x71, 0x12, + 0x81, 0xb3, 0x6f, 0x2e, 0x64, 0x2f, 0x0f, 0x74, 0x65, 0xaf, 0xd7, 0xc9, 0xc9, 0x9b, 0xce, 0x33, + 0x7b, 0xc7, 0xbc, 0xad, 0xd2, 0x8c, 0x06, 0xbe, 0xba, 0xed, 0xbc, 0x8c, 0x58, 0x9d, 0x12, 0x86, + 0x32, 0xcf, 0xa2, 0x60, 0x41, 0x02, 0x36, 0x90, 0xe7, 0x50, 0xdb, 0xb1, 0x7c, 0xa0, 0x43, 0xf0, + 0xa8, 0x5a, 0x0d, 0x56, 0x19, 0x1d, 0xbd, 0x4a, 0xf5, 0x01, 0x98, 0xae, 0x09, 0x2e, 0x95, 0x7a, + 0xc0, 0x8d, 0xa5, 0x62, 0x8b, 0xb1, 0xec, 0xc4, 0xea, 0xb2, 0x71, 0x4f, 0x83, 0x1b, 0xa2, 0x96, + 0x62, 0xc2, 0x8f, 0x2d, 0xe2, 0x4e, 0xc9, 0x50, 0xc2, 0xc2, 0x0a, 0xc6, 0xe5, 0x81, 0x1e, 0xf1, + 0x25, 0x5c, 0xba, 0x29, 0xa1, 0xc0, 0x0c, 0x0a, 0xb9, 0x0c, 0x96, 0xee, 0xd4, 0xe9, 0x4a, 0xd1, + 0xae, 0x02, 0x26, 0x4a, 0x0c, 0xaf, 0xa3, 0x1a, 0xc2, 0x90, 0x23, 0xf5, 0x5b, 0x10, 0x67, 0x88, + 0xd8, 0x43, 0x08, 0x28, 0x71, 0xea, 0x5f, 0x60, 0xa6, 0x09, 0x6b, 0x8e, 0x0d, 0x39, 0xf5, 0x2a, + 0x50, 0x40, 0x02, 0x21, 0x13, 0xc5, 0xaf, 0x4f, 0x8f, 0xf2, 0x0b, 0xd2, 0xf9, 0xdf, 0x10, 0x33, + 0x18, 0xe5, 0x8b, 0xe6, 0xb5, 0x73, 0xf5, 0x27, 0x10, 0x87, 0xae, 0xcf, 0x51, 0xf6, 0xdc, 0x7c, + 0x28, 0x9f, 0x3f, 0xeb, 0x86, 0x9c, 0x75, 0xe3, 0x67, 0xea, 0x90, 0x7e, 0xc1, 0xa4, 0x4f, 0x61, + 0xf6, 0xc9, 0x81, 0x1e, 0xf1, 0xc5, 0x7a, 0xd4, 0xeb, 0xe4, 0x24, 0xc5, 0xcc, 0x6b, 0x05, 0x4c, + 0x96, 0x18, 0xfe, 0x87, 0xd8, 0x9f, 0x74, 0x99, 0x87, 0x0a, 0x98, 0x29, 0x31, 0xfc, 0x9f, 0xc3, + 0xb7, 0x6d, 0x0f, 0xb6, 0xca, 0xa8, 0x05, 0x3d, 0xfb, 0xe3, 0x97, 0x7a, 0x3b, 0xd9, 0xc7, 0x51, + 0x30, 0x56, 0x62, 0x78, 0x13, 0x91, 0x51, 0x28, 0xfe, 0x00, 0x00, 0xa7, 0xd7, 0xb8, 0xbd, 0xdb, + 0x2b, 0xc1, 0x69, 0x28, 0x7b, 0xbb, 0x4f, 0xf6, 0xd8, 0xdd, 0xb2, 0xff, 0xea, 0xcb, 0x7e, 0x78, + 0xae, 0x67, 0xb1, 0xc3, 0xb7, 0x1b, 0x55, 0xc3, 0xa2, 0xae, 0xfc, 0x04, 0x98, 0x7d, 0x43, 0xc8, + 0xdb, 0x75, 0xc4, 0x02, 0x07, 0xf6, 0xb4, 0xd7, 0xc9, 0x7d, 0xee, 0x37, 0x98, 0xd5, 0xae, 0xf8, + 0xdf, 0x22, 0x36, 0xc4, 0x9d, 0x6d, 0x80, 0x74, 0x89, 0xe1, 0x5f, 0x76, 0x91, 0xd5, 0xe0, 0xa8, + 0x84, 0x18, 0x83, 0x18, 0xb1, 0x70, 0x3a, 0xd5, 0x55, 0x90, 0xf0, 0xe4, 0x9a, 0xa5, 0x94, 0x80, + 0x70, 0xf2, 0xc6, 0xcb, 0x69, 0x8d, 0xb4, 0xcb, 0x6f, 0x61, 0x99, 0x17, 0x62, 0xa2, 0xc3, 0x2e, + 0x50, 0x7f, 0x04, 0xa0, 0x25, 0xd7, 0x43, 0x08, 0xdc, 0x87, 0x1d, 0x5d, 0xe4, 0x2f, 0x41, 0xdc, + 0x46, 0x84, 0xba, 0xe2, 0x0d, 0x98, 0x28, 0xcb, 0x5d, 0x61, 0xae, 0x5f, 0x81, 0xbe, 0x4c, 0x99, + 0x33, 0x05, 0xcc, 0x0e, 0x74, 0xae, 0xac, 0xff, 0x7b, 0x30, 0xee, 0x21, 0x0b, 0x39, 0xcd, 0x21, + 0x98, 0x5f, 0x21, 0xd5, 0x3d, 0x05, 0x4c, 0x0b, 0xcd, 0x2b, 0xf2, 0xcc, 0x4e, 0x45, 0x3f, 0xd4, + 0x6d, 0x4f, 0x89, 0xcc, 0x65, 0x99, 0xb8, 0xf8, 0xdb, 0x71, 0x57, 0x53, 0x4e, 0xba, 0x9a, 0xf2, + 0xaa, 0xab, 0x29, 0xfb, 0x17, 0x5a, 0xe4, 0xe4, 0x42, 0x8b, 0x9c, 0x5d, 0x68, 0x91, 0xff, 0xf3, + 0x22, 0x2e, 0xb3, 0x77, 0x0c, 0x87, 0x9a, 0xbb, 0x77, 0xfc, 0x53, 0xf2, 0x93, 0x56, 0xe3, 0xc1, + 0x85, 0x7f, 0xf7, 0x26, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xb6, 0xac, 0x3d, 0x59, 0x09, 0x00, 0x00, } func (this *MsgInitLockupAccount) Equal(that interface{}) bool { @@ -836,6 +877,43 @@ func (m *MsgUndelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgWithdrawReward) 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 *MsgWithdrawReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *MsgSend) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1119,6 +1197,23 @@ func (m *MsgUndelegate) Size() (n int) { return n } +func (m *MsgWithdrawReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func (m *MsgSend) Size() (n int) { if m == nil { return 0 @@ -1896,6 +1991,120 @@ func (m *MsgUndelegate) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgWithdrawReward) 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: MsgWithdrawReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = 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 *MsgSend) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto b/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto index a0a6e1a07ae..cbc99cc2b97 100644 --- a/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto +++ b/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto @@ -79,6 +79,17 @@ message MsgUndelegate { cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } +// MsgWithdrawReward defines a message that enable lockup account to withdraw staking reward +message MsgWithdrawReward { + option (cosmos.msg.v1.signer) = "sender"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"]; +} + // MsgSend defines a message that enable lockup account to execute send message message MsgSend { option (cosmos.msg.v1.signer) = "sender"; From e45a0d95cf983cea78bd8be653ed776c71eb2d77 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Sun, 14 Apr 2024 22:58:44 +0700 Subject: [PATCH 03/22] clean up --- x/accounts/defaults/lockup/go.mod | 4 +- x/accounts/defaults/lockup/lockup.go | 29 ++++++-- x/accounts/defaults/lockup/protov2_wrapper.go | 72 ------------------- 3 files changed, 27 insertions(+), 78 deletions(-) delete mode 100644 x/accounts/defaults/lockup/protov2_wrapper.go diff --git a/x/accounts/defaults/lockup/go.mod b/x/accounts/defaults/lockup/go.mod index 1e5b80b38c4..91e27213b9a 100644 --- a/x/accounts/defaults/lockup/go.mod +++ b/x/accounts/defaults/lockup/go.mod @@ -11,12 +11,12 @@ require ( github.com/cosmos/gogoproto v1.4.12 ) -require cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect +require cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 require ( buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.32.0-20240130113600-88ef6483f90f.1 // indirect buf.build/gen/go/tendermint/tendermint/protocolbuffers/go v1.32.0-20231117195010-33ed361a9051.1 // indirect - cosmossdk.io/api v0.7.3 + cosmossdk.io/api v0.7.3 // indirect cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/math v1.3.0 diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index 6adde2160b9..2b08d657afe 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -7,6 +7,7 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + "google.golang.org/protobuf/runtime/protoiface" "cosmossdk.io/collections" collcodec "cosmossdk.io/collections/codec" @@ -19,12 +20,15 @@ import ( lockuptypes "cosmossdk.io/x/accounts/defaults/lockup/types" banktypes "cosmossdk.io/x/bank/types" distrtypes "cosmossdk.io/x/distribution/types" + stakingtypes "cosmossdk.io/x/staking/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) +type ProtoMsg = protoiface.MessageV1 + var ( OriginalLockingPrefix = collections.NewPrefix(0) DelegatedFreePrefix = collections.NewPrefix(1) @@ -163,7 +167,11 @@ func (bva *BaseLockup) Delegate( return err } - msgDelegate := makeMsgDelegate(delegatorAddress, msg.ValidatorAddress, msg.Amount) + msgDelegate := &stakingtypes.MsgDelegate{ + DelegatorAddress: delegatorAddress, + ValidatorAddress: msg.ValidatorAddress, + Amount: msg.Amount, + } resp, err := sendMessage(ctx, msgDelegate) if err != nil { return err @@ -203,7 +211,11 @@ func (bva *BaseLockup) Undelegate( return err } - msgUndelegate := makeMsgUndelegate(delegatorAddress, msg.ValidatorAddress, msg.Amount) + msgUndelegate := &stakingtypes.MsgUndelegate{ + DelegatorAddress: delegatorAddress, + ValidatorAddress: msg.ValidatorAddress, + Amount: msg.Amount, + } resp, err := sendMessage(ctx, msgUndelegate) if err != nil { return err @@ -288,7 +300,11 @@ func (bva *BaseLockup) SendCoins( responses := []*codectypes.Any{} err = bva.branchService.Execute(ctx, func(ctx context.Context) error { - msgSend := makeMsgSend(fromAddress, msg.ToAddress, msg.Amount) + msgSend := &banktypes.MsgSend{ + FromAddress: fromAddress, + ToAddress: msg.ToAddress, + Amount: msg.Amount, + } resp, err := sendMessage(ctx, msgSend) if err != nil { return err @@ -382,7 +398,12 @@ func (bva *BaseLockup) WithdrawUnlockedCoins( return fmt.Errorf("no tokens available for withdrawing") } - msgSend := makeMsgSend(fromAddress, msg.ToAddress, amount) + msgSend := &banktypes.MsgSend{ + FromAddress: fromAddress, + ToAddress: msg.ToAddress, + Amount: amount, + } + _, err = sendMessage(ctx, msgSend) if err != nil { return err diff --git a/x/accounts/defaults/lockup/protov2_wrapper.go b/x/accounts/defaults/lockup/protov2_wrapper.go deleted file mode 100644 index caee0c60398..00000000000 --- a/x/accounts/defaults/lockup/protov2_wrapper.go +++ /dev/null @@ -1,72 +0,0 @@ -package lockup - -import ( - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/runtime/protoiface" - - bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1" - v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" - stakingv1beta1 "cosmossdk.io/api/cosmos/staking/v1beta1" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type ProtoMsg = protoiface.MessageV1 - -type gogoProtoPlusV2 interface { - proto.Message - ProtoMsg -} - -// protoV2GogoWrapper is a wrapper of a protov2 message into a gogo message. -// this is exceptionally allowed to enable accounts to be decoupled from -// the SDK, since x/accounts can support only protov1 in its APIs. -// But in order to keep it decoupled from the SDK we need to use the API module. -// This is a temporary solution that is being used here: -// https://github.com/cosmos/cosmos-sdk/blob/main/x/accounts/coin_transfer.go -type protoV2GogoWrapper struct { - gogoProtoPlusV2 -} - -func (h protoV2GogoWrapper) XXX_MessageName() string { - return string(proto.MessageName(h.gogoProtoPlusV2)) -} - -func makeMsgSend(fromAddr, toAddr string, coins sdk.Coins) ProtoMsg { - v2Coins := make([]*v1beta1.Coin, len(coins)) - for i, coin := range coins { - v2Coins[i] = &v1beta1.Coin{ - Denom: coin.Denom, - Amount: coin.Amount.String(), - } - } - return protoV2GogoWrapper{&bankv1beta1.MsgSend{ - FromAddress: fromAddr, - ToAddress: toAddr, - Amount: v2Coins, - }} -} - -func makeMsgDelegate(delegatorAddr, validatorAddr string, amount sdk.Coin) ProtoMsg { - v2Coin := &v1beta1.Coin{ - Denom: amount.Denom, - Amount: amount.Amount.String(), - } - return protoV2GogoWrapper{&stakingv1beta1.MsgDelegate{ - DelegatorAddress: delegatorAddr, - ValidatorAddress: validatorAddr, - Amount: v2Coin, - }} -} - -func makeMsgUndelegate(delegatorAddr, validatorAddr string, amount sdk.Coin) ProtoMsg { - v2Coin := &v1beta1.Coin{ - Denom: amount.Denom, - Amount: amount.Amount.String(), - } - return protoV2GogoWrapper{&stakingv1beta1.MsgUndelegate{ - DelegatorAddress: delegatorAddr, - ValidatorAddress: validatorAddr, - Amount: v2Coin, - }} -} From bf22effa323b32344b31d90fd1aec16a63d122d4 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Sun, 14 Apr 2024 23:15:15 +0700 Subject: [PATCH 04/22] seperate withdraw reward to another PR --- .../accounts/defaults/lockup/tx.pulsar.go | 748 +++--------------- .../lockup/continuous_locking_account.go | 25 +- .../lockup/delayed_locking_account.go | 7 - x/accounts/defaults/lockup/lockup.go | 39 - .../lockup/periodic_locking_account.go | 25 +- .../lockup/permanent_locking_account.go | 7 - x/accounts/defaults/lockup/types/tx.pb.go | 319 ++------ .../cosmos/accounts/defaults/lockup/tx.proto | 11 - 8 files changed, 172 insertions(+), 1009 deletions(-) diff --git a/api/cosmos/accounts/defaults/lockup/tx.pulsar.go b/api/cosmos/accounts/defaults/lockup/tx.pulsar.go index 2786e8373a3..082db8883c5 100644 --- a/api/cosmos/accounts/defaults/lockup/tx.pulsar.go +++ b/api/cosmos/accounts/defaults/lockup/tx.pulsar.go @@ -3072,490 +3072,6 @@ func (x *fastReflection_MsgUndelegate) ProtoMethods() *protoiface.Methods { } } -var ( - md_MsgWithdrawReward protoreflect.MessageDescriptor - fd_MsgWithdrawReward_sender protoreflect.FieldDescriptor - fd_MsgWithdrawReward_validator_address protoreflect.FieldDescriptor -) - -func init() { - file_cosmos_accounts_defaults_lockup_tx_proto_init() - md_MsgWithdrawReward = File_cosmos_accounts_defaults_lockup_tx_proto.Messages().ByName("MsgWithdrawReward") - fd_MsgWithdrawReward_sender = md_MsgWithdrawReward.Fields().ByName("sender") - fd_MsgWithdrawReward_validator_address = md_MsgWithdrawReward.Fields().ByName("validator_address") -} - -var _ protoreflect.Message = (*fastReflection_MsgWithdrawReward)(nil) - -type fastReflection_MsgWithdrawReward MsgWithdrawReward - -func (x *MsgWithdrawReward) ProtoReflect() protoreflect.Message { - return (*fastReflection_MsgWithdrawReward)(x) -} - -func (x *MsgWithdrawReward) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -var _fastReflection_MsgWithdrawReward_messageType fastReflection_MsgWithdrawReward_messageType -var _ protoreflect.MessageType = fastReflection_MsgWithdrawReward_messageType{} - -type fastReflection_MsgWithdrawReward_messageType struct{} - -func (x fastReflection_MsgWithdrawReward_messageType) Zero() protoreflect.Message { - return (*fastReflection_MsgWithdrawReward)(nil) -} -func (x fastReflection_MsgWithdrawReward_messageType) New() protoreflect.Message { - return new(fastReflection_MsgWithdrawReward) -} -func (x fastReflection_MsgWithdrawReward_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_MsgWithdrawReward -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_MsgWithdrawReward) Descriptor() protoreflect.MessageDescriptor { - return md_MsgWithdrawReward -} - -// Type returns the message type, which encapsulates both Go and protobuf -// type information. If the Go type information is not needed, -// it is recommended that the message descriptor be used instead. -func (x *fastReflection_MsgWithdrawReward) Type() protoreflect.MessageType { - return _fastReflection_MsgWithdrawReward_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_MsgWithdrawReward) New() protoreflect.Message { - return new(fastReflection_MsgWithdrawReward) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_MsgWithdrawReward) Interface() protoreflect.ProtoMessage { - return (*MsgWithdrawReward)(x) -} - -// Range iterates over every populated field in an undefined order, -// calling f for each field descriptor and value encountered. -// Range returns immediately if f returns false. -// While iterating, mutating operations may only be performed -// on the current field descriptor. -func (x *fastReflection_MsgWithdrawReward) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.Sender != "" { - value := protoreflect.ValueOfString(x.Sender) - if !f(fd_MsgWithdrawReward_sender, value) { - return - } - } - if x.ValidatorAddress != "" { - value := protoreflect.ValueOfString(x.ValidatorAddress) - if !f(fd_MsgWithdrawReward_validator_address, value) { - return - } - } -} - -// Has reports whether a field is populated. -// -// Some fields have the property of nullability where it is possible to -// distinguish between the default value of a field and whether the field -// was explicitly populated with the default value. Singular message fields, -// member fields of a oneof, and proto2 scalar fields are nullable. Such -// fields are populated only if explicitly set. -// -// In other cases (aside from the nullable cases above), -// a proto3 scalar field is populated if it contains a non-zero value, and -// a repeated field is populated if it is non-empty. -func (x *fastReflection_MsgWithdrawReward) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": - return x.Sender != "" - case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": - return x.ValidatorAddress != "" - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) - } - panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) - } -} - -// Clear clears the field such that a subsequent Has call reports false. -// -// Clearing an extension field clears both the extension type and value -// associated with the given field number. -// -// Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgWithdrawReward) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": - x.Sender = "" - case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": - x.ValidatorAddress = "" - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) - } - panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) - } -} - -// Get retrieves the value for a field. -// -// For unpopulated scalars, it returns the default value, where -// the default value of a bytes scalar is guaranteed to be a copy. -// For unpopulated composite types, it returns an empty, read-only view -// of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_MsgWithdrawReward) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": - value := x.Sender - return protoreflect.ValueOfString(value) - case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": - value := x.ValidatorAddress - return protoreflect.ValueOfString(value) - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) - } - panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", descriptor.FullName())) - } -} - -// Set stores the value for a field. -// -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType. -// When setting a composite type, it is unspecified whether the stored value -// aliases the source's memory in any way. If the composite value is an -// empty, read-only value, then it panics. -// -// Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgWithdrawReward) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": - x.Sender = value.Interface().(string) - case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": - x.ValidatorAddress = value.Interface().(string) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) - } - panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) - } -} - -// Mutable returns a mutable reference to a composite type. -// -// If the field is unpopulated, it may allocate a composite value. -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType -// if not already stored. -// It panics if the field does not contain a composite type. -// -// Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgWithdrawReward) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": - panic(fmt.Errorf("field sender of message cosmos.accounts.defaults.lockup.MsgWithdrawReward is not mutable")) - case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": - panic(fmt.Errorf("field validator_address of message cosmos.accounts.defaults.lockup.MsgWithdrawReward is not mutable")) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) - } - panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) - } -} - -// NewField returns a new value that is assignable to the field -// for the given descriptor. For scalars, this returns the default value. -// For lists, maps, and messages, this returns a new, empty, mutable value. -func (x *fastReflection_MsgWithdrawReward) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": - return protoreflect.ValueOfString("") - case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": - return protoreflect.ValueOfString("") - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) - } - panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) - } -} - -// WhichOneof reports which field within the oneof is populated, -// returning nil if none are populated. -// It panics if the oneof descriptor does not belong to this message. -func (x *fastReflection_MsgWithdrawReward) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.defaults.lockup.MsgWithdrawReward", d.FullName())) - } - panic("unreachable") -} - -// GetUnknown retrieves the entire list of unknown fields. -// The caller may only mutate the contents of the RawFields -// if the mutated bytes are stored back into the message with SetUnknown. -func (x *fastReflection_MsgWithdrawReward) GetUnknown() protoreflect.RawFields { - return x.unknownFields -} - -// SetUnknown stores an entire list of unknown fields. -// The raw fields must be syntactically valid according to the wire format. -// An implementation may panic if this is not the case. -// Once stored, the caller must not mutate the content of the RawFields. -// An empty RawFields may be passed to clear the fields. -// -// SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgWithdrawReward) SetUnknown(fields protoreflect.RawFields) { - x.unknownFields = fields -} - -// IsValid reports whether the message is valid. -// -// An invalid message is an empty, read-only value. -// -// An invalid message often corresponds to a nil pointer of the concrete -// message type, but the details are implementation dependent. -// Validity is not part of the protobuf data model, and may not -// be preserved in marshaling or other operations. -func (x *fastReflection_MsgWithdrawReward) IsValid() bool { - return x != nil -} - -// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. -// This method may return nil. -// -// The returned methods type is identical to -// "google.golang.org/protobuf/runtime/protoiface".Methods. -// Consult the protoiface package documentation for details. -func (x *fastReflection_MsgWithdrawReward) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*MsgWithdrawReward) - if x == nil { - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: 0, - } - } - options := runtime.SizeInputToOptions(input) - _ = options - var n int - var l int - _ = l - l = len(x.Sender) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } - l = len(x.ValidatorAddress) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } - if x.unknownFields != nil { - n += len(x.unknownFields) - } - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: n, - } - } - - marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*MsgWithdrawReward) - if x == nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - options := runtime.MarshalInputToOptions(input) - _ = options - size := options.Size(x) - dAtA := make([]byte, size) - i := len(dAtA) - _ = i - var l int - _ = l - if x.unknownFields != nil { - i -= len(x.unknownFields) - copy(dAtA[i:], x.unknownFields) - } - if len(x.ValidatorAddress) > 0 { - i -= len(x.ValidatorAddress) - copy(dAtA[i:], x.ValidatorAddress) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ValidatorAddress))) - i-- - dAtA[i] = 0x12 - } - if len(x.Sender) > 0 { - i -= len(x.Sender) - copy(dAtA[i:], x.Sender) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Sender))) - i-- - dAtA[i] = 0xa - } - if input.Buf != nil { - input.Buf = append(input.Buf, dAtA...) - } else { - input.Buf = dAtA - } - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*MsgWithdrawReward) - if x == nil { - return protoiface.UnmarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Flags: input.Flags, - }, nil - } - options := runtime.UnmarshalInputToOptions(input) - _ = options - dAtA := input.Buf - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgWithdrawReward: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgWithdrawReward: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.ValidatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := runtime.Skip(dAtA[iNdEx:]) - if err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if !options.DiscardUnknown { - x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - } - iNdEx += skippy - } - } - - if iNdEx > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil - } - return &protoiface.Methods{ - NoUnkeyedLiterals: struct{}{}, - Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, - Size: size, - Marshal: marshal, - Unmarshal: unmarshal, - Merge: nil, - CheckInitialized: nil, - } -} - var _ protoreflect.List = (*_MsgSend_3_list)(nil) type _MsgSend_3_list struct { @@ -3631,7 +3147,7 @@ func (x *MsgSend) ProtoReflect() protoreflect.Message { } func (x *MsgSend) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4249,7 +3765,7 @@ func (x *MsgExecuteMessagesResponse) ProtoReflect() protoreflect.Message { } func (x *MsgExecuteMessagesResponse) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4742,7 +4258,7 @@ func (x *MsgWithdraw) ProtoReflect() protoreflect.Message { } func (x *MsgWithdraw) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -5353,7 +4869,7 @@ func (x *MsgWithdrawResponse) ProtoReflect() protoreflect.Message { } func (x *MsgWithdrawResponse) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[10] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -6122,50 +5638,6 @@ func (x *MsgUndelegate) GetAmount() *v1beta1.Coin { return nil } -// MsgWithdrawReward defines a message that enable lockup account to withdraw staking reward -type MsgWithdrawReward struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` -} - -func (x *MsgWithdrawReward) Reset() { - *x = MsgWithdrawReward{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MsgWithdrawReward) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MsgWithdrawReward) ProtoMessage() {} - -// Deprecated: Use MsgWithdrawReward.ProtoReflect.Descriptor instead. -func (*MsgWithdrawReward) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{6} -} - -func (x *MsgWithdrawReward) GetSender() string { - if x != nil { - return x.Sender - } - return "" -} - -func (x *MsgWithdrawReward) GetValidatorAddress() string { - if x != nil { - return x.ValidatorAddress - } - return "" -} - // MsgSend defines a message that enable lockup account to execute send message type MsgSend struct { state protoimpl.MessageState @@ -6180,7 +5652,7 @@ type MsgSend struct { func (x *MsgSend) Reset() { *x = MsgSend{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -6194,7 +5666,7 @@ func (*MsgSend) ProtoMessage() {} // Deprecated: Use MsgSend.ProtoReflect.Descriptor instead. func (*MsgSend) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{7} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{6} } func (x *MsgSend) GetSender() string { @@ -6230,7 +5702,7 @@ type MsgExecuteMessagesResponse struct { func (x *MsgExecuteMessagesResponse) Reset() { *x = MsgExecuteMessagesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -6244,7 +5716,7 @@ func (*MsgExecuteMessagesResponse) ProtoMessage() {} // Deprecated: Use MsgExecuteMessagesResponse.ProtoReflect.Descriptor instead. func (*MsgExecuteMessagesResponse) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{8} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{7} } func (x *MsgExecuteMessagesResponse) GetResponses() []*anypb.Any { @@ -6269,7 +5741,7 @@ type MsgWithdraw struct { func (x *MsgWithdraw) Reset() { *x = MsgWithdraw{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -6283,7 +5755,7 @@ func (*MsgWithdraw) ProtoMessage() {} // Deprecated: Use MsgWithdraw.ProtoReflect.Descriptor instead. func (*MsgWithdraw) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{9} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{8} } func (x *MsgWithdraw) GetWithdrawer() string { @@ -6320,7 +5792,7 @@ type MsgWithdrawResponse struct { func (x *MsgWithdrawResponse) Reset() { *x = MsgWithdrawResponse{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[10] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -6334,7 +5806,7 @@ func (*MsgWithdrawResponse) ProtoMessage() {} // Deprecated: Use MsgWithdrawResponse.ProtoReflect.Descriptor instead. func (*MsgWithdrawResponse) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{10} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{9} } func (x *MsgWithdrawResponse) GetReceiver() string { @@ -6441,81 +5913,70 @@ var file_cosmos_accounts_defaults_lockup_tx_proto_rawDesc = []byte{ 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x13, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x65, 0x6e, - 0x64, 0x65, 0x72, 0x22, 0xaa, 0x01, 0x0a, 0x11, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, - 0x72, 0x61, 0x77, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x12, 0x30, 0x0a, 0x06, 0x73, 0x65, 0x6e, - 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, - 0x69, 0x6e, 0x67, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x4e, 0x0a, 0x11, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x21, 0xd2, 0xb4, 0x2d, 0x1d, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x3a, 0x13, 0x88, 0xa0, 0x1f, - 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, - 0x22, 0x84, 0x02, 0x0a, 0x07, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x6e, 0x64, 0x12, 0x30, 0x0a, 0x06, - 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, - 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x37, - 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, - 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x74, 0x6f, - 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x79, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, - 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, - 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, - 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, - 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, - 0x6e, 0x74, 0x3a, 0x13, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, - 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x1a, 0x4d, 0x73, 0x67, 0x45, 0x78, - 0x65, 0x63, 0x75, 0x74, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x09, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0xb1, 0x01, 0x0a, 0x0b, 0x4d, 0x73, - 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x12, 0x38, 0x0a, 0x0a, 0x77, 0x69, 0x74, - 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, - 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x0a, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, - 0x77, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, - 0x67, 0x52, 0x09, 0x74, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, - 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x64, 0x65, - 0x6e, 0x6f, 0x6d, 0x73, 0x3a, 0x17, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, - 0xb0, 0x2a, 0x0a, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x22, 0xd8, 0x01, - 0x0a, 0x13, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, - 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, - 0x67, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x12, 0x8a, 0x01, 0x0a, 0x0f, - 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, - 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, - 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, - 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x63, 0x6f, - 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0e, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, - 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x42, 0x80, 0x02, 0x0a, 0x23, 0x63, 0x6f, 0x6d, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, - 0x2e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x75, 0x70, - 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x64, 0x65, - 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2f, 0x6c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xa2, 0x02, 0x04, - 0x43, 0x41, 0x44, 0x4c, 0xaa, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, - 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xca, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, - 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xe2, 0x02, 0x2b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, 0x75, - 0x6c, 0x74, 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x22, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, - 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, 0x44, 0x65, 0x66, 0x61, 0x75, - 0x6c, 0x74, 0x73, 0x3a, 0x3a, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x64, 0x65, 0x72, 0x22, 0x84, 0x02, 0x0a, 0x07, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x6e, 0x64, 0x12, + 0x30, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, + 0x72, 0x12, 0x37, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, + 0x09, 0x74, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x79, 0x0a, 0x06, 0x61, 0x6d, + 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, + 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, + 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, + 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x13, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, + 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x1a, 0x4d, 0x73, + 0x67, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, + 0x79, 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0xb1, 0x01, 0x0a, + 0x0b, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x12, 0x38, 0x0a, 0x0a, + 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x0a, 0x77, 0x69, 0x74, 0x68, + 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x74, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, + 0x16, 0x0a, 0x06, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x06, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x73, 0x3a, 0x17, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, + 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x0a, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, + 0x22, 0xd8, 0x01, 0x0a, 0x13, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, + 0x69, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x12, 0x8a, + 0x01, 0x0a, 0x0f, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, + 0x65, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, + 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, + 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, + 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0e, 0x61, 0x6d, 0x6f, + 0x75, 0x6e, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x42, 0x80, 0x02, 0x0a, 0x23, + 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x73, 0x2e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x6c, 0x6f, 0x63, + 0x6b, 0x75, 0x70, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, + 0x2f, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2f, 0x6c, 0x6f, 0x63, 0x6b, 0x75, 0x70, + 0xa2, 0x02, 0x04, 0x43, 0x41, 0x44, 0x4c, 0xaa, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, + 0x74, 0x73, 0x2e, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xca, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, + 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xe2, 0x02, 0x2b, 0x43, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x22, 0x43, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, 0x44, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x3a, 0x3a, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -6530,7 +5991,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP() []byte { return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescData } -var file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_cosmos_accounts_defaults_lockup_tx_proto_goTypes = []interface{}{ (*MsgInitLockupAccount)(nil), // 0: cosmos.accounts.defaults.lockup.MsgInitLockupAccount (*MsgInitLockupAccountResponse)(nil), // 1: cosmos.accounts.defaults.lockup.MsgInitLockupAccountResponse @@ -6538,26 +5999,25 @@ var file_cosmos_accounts_defaults_lockup_tx_proto_goTypes = []interface{}{ (*MsgInitPeriodicLockingAccountResponse)(nil), // 3: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccountResponse (*MsgDelegate)(nil), // 4: cosmos.accounts.defaults.lockup.MsgDelegate (*MsgUndelegate)(nil), // 5: cosmos.accounts.defaults.lockup.MsgUndelegate - (*MsgWithdrawReward)(nil), // 6: cosmos.accounts.defaults.lockup.MsgWithdrawReward - (*MsgSend)(nil), // 7: cosmos.accounts.defaults.lockup.MsgSend - (*MsgExecuteMessagesResponse)(nil), // 8: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse - (*MsgWithdraw)(nil), // 9: cosmos.accounts.defaults.lockup.MsgWithdraw - (*MsgWithdrawResponse)(nil), // 10: cosmos.accounts.defaults.lockup.MsgWithdrawResponse - (*timestamppb.Timestamp)(nil), // 11: google.protobuf.Timestamp - (*Period)(nil), // 12: cosmos.accounts.defaults.lockup.Period - (*v1beta1.Coin)(nil), // 13: cosmos.base.v1beta1.Coin - (*anypb.Any)(nil), // 14: google.protobuf.Any + (*MsgSend)(nil), // 6: cosmos.accounts.defaults.lockup.MsgSend + (*MsgExecuteMessagesResponse)(nil), // 7: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse + (*MsgWithdraw)(nil), // 8: cosmos.accounts.defaults.lockup.MsgWithdraw + (*MsgWithdrawResponse)(nil), // 9: cosmos.accounts.defaults.lockup.MsgWithdrawResponse + (*timestamppb.Timestamp)(nil), // 10: google.protobuf.Timestamp + (*Period)(nil), // 11: cosmos.accounts.defaults.lockup.Period + (*v1beta1.Coin)(nil), // 12: cosmos.base.v1beta1.Coin + (*anypb.Any)(nil), // 13: google.protobuf.Any } var file_cosmos_accounts_defaults_lockup_tx_proto_depIdxs = []int32{ - 11, // 0: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.end_time:type_name -> google.protobuf.Timestamp - 11, // 1: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.start_time:type_name -> google.protobuf.Timestamp - 11, // 2: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.start_time:type_name -> google.protobuf.Timestamp - 12, // 3: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.locking_periods:type_name -> cosmos.accounts.defaults.lockup.Period - 13, // 4: cosmos.accounts.defaults.lockup.MsgDelegate.amount:type_name -> cosmos.base.v1beta1.Coin - 13, // 5: cosmos.accounts.defaults.lockup.MsgUndelegate.amount:type_name -> cosmos.base.v1beta1.Coin - 13, // 6: cosmos.accounts.defaults.lockup.MsgSend.amount:type_name -> cosmos.base.v1beta1.Coin - 14, // 7: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse.responses:type_name -> google.protobuf.Any - 13, // 8: cosmos.accounts.defaults.lockup.MsgWithdrawResponse.amount_received:type_name -> cosmos.base.v1beta1.Coin + 10, // 0: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.end_time:type_name -> google.protobuf.Timestamp + 10, // 1: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.start_time:type_name -> google.protobuf.Timestamp + 10, // 2: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.start_time:type_name -> google.protobuf.Timestamp + 11, // 3: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.locking_periods:type_name -> cosmos.accounts.defaults.lockup.Period + 12, // 4: cosmos.accounts.defaults.lockup.MsgDelegate.amount:type_name -> cosmos.base.v1beta1.Coin + 12, // 5: cosmos.accounts.defaults.lockup.MsgUndelegate.amount:type_name -> cosmos.base.v1beta1.Coin + 12, // 6: cosmos.accounts.defaults.lockup.MsgSend.amount:type_name -> cosmos.base.v1beta1.Coin + 13, // 7: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse.responses:type_name -> google.protobuf.Any + 12, // 8: cosmos.accounts.defaults.lockup.MsgWithdrawResponse.amount_received:type_name -> cosmos.base.v1beta1.Coin 9, // [9:9] is the sub-list for method output_type 9, // [9:9] is the sub-list for method input_type 9, // [9:9] is the sub-list for extension type_name @@ -6645,18 +6105,6 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { } } file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MsgWithdrawReward); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MsgSend); i { case 0: return &v.state @@ -6668,7 +6116,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { return nil } } - file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MsgExecuteMessagesResponse); i { case 0: return &v.state @@ -6680,7 +6128,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { return nil } } - file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MsgWithdraw); i { case 0: return &v.state @@ -6692,7 +6140,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { return nil } } - file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MsgWithdrawResponse); i { case 0: return &v.state @@ -6711,7 +6159,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_accounts_defaults_lockup_tx_proto_rawDesc, NumEnums: 0, - NumMessages: 11, + NumMessages: 10, NumExtensions: 0, NumServices: 0, }, diff --git a/x/accounts/defaults/lockup/continuous_locking_account.go b/x/accounts/defaults/lockup/continuous_locking_account.go index a5917b73e4a..368c7891692 100644 --- a/x/accounts/defaults/lockup/continuous_locking_account.go +++ b/x/accounts/defaults/lockup/continuous_locking_account.go @@ -41,7 +41,7 @@ func (cva ContinuousLockingAccount) Init(ctx context.Context, msg *lockuptypes.M return nil, sdkerrors.ErrInvalidRequest.Wrapf("invalid end time %s", msg.EndTime.String()) } - if msg.EndTime.Before(msg.StartTime) { + if msg.EndTime.Before(msg.StartTime) || msg.EndTime.Equal(msg.StartTime) { return nil, sdkerrors.ErrInvalidRequest.Wrap("invalid start and end time (must be start before end)") } @@ -72,12 +72,6 @@ func (cva *ContinuousLockingAccount) Undelegate(ctx context.Context, msg *lockup return cva.BaseLockup.Undelegate(ctx, msg) } -func (cva *ContinuousLockingAccount) WithdrawReward(ctx context.Context, msg *lockuptypes.MsgWithdrawReward) ( - *lockuptypes.MsgExecuteMessagesResponse, error, -) { - return cva.BaseLockup.WithdrawReward(ctx, msg) -} - func (cva *ContinuousLockingAccount) SendCoins(ctx context.Context, msg *lockuptypes.MsgSend) ( *lockuptypes.MsgExecuteMessagesResponse, error, ) { @@ -95,17 +89,6 @@ func (cva ContinuousLockingAccount) GetLockCoinsInfo(ctx context.Context, blockT unlockedCoins = sdk.Coins{} lockedCoins = sdk.Coins{} - // We must handle the case where the start time for a lockup account has - // been set into the future or when the start of the chain is not exactly - // known. - startTime, err := cva.StartTime.Get(ctx) - if err != nil { - return nil, nil, err - } - endTime, err := cva.EndTime.Get(ctx) - if err != nil { - return nil, nil, err - } var originalVesting sdk.Coins err = cva.IterateCoinEntries(ctx, cva.OriginalLocking, func(key string, value math.Int) (stop bool, err error) { originalVesting = append(originalVesting, sdk.NewCoin(key, value)) @@ -120,11 +103,6 @@ func (cva ContinuousLockingAccount) GetLockCoinsInfo(ctx context.Context, blockT if err != nil { return nil, nil, err } - if startTime.After(blockTime) { - return unlockedCoins, originalVesting, nil - } else if endTime.Before(blockTime) { - return originalVesting, lockedCoins, nil - } return unlockedCoins, lockedCoins, nil } @@ -223,7 +201,6 @@ func (cva ContinuousLockingAccount) RegisterExecuteHandlers(builder *accountstd. accountstd.RegisterExecuteHandler(builder, cva.Delegate) accountstd.RegisterExecuteHandler(builder, cva.Undelegate) accountstd.RegisterExecuteHandler(builder, cva.SendCoins) - accountstd.RegisterExecuteHandler(builder, cva.WithdrawReward) accountstd.RegisterExecuteHandler(builder, cva.WithdrawUnlockedCoins) } diff --git a/x/accounts/defaults/lockup/delayed_locking_account.go b/x/accounts/defaults/lockup/delayed_locking_account.go index f5bd455e7db..dbc19d96008 100644 --- a/x/accounts/defaults/lockup/delayed_locking_account.go +++ b/x/accounts/defaults/lockup/delayed_locking_account.go @@ -49,12 +49,6 @@ func (dva *DelayedLockingAccount) Undelegate(ctx context.Context, msg *lockuptyp return dva.BaseLockup.Undelegate(ctx, msg) } -func (dva *DelayedLockingAccount) WithdrawReward(ctx context.Context, msg *lockuptypes.MsgWithdrawReward) ( - *lockuptypes.MsgExecuteMessagesResponse, error, -) { - return dva.BaseLockup.WithdrawReward(ctx, msg) -} - func (dva *DelayedLockingAccount) SendCoins(ctx context.Context, msg *lockuptypes.MsgSend) ( *lockuptypes.MsgExecuteMessagesResponse, error, ) { @@ -155,7 +149,6 @@ func (dva DelayedLockingAccount) RegisterInitHandler(builder *accountstd.InitBui func (dva DelayedLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, dva.Delegate) accountstd.RegisterExecuteHandler(builder, dva.Undelegate) - accountstd.RegisterExecuteHandler(builder, dva.WithdrawReward) accountstd.RegisterExecuteHandler(builder, dva.SendCoins) accountstd.RegisterExecuteHandler(builder, dva.WithdrawUnlockedCoins) } diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index 2b08d657afe..f66aef1a4de 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -19,7 +19,6 @@ import ( "cosmossdk.io/x/accounts/accountstd" lockuptypes "cosmossdk.io/x/accounts/defaults/lockup/types" banktypes "cosmossdk.io/x/bank/types" - distrtypes "cosmossdk.io/x/distribution/types" stakingtypes "cosmossdk.io/x/staking/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -232,44 +231,6 @@ func (bva *BaseLockup) Undelegate( return &lockuptypes.MsgExecuteMessagesResponse{Responses: responses}, nil } -func (bva *BaseLockup) WithdrawReward( - ctx context.Context, msg *lockuptypes.MsgWithdrawReward, -) ( - *lockuptypes.MsgExecuteMessagesResponse, error, -) { - err := bva.checkSender(ctx, msg.Sender) - if err != nil { - return nil, err - } - whoami := accountstd.Whoami(ctx) - delegatorAddress, err := bva.addressCodec.BytesToString(whoami) - if err != nil { - return nil, err - } - - responses := []*codectypes.Any{} - - err = bva.branchService.Execute(ctx, func(ctx context.Context) error { - msgWithdraw := &distrtypes.MsgWithdrawDelegatorReward{ - DelegatorAddress: delegatorAddress, - ValidatorAddress: msg.ValidatorAddress, - } - resp, err := sendMessage(ctx, msgWithdraw) - if err != nil { - return err - } - - responses = append(responses, resp...) - - return nil - }) - if err != nil { - return nil, err - } - - return &lockuptypes.MsgExecuteMessagesResponse{Responses: responses}, nil -} - func (bva *BaseLockup) SendCoins( ctx context.Context, msg *lockuptypes.MsgSend, getLockedCoinsFunc getLockedCoinsFunc, ) ( diff --git a/x/accounts/defaults/lockup/periodic_locking_account.go b/x/accounts/defaults/lockup/periodic_locking_account.go index d894b82d04e..4680892b53e 100644 --- a/x/accounts/defaults/lockup/periodic_locking_account.go +++ b/x/accounts/defaults/lockup/periodic_locking_account.go @@ -81,6 +81,24 @@ func (pva PeriodicLockingAccount) Init(ctx context.Context, msg *lockuptypes.Msg if err != nil { return nil, err } + + // Set initial value for all withdrawed token + err = pva.WithdrawedCoins.Set(ctx, coin.Denom, math.ZeroInt()) + if err != nil { + return nil, err + } + + // Set initial value for all delegated free token + err = pva.DelegatedFree.Set(ctx, coin.Denom, math.ZeroInt()) + if err != nil { + return nil, err + } + + // Set initial value for all delegated locking token + err = pva.DelegatedLocking.Set(ctx, coin.Denom, math.ZeroInt()) + if err != nil { + return nil, err + } } err = pva.StartTime.Set(ctx, msg.StartTime) @@ -111,12 +129,6 @@ func (pva *PeriodicLockingAccount) Undelegate(ctx context.Context, msg *lockupty return pva.BaseLockup.Undelegate(ctx, msg) } -func (pva *PeriodicLockingAccount) WithdrawReward(ctx context.Context, msg *lockuptypes.MsgWithdrawReward) ( - *lockuptypes.MsgExecuteMessagesResponse, error, -) { - return pva.BaseLockup.WithdrawReward(ctx, msg) -} - func (pva *PeriodicLockingAccount) SendCoins(ctx context.Context, msg *lockuptypes.MsgSend) ( *lockuptypes.MsgExecuteMessagesResponse, error, ) { @@ -331,7 +343,6 @@ func (pva PeriodicLockingAccount) RegisterInitHandler(builder *accountstd.InitBu func (pva PeriodicLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, pva.Delegate) accountstd.RegisterExecuteHandler(builder, pva.Undelegate) - accountstd.RegisterExecuteHandler(builder, pva.WithdrawReward) accountstd.RegisterExecuteHandler(builder, pva.SendCoins) accountstd.RegisterExecuteHandler(builder, pva.WithdrawUnlockedCoins) } diff --git a/x/accounts/defaults/lockup/permanent_locking_account.go b/x/accounts/defaults/lockup/permanent_locking_account.go index dfeabaef34a..70a8b98dd1d 100644 --- a/x/accounts/defaults/lockup/permanent_locking_account.go +++ b/x/accounts/defaults/lockup/permanent_locking_account.go @@ -66,12 +66,6 @@ func (plva *PermanentLockingAccount) Undelegate(ctx context.Context, msg *lockup return plva.BaseLockup.Undelegate(ctx, msg) } -func (plva *PermanentLockingAccount) WithdrawReward(ctx context.Context, msg *lockuptypes.MsgWithdrawReward) ( - *lockuptypes.MsgExecuteMessagesResponse, error, -) { - return plva.BaseLockup.WithdrawReward(ctx, msg) -} - func (plva *PermanentLockingAccount) SendCoins(ctx context.Context, msg *lockuptypes.MsgSend) ( *lockuptypes.MsgExecuteMessagesResponse, error, ) { @@ -107,7 +101,6 @@ func (plva PermanentLockingAccount) RegisterInitHandler(builder *accountstd.Init func (plva PermanentLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, plva.Delegate) accountstd.RegisterExecuteHandler(builder, plva.Undelegate) - accountstd.RegisterExecuteHandler(builder, plva.WithdrawReward) accountstd.RegisterExecuteHandler(builder, plva.SendCoins) } diff --git a/x/accounts/defaults/lockup/types/tx.pb.go b/x/accounts/defaults/lockup/types/tx.pb.go index 61d7f96d024..c50ab2f5c36 100644 --- a/x/accounts/defaults/lockup/types/tx.pb.go +++ b/x/accounts/defaults/lockup/types/tx.pb.go @@ -318,45 +318,6 @@ func (m *MsgUndelegate) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUndelegate proto.InternalMessageInfo -// MsgWithdrawReward defines a message that enable lockup account to withdraw staking reward -type MsgWithdrawReward struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` -} - -func (m *MsgWithdrawReward) Reset() { *m = MsgWithdrawReward{} } -func (m *MsgWithdrawReward) String() string { return proto.CompactTextString(m) } -func (*MsgWithdrawReward) ProtoMessage() {} -func (*MsgWithdrawReward) Descriptor() ([]byte, []int) { - return fileDescriptor_e5f39108a4d67f92, []int{6} -} -func (m *MsgWithdrawReward) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgWithdrawReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgWithdrawReward.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 *MsgWithdrawReward) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgWithdrawReward.Merge(m, src) -} -func (m *MsgWithdrawReward) XXX_Size() int { - return m.Size() -} -func (m *MsgWithdrawReward) XXX_DiscardUnknown() { - xxx_messageInfo_MsgWithdrawReward.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgWithdrawReward proto.InternalMessageInfo - // MsgSend defines a message that enable lockup account to execute send message type MsgSend struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` @@ -368,7 +329,7 @@ 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_e5f39108a4d67f92, []int{7} + return fileDescriptor_e5f39108a4d67f92, []int{6} } func (m *MsgSend) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -406,7 +367,7 @@ func (m *MsgExecuteMessagesResponse) Reset() { *m = MsgExecuteMessagesRe func (m *MsgExecuteMessagesResponse) String() string { return proto.CompactTextString(m) } func (*MsgExecuteMessagesResponse) ProtoMessage() {} func (*MsgExecuteMessagesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e5f39108a4d67f92, []int{8} + return fileDescriptor_e5f39108a4d67f92, []int{7} } func (m *MsgExecuteMessagesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -454,7 +415,7 @@ func (m *MsgWithdraw) Reset() { *m = MsgWithdraw{} } func (m *MsgWithdraw) String() string { return proto.CompactTextString(m) } func (*MsgWithdraw) ProtoMessage() {} func (*MsgWithdraw) Descriptor() ([]byte, []int) { - return fileDescriptor_e5f39108a4d67f92, []int{9} + return fileDescriptor_e5f39108a4d67f92, []int{8} } func (m *MsgWithdraw) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -493,7 +454,7 @@ func (m *MsgWithdrawResponse) Reset() { *m = MsgWithdrawResponse{} } func (m *MsgWithdrawResponse) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawResponse) ProtoMessage() {} func (*MsgWithdrawResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e5f39108a4d67f92, []int{10} + return fileDescriptor_e5f39108a4d67f92, []int{9} } func (m *MsgWithdrawResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -543,7 +504,6 @@ func init() { proto.RegisterType((*MsgInitPeriodicLockingAccountResponse)(nil), "cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccountResponse") proto.RegisterType((*MsgDelegate)(nil), "cosmos.accounts.defaults.lockup.MsgDelegate") proto.RegisterType((*MsgUndelegate)(nil), "cosmos.accounts.defaults.lockup.MsgUndelegate") - proto.RegisterType((*MsgWithdrawReward)(nil), "cosmos.accounts.defaults.lockup.MsgWithdrawReward") proto.RegisterType((*MsgSend)(nil), "cosmos.accounts.defaults.lockup.MsgSend") proto.RegisterType((*MsgExecuteMessagesResponse)(nil), "cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse") proto.RegisterType((*MsgWithdraw)(nil), "cosmos.accounts.defaults.lockup.MsgWithdraw") @@ -555,58 +515,57 @@ func init() { } var fileDescriptor_e5f39108a4d67f92 = []byte{ - // 816 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0xcf, 0x4f, 0x1b, 0x47, - 0x14, 0xf6, 0xda, 0xaa, 0xc1, 0x43, 0x81, 0xb2, 0x58, 0xc5, 0x58, 0x65, 0x97, 0x5a, 0x42, 0x58, - 0x56, 0xbd, 0x5b, 0x68, 0xa5, 0x56, 0x56, 0x2f, 0xb8, 0xf4, 0x97, 0x54, 0x57, 0xc8, 0xf4, 0x87, - 0xd4, 0x1c, 0xac, 0xf1, 0xee, 0x30, 0xac, 0xf0, 0xce, 0x58, 0x3b, 0x63, 0x1b, 0xdf, 0xa2, 0x28, - 0x87, 0x88, 0x13, 0xe7, 0x9c, 0x38, 0x45, 0x11, 0x27, 0x47, 0xe2, 0x8f, 0xe0, 0x88, 0x38, 0x71, - 0x0a, 0x91, 0x89, 0x64, 0xfe, 0x8c, 0x68, 0x77, 0x66, 0x89, 0x0d, 0x04, 0x1c, 0x1f, 0x12, 0x29, - 0x17, 0xef, 0xcc, 0xbc, 0xef, 0xbd, 0xf7, 0xbd, 0x6f, 0xde, 0xdb, 0x35, 0xc8, 0x5a, 0x94, 0xb9, - 0x94, 0x99, 0xd0, 0xb2, 0x68, 0x83, 0x70, 0x66, 0xda, 0x68, 0x0b, 0x36, 0x6a, 0x9c, 0x99, 0x35, - 0x6a, 0xed, 0x34, 0xea, 0x26, 0xdf, 0x35, 0xea, 0x1e, 0xe5, 0x54, 0xd5, 0x05, 0xd2, 0x08, 0x91, - 0x46, 0x88, 0x34, 0x04, 0x32, 0x3d, 0x03, 0x5d, 0x87, 0x50, 0x33, 0xf8, 0x15, 0x3e, 0x69, 0x4d, - 0x46, 0xaf, 0x42, 0x86, 0xcc, 0xe6, 0x4a, 0x15, 0x71, 0xb8, 0x62, 0x5a, 0xd4, 0x21, 0xd2, 0xfe, - 0xcd, 0x7d, 0xd9, 0xc5, 0x43, 0xa2, 0xe7, 0x24, 0xda, 0x65, 0xd8, 0x6c, 0xae, 0xf8, 0x0f, 0x69, - 0x98, 0x17, 0x86, 0x4a, 0xb0, 0x33, 0x25, 0x4f, 0x61, 0x4a, 0x62, 0x8a, 0xa9, 0x38, 0xf7, 0x57, - 0xa1, 0x03, 0xa6, 0x14, 0xd7, 0x90, 0x19, 0xec, 0xaa, 0x8d, 0x2d, 0x13, 0x92, 0xb6, 0x34, 0xe9, - 0xd7, 0x4d, 0xdc, 0x71, 0x11, 0xe3, 0xd0, 0x95, 0x2c, 0x32, 0x0f, 0xa3, 0x20, 0x59, 0x62, 0xf8, - 0x0f, 0xe2, 0xf0, 0x3f, 0x03, 0x76, 0x6b, 0x82, 0xbc, 0x6a, 0x80, 0xcf, 0x68, 0x8b, 0x20, 0x2f, - 0xa5, 0x2c, 0x2a, 0xd9, 0x44, 0x31, 0x75, 0x7a, 0x94, 0x4f, 0x4a, 0x2e, 0x6b, 0xb6, 0xed, 0x21, - 0xc6, 0x36, 0xb9, 0xe7, 0x10, 0x5c, 0x16, 0x30, 0x75, 0x1d, 0x8c, 0x23, 0x62, 0x57, 0xfc, 0xf8, - 0xa9, 0xe8, 0xa2, 0x92, 0x9d, 0x58, 0x4d, 0x1b, 0x22, 0xb9, 0x11, 0x26, 0x37, 0xfe, 0x0e, 0x93, - 0x17, 0x27, 0x8f, 0x5f, 0xea, 0x91, 0xfd, 0x73, 0x5d, 0x79, 0xde, 0xeb, 0xe4, 0x94, 0xf2, 0x18, - 0x22, 0xb6, 0x6f, 0x54, 0x7f, 0x07, 0x80, 0x71, 0xe8, 0x71, 0x11, 0x27, 0xf6, 0xbe, 0x71, 0x12, - 0x81, 0xb3, 0x6f, 0x2e, 0x64, 0x2f, 0x0f, 0x74, 0x65, 0xaf, 0xd7, 0xc9, 0xc9, 0x9b, 0xce, 0x33, - 0x7b, 0xc7, 0xbc, 0xad, 0xd2, 0x8c, 0x06, 0xbe, 0xba, 0xed, 0xbc, 0x8c, 0x58, 0x9d, 0x12, 0x86, - 0x32, 0xcf, 0xa2, 0x60, 0x41, 0x02, 0x36, 0x90, 0xe7, 0x50, 0xdb, 0xb1, 0x7c, 0xa0, 0x43, 0xf0, - 0xa8, 0x5a, 0x0d, 0x56, 0x19, 0x1d, 0xbd, 0x4a, 0xf5, 0x01, 0x98, 0xae, 0x09, 0x2e, 0x95, 0x7a, - 0xc0, 0x8d, 0xa5, 0x62, 0x8b, 0xb1, 0xec, 0xc4, 0xea, 0xb2, 0x71, 0x4f, 0x83, 0x1b, 0xa2, 0x96, - 0x62, 0xc2, 0x8f, 0x2d, 0xe2, 0x4e, 0xc9, 0x50, 0xc2, 0xc2, 0x0a, 0xc6, 0xe5, 0x81, 0x1e, 0xf1, - 0x25, 0x5c, 0xba, 0x29, 0xa1, 0xc0, 0x0c, 0x0a, 0xb9, 0x0c, 0x96, 0xee, 0xd4, 0xe9, 0x4a, 0xd1, - 0xae, 0x02, 0x26, 0x4a, 0x0c, 0xaf, 0xa3, 0x1a, 0xc2, 0x90, 0x23, 0xf5, 0x5b, 0x10, 0x67, 0x88, - 0xd8, 0x43, 0x08, 0x28, 0x71, 0xea, 0x5f, 0x60, 0xa6, 0x09, 0x6b, 0x8e, 0x0d, 0x39, 0xf5, 0x2a, - 0x50, 0x40, 0x02, 0x21, 0x13, 0xc5, 0xaf, 0x4f, 0x8f, 0xf2, 0x0b, 0xd2, 0xf9, 0xdf, 0x10, 0x33, - 0x18, 0xe5, 0x8b, 0xe6, 0xb5, 0x73, 0xf5, 0x27, 0x10, 0x87, 0xae, 0xcf, 0x51, 0xf6, 0xdc, 0x7c, - 0x28, 0x9f, 0x3f, 0xeb, 0x86, 0x9c, 0x75, 0xe3, 0x67, 0xea, 0x90, 0x7e, 0xc1, 0xa4, 0x4f, 0x61, - 0xf6, 0xc9, 0x81, 0x1e, 0xf1, 0xc5, 0x7a, 0xd4, 0xeb, 0xe4, 0x24, 0xc5, 0xcc, 0x6b, 0x05, 0x4c, - 0x96, 0x18, 0xfe, 0x87, 0xd8, 0x9f, 0x74, 0x99, 0x87, 0x0a, 0x98, 0x29, 0x31, 0xfc, 0x9f, 0xc3, - 0xb7, 0x6d, 0x0f, 0xb6, 0xca, 0xa8, 0x05, 0x3d, 0xfb, 0xe3, 0x97, 0x7a, 0x3b, 0xd9, 0xc7, 0x51, - 0x30, 0x56, 0x62, 0x78, 0x13, 0x91, 0x51, 0x28, 0xfe, 0x00, 0x00, 0xa7, 0xd7, 0xb8, 0xbd, 0xdb, - 0x2b, 0xc1, 0x69, 0x28, 0x7b, 0xbb, 0x4f, 0xf6, 0xd8, 0xdd, 0xb2, 0xff, 0xea, 0xcb, 0x7e, 0x78, - 0xae, 0x67, 0xb1, 0xc3, 0xb7, 0x1b, 0x55, 0xc3, 0xa2, 0xae, 0xfc, 0x04, 0x98, 0x7d, 0x43, 0xc8, - 0xdb, 0x75, 0xc4, 0x02, 0x07, 0xf6, 0xb4, 0xd7, 0xc9, 0x7d, 0xee, 0x37, 0x98, 0xd5, 0xae, 0xf8, - 0xdf, 0x22, 0x36, 0xc4, 0x9d, 0x6d, 0x80, 0x74, 0x89, 0xe1, 0x5f, 0x76, 0x91, 0xd5, 0xe0, 0xa8, - 0x84, 0x18, 0x83, 0x18, 0xb1, 0x70, 0x3a, 0xd5, 0x55, 0x90, 0xf0, 0xe4, 0x9a, 0xa5, 0x94, 0x80, - 0x70, 0xf2, 0xc6, 0xcb, 0x69, 0x8d, 0xb4, 0xcb, 0x6f, 0x61, 0x99, 0x17, 0x62, 0xa2, 0xc3, 0x2e, - 0x50, 0x7f, 0x04, 0xa0, 0x25, 0xd7, 0x43, 0x08, 0xdc, 0x87, 0x1d, 0x5d, 0xe4, 0x2f, 0x41, 0xdc, - 0x46, 0x84, 0xba, 0xe2, 0x0d, 0x98, 0x28, 0xcb, 0x5d, 0x61, 0xae, 0x5f, 0x81, 0xbe, 0x4c, 0x99, - 0x33, 0x05, 0xcc, 0x0e, 0x74, 0xae, 0xac, 0xff, 0x7b, 0x30, 0xee, 0x21, 0x0b, 0x39, 0xcd, 0x21, - 0x98, 0x5f, 0x21, 0xd5, 0x3d, 0x05, 0x4c, 0x0b, 0xcd, 0x2b, 0xf2, 0xcc, 0x4e, 0x45, 0x3f, 0xd4, - 0x6d, 0x4f, 0x89, 0xcc, 0x65, 0x99, 0xb8, 0xf8, 0xdb, 0x71, 0x57, 0x53, 0x4e, 0xba, 0x9a, 0xf2, - 0xaa, 0xab, 0x29, 0xfb, 0x17, 0x5a, 0xe4, 0xe4, 0x42, 0x8b, 0x9c, 0x5d, 0x68, 0x91, 0xff, 0xf3, - 0x22, 0x2e, 0xb3, 0x77, 0x0c, 0x87, 0x9a, 0xbb, 0x77, 0xfc, 0x53, 0xf2, 0x93, 0x56, 0xe3, 0xc1, - 0x85, 0x7f, 0xf7, 0x26, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xb6, 0xac, 0x3d, 0x59, 0x09, 0x00, 0x00, + // 797 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0x3d, 0x4f, 0x1b, 0x49, + 0x18, 0xf6, 0xda, 0x3a, 0x83, 0x87, 0x03, 0x8e, 0xc5, 0x3a, 0x8c, 0x75, 0xec, 0x72, 0x96, 0x10, + 0x96, 0x75, 0xde, 0x3d, 0xb8, 0x93, 0xee, 0x64, 0x5d, 0x83, 0x8f, 0x7c, 0x49, 0x71, 0x84, 0x4c, + 0x3e, 0xa4, 0xa4, 0xb0, 0xd6, 0xbb, 0xc3, 0xb0, 0xc2, 0x3b, 0x63, 0xed, 0x8c, 0x0d, 0xee, 0xa2, + 0x28, 0x45, 0x44, 0x45, 0x9d, 0x8a, 0x2a, 0x8a, 0x52, 0x39, 0x12, 0x3f, 0x82, 0x12, 0x51, 0x51, + 0x85, 0xc8, 0x44, 0x32, 0x3f, 0x23, 0x9a, 0x9d, 0x59, 0x62, 0x3e, 0x02, 0x8e, 0x8b, 0x14, 0x69, + 0xbc, 0x33, 0xf3, 0x3e, 0xef, 0xfb, 0x3e, 0xcf, 0x33, 0x1f, 0x32, 0xc8, 0xda, 0x84, 0x7a, 0x84, + 0x9a, 0x96, 0x6d, 0x93, 0x06, 0x66, 0xd4, 0x74, 0xe0, 0x9a, 0xd5, 0xa8, 0x31, 0x6a, 0xd6, 0x88, + 0xbd, 0xd1, 0xa8, 0x9b, 0x6c, 0xcb, 0xa8, 0xfb, 0x84, 0x11, 0x55, 0x17, 0x48, 0x23, 0x44, 0x1a, + 0x21, 0xd2, 0x10, 0xc8, 0xf4, 0x84, 0xe5, 0xb9, 0x98, 0x98, 0xc1, 0xaf, 0xc8, 0x49, 0x6b, 0xb2, + 0x7a, 0xd5, 0xa2, 0xd0, 0x6c, 0x2e, 0x54, 0x21, 0xb3, 0x16, 0x4c, 0x9b, 0xb8, 0x58, 0xc6, 0xff, + 0xb8, 0xa9, 0xbb, 0xf8, 0x48, 0xf4, 0x94, 0x44, 0x7b, 0x14, 0x99, 0xcd, 0x05, 0xfe, 0x91, 0x81, + 0x69, 0x11, 0xa8, 0x04, 0x33, 0x53, 0xf2, 0x14, 0xa1, 0x24, 0x22, 0x88, 0x88, 0x75, 0x3e, 0x0a, + 0x13, 0x10, 0x21, 0xa8, 0x06, 0xcd, 0x60, 0x56, 0x6d, 0xac, 0x99, 0x16, 0x6e, 0xc9, 0x90, 0x7e, + 0x31, 0xc4, 0x5c, 0x0f, 0x52, 0x66, 0x79, 0x92, 0x45, 0xe6, 0x79, 0x14, 0x24, 0x4b, 0x14, 0xdd, + 0xc3, 0x2e, 0xbb, 0x1f, 0xb0, 0x5b, 0x12, 0xe4, 0x55, 0x03, 0xfc, 0x44, 0x36, 0x31, 0xf4, 0x53, + 0xca, 0xac, 0x92, 0x4d, 0x14, 0x53, 0x87, 0x7b, 0xf9, 0xa4, 0xe4, 0xb2, 0xe4, 0x38, 0x3e, 0xa4, + 0x74, 0x95, 0xf9, 0x2e, 0x46, 0x65, 0x01, 0x53, 0x97, 0xc1, 0x30, 0xc4, 0x4e, 0x85, 0xd7, 0x4f, + 0x45, 0x67, 0x95, 0xec, 0xc8, 0x62, 0xda, 0x10, 0xcd, 0x8d, 0xb0, 0xb9, 0xf1, 0x30, 0x6c, 0x5e, + 0x1c, 0xdd, 0xff, 0xa0, 0x47, 0x76, 0x8e, 0x75, 0xe5, 0x6d, 0xb7, 0x9d, 0x53, 0xca, 0x43, 0x10, + 0x3b, 0x3c, 0xa8, 0xde, 0x05, 0x80, 0x32, 0xcb, 0x67, 0xa2, 0x4e, 0xec, 0x5b, 0xeb, 0x24, 0x82, + 0x64, 0x1e, 0x2e, 0x64, 0x4f, 0x77, 0x75, 0x65, 0xbb, 0xdb, 0xce, 0xc9, 0x9d, 0xce, 0x53, 0x67, + 0xc3, 0xbc, 0x4a, 0x69, 0x46, 0x03, 0xbf, 0x5d, 0xb5, 0x5e, 0x86, 0xb4, 0x4e, 0x30, 0x85, 0x99, + 0x37, 0x51, 0x30, 0x23, 0x01, 0x2b, 0xd0, 0x77, 0x89, 0xe3, 0xda, 0x1c, 0xe8, 0x62, 0x34, 0xa8, + 0x57, 0xe7, 0x55, 0x46, 0x07, 0x57, 0xa9, 0x3e, 0x03, 0xe3, 0x35, 0xc1, 0xa5, 0x52, 0x0f, 0xb8, + 0xd1, 0x54, 0x6c, 0x36, 0x96, 0x1d, 0x59, 0x9c, 0x37, 0x6e, 0x38, 0xe0, 0x86, 0xd0, 0x52, 0x4c, + 0xf0, 0xda, 0xa2, 0xee, 0x98, 0x2c, 0x25, 0x22, 0xb4, 0x60, 0x9c, 0xee, 0xea, 0x11, 0x6e, 0xe1, + 0xdc, 0x65, 0x0b, 0x05, 0xe6, 0xbc, 0x91, 0xf3, 0x60, 0xee, 0x5a, 0x9f, 0xce, 0x1c, 0xed, 0x28, + 0x60, 0xa4, 0x44, 0xd1, 0x32, 0xac, 0x41, 0x64, 0x31, 0xa8, 0xfe, 0x09, 0xe2, 0x14, 0x62, 0xa7, + 0x0f, 0x03, 0x25, 0x4e, 0x7d, 0x00, 0x26, 0x9a, 0x56, 0xcd, 0x75, 0x2c, 0x46, 0xfc, 0x8a, 0x25, + 0x20, 0x81, 0x91, 0x89, 0xe2, 0xef, 0x87, 0x7b, 0xf9, 0x19, 0x99, 0xfc, 0x38, 0xc4, 0x9c, 0xaf, + 0xf2, 0x4b, 0xf3, 0xc2, 0xba, 0xfa, 0x1f, 0x88, 0x5b, 0x1e, 0xe7, 0x28, 0xcf, 0xdc, 0x74, 0x68, + 0x1f, 0xbf, 0xeb, 0x86, 0xbc, 0xeb, 0xc6, 0xff, 0xc4, 0xc5, 0xbd, 0x86, 0xc9, 0x9c, 0xc2, 0xe4, + 0xab, 0x5d, 0x3d, 0xc2, 0xcd, 0x7a, 0xd1, 0x6d, 0xe7, 0x24, 0xc5, 0xcc, 0x27, 0x05, 0x8c, 0x96, + 0x28, 0x7a, 0x84, 0x9d, 0x1f, 0x5a, 0xe6, 0xcb, 0x28, 0x18, 0x2a, 0x51, 0xb4, 0x0a, 0xb1, 0x33, + 0x80, 0xc0, 0x7f, 0x00, 0x60, 0xe4, 0x82, 0xb2, 0xaf, 0x67, 0x25, 0x18, 0x09, 0x95, 0xb4, 0x7a, + 0x94, 0xc4, 0xae, 0x57, 0x72, 0x9b, 0x2b, 0x79, 0x77, 0xac, 0x67, 0x91, 0xcb, 0xd6, 0x1b, 0x55, + 0xc3, 0x26, 0x9e, 0x7c, 0x55, 0xcd, 0x9e, 0x73, 0xcd, 0x5a, 0x75, 0x48, 0x83, 0x04, 0xfa, 0xba, + 0xdb, 0xce, 0xfd, 0xcc, 0xf7, 0xcc, 0x6e, 0x55, 0xf8, 0xf3, 0x4e, 0xfb, 0xb0, 0x61, 0x05, 0xa4, + 0x4b, 0x14, 0xdd, 0xda, 0x82, 0x76, 0x83, 0xc1, 0x12, 0xa4, 0xd4, 0x42, 0x90, 0x86, 0x07, 0x5e, + 0x5d, 0x04, 0x09, 0x5f, 0x8e, 0x69, 0x4a, 0x09, 0x08, 0x27, 0x2f, 0xdd, 0xf7, 0x25, 0xdc, 0x2a, + 0x7f, 0x81, 0x65, 0xde, 0x8b, 0x4b, 0xf2, 0xc4, 0x65, 0xeb, 0x8e, 0x6f, 0x6d, 0xaa, 0xff, 0x02, + 0xb0, 0x29, 0xc7, 0x7d, 0x18, 0xdc, 0x83, 0x1d, 0xdc, 0xe4, 0x5f, 0x41, 0xdc, 0x81, 0x98, 0x78, + 0xe2, 0x51, 0x49, 0x94, 0xe5, 0xac, 0x30, 0xd5, 0xeb, 0x40, 0x4f, 0xa7, 0xcc, 0x91, 0x02, 0x26, + 0x7b, 0x38, 0x9f, 0xe9, 0xff, 0x1b, 0x0c, 0xfb, 0xd0, 0x86, 0x6e, 0xb3, 0x0f, 0xe6, 0x67, 0x48, + 0x75, 0x5b, 0x01, 0xe3, 0xc2, 0xf3, 0x8a, 0x5c, 0x73, 0x52, 0xd1, 0xef, 0xb5, 0xdb, 0x63, 0xa2, + 0x73, 0x59, 0x36, 0x2e, 0xde, 0xd9, 0xef, 0x68, 0xca, 0x41, 0x47, 0x53, 0x3e, 0x76, 0x34, 0x65, + 0xe7, 0x44, 0x8b, 0x1c, 0x9c, 0x68, 0x91, 0xa3, 0x13, 0x2d, 0xf2, 0x34, 0x2f, 0xea, 0x52, 0x67, + 0xc3, 0x70, 0x89, 0xb9, 0x75, 0xcd, 0x9f, 0x0f, 0xde, 0xb4, 0x1a, 0x0f, 0x36, 0xfc, 0xaf, 0xcf, + 0x01, 0x00, 0x00, 0xff, 0xff, 0xf7, 0xd7, 0x1d, 0x22, 0xac, 0x08, 0x00, 0x00, } func (this *MsgInitLockupAccount) Equal(that interface{}) bool { @@ -877,43 +836,6 @@ func (m *MsgUndelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgWithdrawReward) 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 *MsgWithdrawReward) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgWithdrawReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ValidatorAddress) > 0 { - i -= len(m.ValidatorAddress) - copy(dAtA[i:], m.ValidatorAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorAddress))) - i-- - dAtA[i] = 0x12 - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *MsgSend) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1197,23 +1119,6 @@ func (m *MsgUndelegate) Size() (n int) { return n } -func (m *MsgWithdrawReward) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ValidatorAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - func (m *MsgSend) Size() (n int) { if m == nil { return 0 @@ -1991,120 +1896,6 @@ func (m *MsgUndelegate) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgWithdrawReward) 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: MsgWithdrawReward: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgWithdrawReward: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = 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 *MsgSend) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto b/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto index cbc99cc2b97..a0a6e1a07ae 100644 --- a/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto +++ b/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto @@ -79,17 +79,6 @@ message MsgUndelegate { cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } -// MsgWithdrawReward defines a message that enable lockup account to withdraw staking reward -message MsgWithdrawReward { - option (cosmos.msg.v1.signer) = "sender"; - - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"]; -} - // MsgSend defines a message that enable lockup account to execute send message message MsgSend { option (cosmos.msg.v1.signer) = "sender"; From 375b789bbef6c5830a166076f210658548f9f5f6 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Sun, 14 Apr 2024 23:15:31 +0700 Subject: [PATCH 05/22] minor --- x/accounts/defaults/lockup/go.mod | 1 - 1 file changed, 1 deletion(-) diff --git a/x/accounts/defaults/lockup/go.mod b/x/accounts/defaults/lockup/go.mod index 91e27213b9a..c84c627efbe 100644 --- a/x/accounts/defaults/lockup/go.mod +++ b/x/accounts/defaults/lockup/go.mod @@ -22,7 +22,6 @@ require ( cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.0.2 // indirect cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 // indirect - cosmossdk.io/x/distribution v0.0.0-20240410222740-c56152dfac35 cosmossdk.io/x/tx v0.13.1 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect From fd69fd3a980af5c5f97b96cba13f6f8a807779d5 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Sun, 14 Apr 2024 23:27:40 +0700 Subject: [PATCH 06/22] minor --- x/accounts/defaults/lockup/lockup.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index f66aef1a4de..43d6314c8a1 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -7,7 +7,6 @@ import ( "time" "github.com/cosmos/gogoproto/proto" - "google.golang.org/protobuf/runtime/protoiface" "cosmossdk.io/collections" collcodec "cosmossdk.io/collections/codec" @@ -26,8 +25,6 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -type ProtoMsg = protoiface.MessageV1 - var ( OriginalLockingPrefix = collections.NewPrefix(0) DelegatedFreePrefix = collections.NewPrefix(1) @@ -526,7 +523,7 @@ func (bva *BaseLockup) TrackUndelegation(ctx context.Context, amount sdk.Coins) func (bva BaseLockup) getBalance(ctx context.Context, sender, denom string) (*sdk.Coin, error) { // Query account balance for the sent denom - balanceQueryReq := banktypes.NewQueryBalanceRequest(sender, denom) + balanceQueryReq := &banktypes.QueryBalanceRequest{Address: sender, Denom: denom} resp, err := accountstd.QueryModule[banktypes.QueryBalanceResponse](ctx, balanceQueryReq) if err != nil { return nil, err @@ -571,7 +568,7 @@ func (bva BaseLockup) checkTokensSendable(ctx context.Context, sender string, am return nil } -// IterateSendEnabledEntries iterates over all the SendEnabled entries. +// IterateCoinEntries iterates over all the CoinEntries entries. func (bva BaseLockup) IterateCoinEntries( ctx context.Context, entries collections.Map[string, math.Int], From 4fe5ffdfb6d22740b562c5adf14690afcafd62da Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Sun, 14 Apr 2024 23:35:22 +0700 Subject: [PATCH 07/22] minor --- .../defaults/lockup/continuous_locking_account.go | 10 +++++----- x/accounts/defaults/lockup/periodic_locking_account.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/x/accounts/defaults/lockup/continuous_locking_account.go b/x/accounts/defaults/lockup/continuous_locking_account.go index 368c7891692..c1d8daf571a 100644 --- a/x/accounts/defaults/lockup/continuous_locking_account.go +++ b/x/accounts/defaults/lockup/continuous_locking_account.go @@ -89,15 +89,15 @@ func (cva ContinuousLockingAccount) GetLockCoinsInfo(ctx context.Context, blockT unlockedCoins = sdk.Coins{} lockedCoins = sdk.Coins{} - var originalVesting sdk.Coins + var originalLocking sdk.Coins err = cva.IterateCoinEntries(ctx, cva.OriginalLocking, func(key string, value math.Int) (stop bool, err error) { - originalVesting = append(originalVesting, sdk.NewCoin(key, value)) - vestedCoin, vestingCoin, err := cva.GetLockCoinInfoWithDenom(ctx, blockTime, key) + originalLocking = append(originalLocking, sdk.NewCoin(key, value)) + unlockedCoin, lockedCoin, err := cva.GetLockCoinInfoWithDenom(ctx, blockTime, key) if err != nil { return true, err } - unlockedCoins = append(unlockedCoins, *vestedCoin) - lockedCoins = append(lockedCoins, *vestingCoin) + unlockedCoins = append(unlockedCoins, *unlockedCoin) + lockedCoins = append(lockedCoins, *lockedCoin) return false, nil }) if err != nil { diff --git a/x/accounts/defaults/lockup/periodic_locking_account.go b/x/accounts/defaults/lockup/periodic_locking_account.go index 4680892b53e..03de1add76f 100644 --- a/x/accounts/defaults/lockup/periodic_locking_account.go +++ b/x/accounts/defaults/lockup/periodic_locking_account.go @@ -141,7 +141,7 @@ func (pva *PeriodicLockingAccount) WithdrawUnlockedCoins(ctx context.Context, ms return pva.BaseLockup.WithdrawUnlockedCoins(ctx, msg, pva.GetLockedCoinsWithDenoms) } -// IterateSendEnabledEntries iterates over all the SendEnabled entries. +// IteratePeriods iterates over all the Periods entries. func (pva PeriodicLockingAccount) IteratePeriods( ctx context.Context, cb func(value lockuptypes.Period) (bool, error), From 83eca87f5235a03f60a0f00bae48d09f99c983ee Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Mon, 15 Apr 2024 12:54:57 +0700 Subject: [PATCH 08/22] add withdraw reward --- .../accounts/defaults/lockup/tx.pulsar.go | 748 +++++++++++++++--- .../lockup/continuous_locking_account.go | 8 +- .../lockup/delayed_locking_account.go | 8 +- x/accounts/defaults/lockup/go.mod | 10 + x/accounts/defaults/lockup/go.sum | 5 + x/accounts/defaults/lockup/lockup.go | 33 + .../lockup/periodic_locking_account.go | 8 +- .../lockup/permanent_locking_account.go | 2 +- x/accounts/defaults/lockup/types/tx.pb.go | 319 ++++++-- .../cosmos/accounts/defaults/lockup/tx.proto | 11 + 10 files changed, 977 insertions(+), 175 deletions(-) diff --git a/api/cosmos/accounts/defaults/lockup/tx.pulsar.go b/api/cosmos/accounts/defaults/lockup/tx.pulsar.go index 082db8883c5..5483fe9c096 100644 --- a/api/cosmos/accounts/defaults/lockup/tx.pulsar.go +++ b/api/cosmos/accounts/defaults/lockup/tx.pulsar.go @@ -3072,6 +3072,490 @@ func (x *fastReflection_MsgUndelegate) ProtoMethods() *protoiface.Methods { } } +var ( + md_MsgWithdrawReward protoreflect.MessageDescriptor + fd_MsgWithdrawReward_sender protoreflect.FieldDescriptor + fd_MsgWithdrawReward_validator_address protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_accounts_defaults_lockup_tx_proto_init() + md_MsgWithdrawReward = File_cosmos_accounts_defaults_lockup_tx_proto.Messages().ByName("MsgWithdrawReward") + fd_MsgWithdrawReward_sender = md_MsgWithdrawReward.Fields().ByName("sender") + fd_MsgWithdrawReward_validator_address = md_MsgWithdrawReward.Fields().ByName("validator_address") +} + +var _ protoreflect.Message = (*fastReflection_MsgWithdrawReward)(nil) + +type fastReflection_MsgWithdrawReward MsgWithdrawReward + +func (x *MsgWithdrawReward) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgWithdrawReward)(x) +} + +func (x *MsgWithdrawReward) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_MsgWithdrawReward_messageType fastReflection_MsgWithdrawReward_messageType +var _ protoreflect.MessageType = fastReflection_MsgWithdrawReward_messageType{} + +type fastReflection_MsgWithdrawReward_messageType struct{} + +func (x fastReflection_MsgWithdrawReward_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgWithdrawReward)(nil) +} +func (x fastReflection_MsgWithdrawReward_messageType) New() protoreflect.Message { + return new(fastReflection_MsgWithdrawReward) +} +func (x fastReflection_MsgWithdrawReward_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgWithdrawReward +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgWithdrawReward) Descriptor() protoreflect.MessageDescriptor { + return md_MsgWithdrawReward +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_MsgWithdrawReward) Type() protoreflect.MessageType { + return _fastReflection_MsgWithdrawReward_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgWithdrawReward) New() protoreflect.Message { + return new(fastReflection_MsgWithdrawReward) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgWithdrawReward) Interface() protoreflect.ProtoMessage { + return (*MsgWithdrawReward)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_MsgWithdrawReward) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Sender != "" { + value := protoreflect.ValueOfString(x.Sender) + if !f(fd_MsgWithdrawReward_sender, value) { + return + } + } + if x.ValidatorAddress != "" { + value := protoreflect.ValueOfString(x.ValidatorAddress) + if !f(fd_MsgWithdrawReward_validator_address, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_MsgWithdrawReward) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + return x.Sender != "" + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + return x.ValidatorAddress != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgWithdrawReward) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + x.Sender = "" + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + x.ValidatorAddress = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_MsgWithdrawReward) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + value := x.Sender + return protoreflect.ValueOfString(value) + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + value := x.ValidatorAddress + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgWithdrawReward) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + x.Sender = value.Interface().(string) + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + x.ValidatorAddress = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgWithdrawReward) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + panic(fmt.Errorf("field sender of message cosmos.accounts.defaults.lockup.MsgWithdrawReward is not mutable")) + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + panic(fmt.Errorf("field validator_address of message cosmos.accounts.defaults.lockup.MsgWithdrawReward is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_MsgWithdrawReward) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.sender": + return protoreflect.ValueOfString("") + case "cosmos.accounts.defaults.lockup.MsgWithdrawReward.validator_address": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.lockup.MsgWithdrawReward")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.lockup.MsgWithdrawReward does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_MsgWithdrawReward) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.defaults.lockup.MsgWithdrawReward", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_MsgWithdrawReward) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgWithdrawReward) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_MsgWithdrawReward) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_MsgWithdrawReward) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgWithdrawReward) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Sender) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.ValidatorAddress) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgWithdrawReward) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.ValidatorAddress) > 0 { + i -= len(x.ValidatorAddress) + copy(dAtA[i:], x.ValidatorAddress) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(x.Sender) > 0 { + i -= len(x.Sender) + copy(dAtA[i:], x.Sender) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Sender))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*MsgWithdrawReward) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgWithdrawReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgWithdrawReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + var _ protoreflect.List = (*_MsgSend_3_list)(nil) type _MsgSend_3_list struct { @@ -3147,7 +3631,7 @@ func (x *MsgSend) ProtoReflect() protoreflect.Message { } func (x *MsgSend) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3765,7 +4249,7 @@ func (x *MsgExecuteMessagesResponse) ProtoReflect() protoreflect.Message { } func (x *MsgExecuteMessagesResponse) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4258,7 +4742,7 @@ func (x *MsgWithdraw) ProtoReflect() protoreflect.Message { } func (x *MsgWithdraw) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4869,7 +5353,7 @@ func (x *MsgWithdrawResponse) ProtoReflect() protoreflect.Message { } func (x *MsgWithdrawResponse) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -5638,6 +6122,50 @@ func (x *MsgUndelegate) GetAmount() *v1beta1.Coin { return nil } +// MsgWithdrawReward defines a message that enable lockup account to execute withdraw reward message +type MsgWithdrawReward struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` +} + +func (x *MsgWithdrawReward) Reset() { + *x = MsgWithdrawReward{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgWithdrawReward) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgWithdrawReward) ProtoMessage() {} + +// Deprecated: Use MsgWithdrawReward.ProtoReflect.Descriptor instead. +func (*MsgWithdrawReward) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{6} +} + +func (x *MsgWithdrawReward) GetSender() string { + if x != nil { + return x.Sender + } + return "" +} + +func (x *MsgWithdrawReward) GetValidatorAddress() string { + if x != nil { + return x.ValidatorAddress + } + return "" +} + // MsgSend defines a message that enable lockup account to execute send message type MsgSend struct { state protoimpl.MessageState @@ -5652,7 +6180,7 @@ type MsgSend struct { func (x *MsgSend) Reset() { *x = MsgSend{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5666,7 +6194,7 @@ func (*MsgSend) ProtoMessage() {} // Deprecated: Use MsgSend.ProtoReflect.Descriptor instead. func (*MsgSend) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{6} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{7} } func (x *MsgSend) GetSender() string { @@ -5702,7 +6230,7 @@ type MsgExecuteMessagesResponse struct { func (x *MsgExecuteMessagesResponse) Reset() { *x = MsgExecuteMessagesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5716,7 +6244,7 @@ func (*MsgExecuteMessagesResponse) ProtoMessage() {} // Deprecated: Use MsgExecuteMessagesResponse.ProtoReflect.Descriptor instead. func (*MsgExecuteMessagesResponse) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{7} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{8} } func (x *MsgExecuteMessagesResponse) GetResponses() []*anypb.Any { @@ -5741,7 +6269,7 @@ type MsgWithdraw struct { func (x *MsgWithdraw) Reset() { *x = MsgWithdraw{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5755,7 +6283,7 @@ func (*MsgWithdraw) ProtoMessage() {} // Deprecated: Use MsgWithdraw.ProtoReflect.Descriptor instead. func (*MsgWithdraw) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{8} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{9} } func (x *MsgWithdraw) GetWithdrawer() string { @@ -5792,7 +6320,7 @@ type MsgWithdrawResponse struct { func (x *MsgWithdrawResponse) Reset() { *x = MsgWithdrawResponse{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9] + mi := &file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5806,7 +6334,7 @@ func (*MsgWithdrawResponse) ProtoMessage() {} // Deprecated: Use MsgWithdrawResponse.ProtoReflect.Descriptor instead. func (*MsgWithdrawResponse) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{9} + return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP(), []int{10} } func (x *MsgWithdrawResponse) GetReceiver() string { @@ -5913,70 +6441,81 @@ var file_cosmos_accounts_defaults_lockup_tx_proto_rawDesc = []byte{ 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x13, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x65, 0x6e, - 0x64, 0x65, 0x72, 0x22, 0x84, 0x02, 0x0a, 0x07, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x6e, 0x64, 0x12, - 0x30, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, - 0x72, 0x12, 0x37, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, - 0x09, 0x74, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x79, 0x0a, 0x06, 0x61, 0x6d, - 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, - 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, - 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, - 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x13, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, - 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x1a, 0x4d, 0x73, - 0x67, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, - 0x79, 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0xb1, 0x01, 0x0a, - 0x0b, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x12, 0x38, 0x0a, 0x0a, - 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x0a, 0x77, 0x69, 0x74, 0x68, - 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x74, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, - 0x16, 0x0a, 0x06, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x06, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x73, 0x3a, 0x17, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, - 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x0a, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, - 0x22, 0xd8, 0x01, 0x0a, 0x13, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, - 0x69, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x12, 0x8a, - 0x01, 0x0a, 0x0f, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, - 0x65, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, - 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, - 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, - 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0e, 0x61, 0x6d, 0x6f, - 0x75, 0x6e, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x42, 0x80, 0x02, 0x0a, 0x23, - 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x73, 0x2e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x6c, 0x6f, 0x63, - 0x6b, 0x75, 0x70, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, - 0x2f, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2f, 0x6c, 0x6f, 0x63, 0x6b, 0x75, 0x70, - 0xa2, 0x02, 0x04, 0x43, 0x41, 0x44, 0x4c, 0xaa, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, - 0x74, 0x73, 0x2e, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xca, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xe2, 0x02, 0x2b, 0x43, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, - 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x22, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, 0x44, 0x65, - 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x3a, 0x3a, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x65, 0x72, 0x22, 0xaa, 0x01, 0x0a, 0x11, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, + 0x72, 0x61, 0x77, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x12, 0x30, 0x0a, 0x06, 0x73, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x4e, 0x0a, 0x11, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x21, 0xd2, 0xb4, 0x2d, 0x1d, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x3a, 0x13, 0x88, 0xa0, 0x1f, + 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, + 0x22, 0x84, 0x02, 0x0a, 0x07, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x6e, 0x64, 0x12, 0x30, 0x0a, 0x06, + 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, + 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x37, + 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x74, 0x6f, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x79, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, + 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, + 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, + 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, + 0x6e, 0x74, 0x3a, 0x13, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, + 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x1a, 0x4d, 0x73, 0x67, 0x45, 0x78, + 0x65, 0x63, 0x75, 0x74, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x09, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0xb1, 0x01, 0x0a, 0x0b, 0x4d, 0x73, + 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x12, 0x38, 0x0a, 0x0a, 0x77, 0x69, 0x74, + 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, + 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x0a, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, + 0x77, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x52, 0x09, 0x74, 0x6f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, + 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x64, 0x65, + 0x6e, 0x6f, 0x6d, 0x73, 0x3a, 0x17, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, + 0xb0, 0x2a, 0x0a, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x65, 0x72, 0x22, 0xd8, 0x01, + 0x0a, 0x13, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x12, 0x8a, 0x01, 0x0a, 0x0f, + 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, + 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, + 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, + 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x63, 0x6f, + 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0e, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x42, 0x80, 0x02, 0x0a, 0x23, 0x63, 0x6f, 0x6d, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, + 0x2e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x75, 0x70, + 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x64, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2f, 0x6c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xa2, 0x02, 0x04, + 0x43, 0x41, 0x44, 0x4c, 0xaa, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, + 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xca, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, + 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0xe2, 0x02, 0x2b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x73, 0x5c, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x22, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, + 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, 0x44, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x73, 0x3a, 0x3a, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -5991,7 +6530,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_rawDescGZIP() []byte { return file_cosmos_accounts_defaults_lockup_tx_proto_rawDescData } -var file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_cosmos_accounts_defaults_lockup_tx_proto_goTypes = []interface{}{ (*MsgInitLockupAccount)(nil), // 0: cosmos.accounts.defaults.lockup.MsgInitLockupAccount (*MsgInitLockupAccountResponse)(nil), // 1: cosmos.accounts.defaults.lockup.MsgInitLockupAccountResponse @@ -5999,25 +6538,26 @@ var file_cosmos_accounts_defaults_lockup_tx_proto_goTypes = []interface{}{ (*MsgInitPeriodicLockingAccountResponse)(nil), // 3: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccountResponse (*MsgDelegate)(nil), // 4: cosmos.accounts.defaults.lockup.MsgDelegate (*MsgUndelegate)(nil), // 5: cosmos.accounts.defaults.lockup.MsgUndelegate - (*MsgSend)(nil), // 6: cosmos.accounts.defaults.lockup.MsgSend - (*MsgExecuteMessagesResponse)(nil), // 7: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse - (*MsgWithdraw)(nil), // 8: cosmos.accounts.defaults.lockup.MsgWithdraw - (*MsgWithdrawResponse)(nil), // 9: cosmos.accounts.defaults.lockup.MsgWithdrawResponse - (*timestamppb.Timestamp)(nil), // 10: google.protobuf.Timestamp - (*Period)(nil), // 11: cosmos.accounts.defaults.lockup.Period - (*v1beta1.Coin)(nil), // 12: cosmos.base.v1beta1.Coin - (*anypb.Any)(nil), // 13: google.protobuf.Any + (*MsgWithdrawReward)(nil), // 6: cosmos.accounts.defaults.lockup.MsgWithdrawReward + (*MsgSend)(nil), // 7: cosmos.accounts.defaults.lockup.MsgSend + (*MsgExecuteMessagesResponse)(nil), // 8: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse + (*MsgWithdraw)(nil), // 9: cosmos.accounts.defaults.lockup.MsgWithdraw + (*MsgWithdrawResponse)(nil), // 10: cosmos.accounts.defaults.lockup.MsgWithdrawResponse + (*timestamppb.Timestamp)(nil), // 11: google.protobuf.Timestamp + (*Period)(nil), // 12: cosmos.accounts.defaults.lockup.Period + (*v1beta1.Coin)(nil), // 13: cosmos.base.v1beta1.Coin + (*anypb.Any)(nil), // 14: google.protobuf.Any } var file_cosmos_accounts_defaults_lockup_tx_proto_depIdxs = []int32{ - 10, // 0: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.end_time:type_name -> google.protobuf.Timestamp - 10, // 1: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.start_time:type_name -> google.protobuf.Timestamp - 10, // 2: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.start_time:type_name -> google.protobuf.Timestamp - 11, // 3: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.locking_periods:type_name -> cosmos.accounts.defaults.lockup.Period - 12, // 4: cosmos.accounts.defaults.lockup.MsgDelegate.amount:type_name -> cosmos.base.v1beta1.Coin - 12, // 5: cosmos.accounts.defaults.lockup.MsgUndelegate.amount:type_name -> cosmos.base.v1beta1.Coin - 12, // 6: cosmos.accounts.defaults.lockup.MsgSend.amount:type_name -> cosmos.base.v1beta1.Coin - 13, // 7: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse.responses:type_name -> google.protobuf.Any - 12, // 8: cosmos.accounts.defaults.lockup.MsgWithdrawResponse.amount_received:type_name -> cosmos.base.v1beta1.Coin + 11, // 0: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.end_time:type_name -> google.protobuf.Timestamp + 11, // 1: cosmos.accounts.defaults.lockup.MsgInitLockupAccount.start_time:type_name -> google.protobuf.Timestamp + 11, // 2: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.start_time:type_name -> google.protobuf.Timestamp + 12, // 3: cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccount.locking_periods:type_name -> cosmos.accounts.defaults.lockup.Period + 13, // 4: cosmos.accounts.defaults.lockup.MsgDelegate.amount:type_name -> cosmos.base.v1beta1.Coin + 13, // 5: cosmos.accounts.defaults.lockup.MsgUndelegate.amount:type_name -> cosmos.base.v1beta1.Coin + 13, // 6: cosmos.accounts.defaults.lockup.MsgSend.amount:type_name -> cosmos.base.v1beta1.Coin + 14, // 7: cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse.responses:type_name -> google.protobuf.Any + 13, // 8: cosmos.accounts.defaults.lockup.MsgWithdrawResponse.amount_received:type_name -> cosmos.base.v1beta1.Coin 9, // [9:9] is the sub-list for method output_type 9, // [9:9] is the sub-list for method input_type 9, // [9:9] is the sub-list for extension type_name @@ -6105,7 +6645,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { } } file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MsgSend); i { + switch v := v.(*MsgWithdrawReward); i { case 0: return &v.state case 1: @@ -6117,7 +6657,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { } } file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MsgExecuteMessagesResponse); i { + switch v := v.(*MsgSend); i { case 0: return &v.state case 1: @@ -6129,7 +6669,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { } } file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MsgWithdraw); i { + switch v := v.(*MsgExecuteMessagesResponse); i { case 0: return &v.state case 1: @@ -6141,6 +6681,18 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { } } file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgWithdraw); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_accounts_defaults_lockup_tx_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MsgWithdrawResponse); i { case 0: return &v.state @@ -6159,7 +6711,7 @@ func file_cosmos_accounts_defaults_lockup_tx_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_accounts_defaults_lockup_tx_proto_rawDesc, NumEnums: 0, - NumMessages: 10, + NumMessages: 11, NumExtensions: 0, NumServices: 0, }, diff --git a/x/accounts/defaults/lockup/continuous_locking_account.go b/x/accounts/defaults/lockup/continuous_locking_account.go index c38a48d4ee0..2114f060348 100644 --- a/x/accounts/defaults/lockup/continuous_locking_account.go +++ b/x/accounts/defaults/lockup/continuous_locking_account.go @@ -66,12 +66,6 @@ func (cva *ContinuousLockingAccount) Delegate(ctx context.Context, msg *lockupty return cva.BaseLockup.Delegate(ctx, msg, cva.GetLockedCoinsWithDenoms) } -func (cva *ContinuousLockingAccount) Undelegate(ctx context.Context, msg *lockuptypes.MsgUndelegate) ( - *lockuptypes.MsgExecuteMessagesResponse, error, -) { - return cva.BaseLockup.Undelegate(ctx, msg) -} - func (cva *ContinuousLockingAccount) SendCoins(ctx context.Context, msg *lockuptypes.MsgSend) ( *lockuptypes.MsgExecuteMessagesResponse, error, ) { @@ -215,9 +209,9 @@ func (cva ContinuousLockingAccount) RegisterInitHandler(builder *accountstd.Init func (cva ContinuousLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, cva.Delegate) - accountstd.RegisterExecuteHandler(builder, cva.Undelegate) accountstd.RegisterExecuteHandler(builder, cva.SendCoins) accountstd.RegisterExecuteHandler(builder, cva.WithdrawUnlockedCoins) + cva.BaseLockup.RegisterExecuteHandlers(builder) } func (cva ContinuousLockingAccount) RegisterQueryHandlers(builder *accountstd.QueryBuilder) { diff --git a/x/accounts/defaults/lockup/delayed_locking_account.go b/x/accounts/defaults/lockup/delayed_locking_account.go index dbc19d96008..f5b63d6d0cb 100644 --- a/x/accounts/defaults/lockup/delayed_locking_account.go +++ b/x/accounts/defaults/lockup/delayed_locking_account.go @@ -43,12 +43,6 @@ func (dva *DelayedLockingAccount) Delegate(ctx context.Context, msg *lockuptypes return dva.BaseLockup.Delegate(ctx, msg, dva.GetLockedCoinsWithDenoms) } -func (dva *DelayedLockingAccount) Undelegate(ctx context.Context, msg *lockuptypes.MsgUndelegate) ( - *lockuptypes.MsgExecuteMessagesResponse, error, -) { - return dva.BaseLockup.Undelegate(ctx, msg) -} - func (dva *DelayedLockingAccount) SendCoins(ctx context.Context, msg *lockuptypes.MsgSend) ( *lockuptypes.MsgExecuteMessagesResponse, error, ) { @@ -148,9 +142,9 @@ func (dva DelayedLockingAccount) RegisterInitHandler(builder *accountstd.InitBui func (dva DelayedLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, dva.Delegate) - accountstd.RegisterExecuteHandler(builder, dva.Undelegate) accountstd.RegisterExecuteHandler(builder, dva.SendCoins) accountstd.RegisterExecuteHandler(builder, dva.WithdrawUnlockedCoins) + dva.BaseLockup.RegisterExecuteHandlers(builder) } func (dva DelayedLockingAccount) RegisterQueryHandlers(builder *accountstd.QueryBuilder) { diff --git a/x/accounts/defaults/lockup/go.mod b/x/accounts/defaults/lockup/go.mod index ca699d48ebd..7fcf42e8671 100644 --- a/x/accounts/defaults/lockup/go.mod +++ b/x/accounts/defaults/lockup/go.mod @@ -11,6 +11,15 @@ require ( github.com/cosmos/gogoproto v1.4.12 ) +require ( + cosmossdk.io/depinject v1.0.0-alpha.4 // indirect + cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect + github.com/golang/mock v1.6.0 // indirect + github.com/google/orderedcode v0.0.1 // indirect + github.com/lib/pq v1.10.7 // indirect + github.com/minio/highwayhash v1.0.2 // indirect +) + require ( buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.32.0-20240130113600-88ef6483f90f.1 // indirect buf.build/gen/go/tendermint/tendermint/protocolbuffers/go v1.32.0-20231117195010-33ed361a9051.1 // indirect @@ -20,6 +29,7 @@ require ( cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.0.2 // indirect cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 // indirect + cosmossdk.io/x/distribution v0.0.0-00010101000000-000000000000 cosmossdk.io/x/tx v0.13.1 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect diff --git a/x/accounts/defaults/lockup/go.sum b/x/accounts/defaults/lockup/go.sum index 13ac00c9387..ee17c081ef4 100644 --- a/x/accounts/defaults/lockup/go.sum +++ b/x/accounts/defaults/lockup/go.sum @@ -661,6 +661,7 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= @@ -720,6 +721,7 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -761,6 +763,7 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -772,6 +775,7 @@ golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -852,6 +856,7 @@ golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index 71e7687c842..f72373d62ae 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -17,6 +17,7 @@ import ( "cosmossdk.io/x/accounts/accountstd" lockuptypes "cosmossdk.io/x/accounts/defaults/lockup/types" banktypes "cosmossdk.io/x/bank/types" + distrtypes "cosmossdk.io/x/distribution/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -194,6 +195,33 @@ func (bva *BaseLockup) Undelegate( return &lockuptypes.MsgExecuteMessagesResponse{Responses: responses}, nil } +func (bva *BaseLockup) WithdrawReward( + ctx context.Context, msg *lockuptypes.MsgWithdrawReward, +) ( + *lockuptypes.MsgExecuteMessagesResponse, error, +) { + err := bva.checkSender(ctx, msg.Sender) + if err != nil { + return nil, err + } + whoami := accountstd.Whoami(ctx) + delegatorAddress, err := bva.addressCodec.BytesToString(whoami) + if err != nil { + return nil, err + } + + msgWithdraw := &distrtypes.MsgWithdrawDelegatorReward{ + DelegatorAddress: delegatorAddress, + ValidatorAddress: msg.ValidatorAddress, + } + responses, err := sendMessage(ctx, msgWithdraw) + if err != nil { + return nil, err + } + + return &lockuptypes.MsgExecuteMessagesResponse{Responses: responses}, nil +} + func (bva *BaseLockup) SendCoins( ctx context.Context, msg *lockuptypes.MsgSend, getLockedCoinsFunc getLockedCoinsFunc, ) ( @@ -586,3 +614,8 @@ func (bva BaseLockup) QueryLockupAccountBaseInfo(ctx context.Context, _ *lockupt EndTime: &endTime, }, nil } + +func (bva BaseLockup) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { + accountstd.RegisterExecuteHandler(builder, bva.Undelegate) + accountstd.RegisterExecuteHandler(builder, bva.WithdrawReward) +} diff --git a/x/accounts/defaults/lockup/periodic_locking_account.go b/x/accounts/defaults/lockup/periodic_locking_account.go index be3ce30c153..04473742fd5 100644 --- a/x/accounts/defaults/lockup/periodic_locking_account.go +++ b/x/accounts/defaults/lockup/periodic_locking_account.go @@ -105,12 +105,6 @@ func (pva *PeriodicLockingAccount) Delegate(ctx context.Context, msg *lockuptype return pva.BaseLockup.Delegate(ctx, msg, pva.GetLockedCoinsWithDenoms) } -func (pva *PeriodicLockingAccount) Undelegate(ctx context.Context, msg *lockuptypes.MsgUndelegate) ( - *lockuptypes.MsgExecuteMessagesResponse, error, -) { - return pva.BaseLockup.Undelegate(ctx, msg) -} - func (pva *PeriodicLockingAccount) SendCoins(ctx context.Context, msg *lockuptypes.MsgSend) ( *lockuptypes.MsgExecuteMessagesResponse, error, ) { @@ -324,9 +318,9 @@ func (pva PeriodicLockingAccount) RegisterInitHandler(builder *accountstd.InitBu func (pva PeriodicLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, pva.Delegate) - accountstd.RegisterExecuteHandler(builder, pva.Undelegate) accountstd.RegisterExecuteHandler(builder, pva.SendCoins) accountstd.RegisterExecuteHandler(builder, pva.WithdrawUnlockedCoins) + pva.BaseLockup.RegisterExecuteHandlers(builder) } func (pva PeriodicLockingAccount) RegisterQueryHandlers(builder *accountstd.QueryBuilder) { diff --git a/x/accounts/defaults/lockup/permanent_locking_account.go b/x/accounts/defaults/lockup/permanent_locking_account.go index 70a8b98dd1d..2ca615c15ba 100644 --- a/x/accounts/defaults/lockup/permanent_locking_account.go +++ b/x/accounts/defaults/lockup/permanent_locking_account.go @@ -100,8 +100,8 @@ func (plva PermanentLockingAccount) RegisterInitHandler(builder *accountstd.Init func (plva PermanentLockingAccount) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) { accountstd.RegisterExecuteHandler(builder, plva.Delegate) - accountstd.RegisterExecuteHandler(builder, plva.Undelegate) accountstd.RegisterExecuteHandler(builder, plva.SendCoins) + plva.BaseLockup.RegisterExecuteHandlers(builder) } func (plva PermanentLockingAccount) RegisterQueryHandlers(builder *accountstd.QueryBuilder) { diff --git a/x/accounts/defaults/lockup/types/tx.pb.go b/x/accounts/defaults/lockup/types/tx.pb.go index c50ab2f5c36..6a4383e31c7 100644 --- a/x/accounts/defaults/lockup/types/tx.pb.go +++ b/x/accounts/defaults/lockup/types/tx.pb.go @@ -318,6 +318,45 @@ func (m *MsgUndelegate) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUndelegate proto.InternalMessageInfo +// MsgWithdrawReward defines a message that enable lockup account to execute withdraw reward message +type MsgWithdrawReward struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` +} + +func (m *MsgWithdrawReward) Reset() { *m = MsgWithdrawReward{} } +func (m *MsgWithdrawReward) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawReward) ProtoMessage() {} +func (*MsgWithdrawReward) Descriptor() ([]byte, []int) { + return fileDescriptor_e5f39108a4d67f92, []int{6} +} +func (m *MsgWithdrawReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawReward.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 *MsgWithdrawReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawReward.Merge(m, src) +} +func (m *MsgWithdrawReward) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawReward) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawReward.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawReward proto.InternalMessageInfo + // MsgSend defines a message that enable lockup account to execute send message type MsgSend struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` @@ -329,7 +368,7 @@ 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_e5f39108a4d67f92, []int{6} + return fileDescriptor_e5f39108a4d67f92, []int{7} } func (m *MsgSend) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -367,7 +406,7 @@ func (m *MsgExecuteMessagesResponse) Reset() { *m = MsgExecuteMessagesRe func (m *MsgExecuteMessagesResponse) String() string { return proto.CompactTextString(m) } func (*MsgExecuteMessagesResponse) ProtoMessage() {} func (*MsgExecuteMessagesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e5f39108a4d67f92, []int{7} + return fileDescriptor_e5f39108a4d67f92, []int{8} } func (m *MsgExecuteMessagesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -415,7 +454,7 @@ func (m *MsgWithdraw) Reset() { *m = MsgWithdraw{} } func (m *MsgWithdraw) String() string { return proto.CompactTextString(m) } func (*MsgWithdraw) ProtoMessage() {} func (*MsgWithdraw) Descriptor() ([]byte, []int) { - return fileDescriptor_e5f39108a4d67f92, []int{8} + return fileDescriptor_e5f39108a4d67f92, []int{9} } func (m *MsgWithdraw) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -454,7 +493,7 @@ func (m *MsgWithdrawResponse) Reset() { *m = MsgWithdrawResponse{} } func (m *MsgWithdrawResponse) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawResponse) ProtoMessage() {} func (*MsgWithdrawResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e5f39108a4d67f92, []int{9} + return fileDescriptor_e5f39108a4d67f92, []int{10} } func (m *MsgWithdrawResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -504,6 +543,7 @@ func init() { proto.RegisterType((*MsgInitPeriodicLockingAccountResponse)(nil), "cosmos.accounts.defaults.lockup.MsgInitPeriodicLockingAccountResponse") proto.RegisterType((*MsgDelegate)(nil), "cosmos.accounts.defaults.lockup.MsgDelegate") proto.RegisterType((*MsgUndelegate)(nil), "cosmos.accounts.defaults.lockup.MsgUndelegate") + proto.RegisterType((*MsgWithdrawReward)(nil), "cosmos.accounts.defaults.lockup.MsgWithdrawReward") proto.RegisterType((*MsgSend)(nil), "cosmos.accounts.defaults.lockup.MsgSend") proto.RegisterType((*MsgExecuteMessagesResponse)(nil), "cosmos.accounts.defaults.lockup.MsgExecuteMessagesResponse") proto.RegisterType((*MsgWithdraw)(nil), "cosmos.accounts.defaults.lockup.MsgWithdraw") @@ -515,57 +555,58 @@ func init() { } var fileDescriptor_e5f39108a4d67f92 = []byte{ - // 797 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0x3d, 0x4f, 0x1b, 0x49, - 0x18, 0xf6, 0xda, 0x3a, 0x83, 0x87, 0x03, 0x8e, 0xc5, 0x3a, 0x8c, 0x75, 0xec, 0x72, 0x96, 0x10, - 0x96, 0x75, 0xde, 0x3d, 0xb8, 0x93, 0xee, 0x64, 0x5d, 0x83, 0x8f, 0x7c, 0x49, 0x71, 0x84, 0x4c, - 0x3e, 0xa4, 0xa4, 0xb0, 0xd6, 0xbb, 0xc3, 0xb0, 0xc2, 0x3b, 0x63, 0xed, 0x8c, 0x0d, 0xee, 0xa2, - 0x28, 0x45, 0x44, 0x45, 0x9d, 0x8a, 0x2a, 0x8a, 0x52, 0x39, 0x12, 0x3f, 0x82, 0x12, 0x51, 0x51, - 0x85, 0xc8, 0x44, 0x32, 0x3f, 0x23, 0x9a, 0x9d, 0x59, 0x62, 0x3e, 0x02, 0x8e, 0x8b, 0x14, 0x69, - 0xbc, 0x33, 0xf3, 0x3e, 0xef, 0xfb, 0x3e, 0xcf, 0x33, 0x1f, 0x32, 0xc8, 0xda, 0x84, 0x7a, 0x84, - 0x9a, 0x96, 0x6d, 0x93, 0x06, 0x66, 0xd4, 0x74, 0xe0, 0x9a, 0xd5, 0xa8, 0x31, 0x6a, 0xd6, 0x88, - 0xbd, 0xd1, 0xa8, 0x9b, 0x6c, 0xcb, 0xa8, 0xfb, 0x84, 0x11, 0x55, 0x17, 0x48, 0x23, 0x44, 0x1a, - 0x21, 0xd2, 0x10, 0xc8, 0xf4, 0x84, 0xe5, 0xb9, 0x98, 0x98, 0xc1, 0xaf, 0xc8, 0x49, 0x6b, 0xb2, - 0x7a, 0xd5, 0xa2, 0xd0, 0x6c, 0x2e, 0x54, 0x21, 0xb3, 0x16, 0x4c, 0x9b, 0xb8, 0x58, 0xc6, 0xff, - 0xb8, 0xa9, 0xbb, 0xf8, 0x48, 0xf4, 0x94, 0x44, 0x7b, 0x14, 0x99, 0xcd, 0x05, 0xfe, 0x91, 0x81, - 0x69, 0x11, 0xa8, 0x04, 0x33, 0x53, 0xf2, 0x14, 0xa1, 0x24, 0x22, 0x88, 0x88, 0x75, 0x3e, 0x0a, - 0x13, 0x10, 0x21, 0xa8, 0x06, 0xcd, 0x60, 0x56, 0x6d, 0xac, 0x99, 0x16, 0x6e, 0xc9, 0x90, 0x7e, - 0x31, 0xc4, 0x5c, 0x0f, 0x52, 0x66, 0x79, 0x92, 0x45, 0xe6, 0x79, 0x14, 0x24, 0x4b, 0x14, 0xdd, - 0xc3, 0x2e, 0xbb, 0x1f, 0xb0, 0x5b, 0x12, 0xe4, 0x55, 0x03, 0xfc, 0x44, 0x36, 0x31, 0xf4, 0x53, - 0xca, 0xac, 0x92, 0x4d, 0x14, 0x53, 0x87, 0x7b, 0xf9, 0xa4, 0xe4, 0xb2, 0xe4, 0x38, 0x3e, 0xa4, - 0x74, 0x95, 0xf9, 0x2e, 0x46, 0x65, 0x01, 0x53, 0x97, 0xc1, 0x30, 0xc4, 0x4e, 0x85, 0xd7, 0x4f, - 0x45, 0x67, 0x95, 0xec, 0xc8, 0x62, 0xda, 0x10, 0xcd, 0x8d, 0xb0, 0xb9, 0xf1, 0x30, 0x6c, 0x5e, - 0x1c, 0xdd, 0xff, 0xa0, 0x47, 0x76, 0x8e, 0x75, 0xe5, 0x6d, 0xb7, 0x9d, 0x53, 0xca, 0x43, 0x10, - 0x3b, 0x3c, 0xa8, 0xde, 0x05, 0x80, 0x32, 0xcb, 0x67, 0xa2, 0x4e, 0xec, 0x5b, 0xeb, 0x24, 0x82, - 0x64, 0x1e, 0x2e, 0x64, 0x4f, 0x77, 0x75, 0x65, 0xbb, 0xdb, 0xce, 0xc9, 0x9d, 0xce, 0x53, 0x67, - 0xc3, 0xbc, 0x4a, 0x69, 0x46, 0x03, 0xbf, 0x5d, 0xb5, 0x5e, 0x86, 0xb4, 0x4e, 0x30, 0x85, 0x99, - 0x37, 0x51, 0x30, 0x23, 0x01, 0x2b, 0xd0, 0x77, 0x89, 0xe3, 0xda, 0x1c, 0xe8, 0x62, 0x34, 0xa8, - 0x57, 0xe7, 0x55, 0x46, 0x07, 0x57, 0xa9, 0x3e, 0x03, 0xe3, 0x35, 0xc1, 0xa5, 0x52, 0x0f, 0xb8, - 0xd1, 0x54, 0x6c, 0x36, 0x96, 0x1d, 0x59, 0x9c, 0x37, 0x6e, 0x38, 0xe0, 0x86, 0xd0, 0x52, 0x4c, - 0xf0, 0xda, 0xa2, 0xee, 0x98, 0x2c, 0x25, 0x22, 0xb4, 0x60, 0x9c, 0xee, 0xea, 0x11, 0x6e, 0xe1, - 0xdc, 0x65, 0x0b, 0x05, 0xe6, 0xbc, 0x91, 0xf3, 0x60, 0xee, 0x5a, 0x9f, 0xce, 0x1c, 0xed, 0x28, - 0x60, 0xa4, 0x44, 0xd1, 0x32, 0xac, 0x41, 0x64, 0x31, 0xa8, 0xfe, 0x09, 0xe2, 0x14, 0x62, 0xa7, - 0x0f, 0x03, 0x25, 0x4e, 0x7d, 0x00, 0x26, 0x9a, 0x56, 0xcd, 0x75, 0x2c, 0x46, 0xfc, 0x8a, 0x25, - 0x20, 0x81, 0x91, 0x89, 0xe2, 0xef, 0x87, 0x7b, 0xf9, 0x19, 0x99, 0xfc, 0x38, 0xc4, 0x9c, 0xaf, - 0xf2, 0x4b, 0xf3, 0xc2, 0xba, 0xfa, 0x1f, 0x88, 0x5b, 0x1e, 0xe7, 0x28, 0xcf, 0xdc, 0x74, 0x68, - 0x1f, 0xbf, 0xeb, 0x86, 0xbc, 0xeb, 0xc6, 0xff, 0xc4, 0xc5, 0xbd, 0x86, 0xc9, 0x9c, 0xc2, 0xe4, - 0xab, 0x5d, 0x3d, 0xc2, 0xcd, 0x7a, 0xd1, 0x6d, 0xe7, 0x24, 0xc5, 0xcc, 0x27, 0x05, 0x8c, 0x96, - 0x28, 0x7a, 0x84, 0x9d, 0x1f, 0x5a, 0xe6, 0xcb, 0x28, 0x18, 0x2a, 0x51, 0xb4, 0x0a, 0xb1, 0x33, - 0x80, 0xc0, 0x7f, 0x00, 0x60, 0xe4, 0x82, 0xb2, 0xaf, 0x67, 0x25, 0x18, 0x09, 0x95, 0xb4, 0x7a, - 0x94, 0xc4, 0xae, 0x57, 0x72, 0x9b, 0x2b, 0x79, 0x77, 0xac, 0x67, 0x91, 0xcb, 0xd6, 0x1b, 0x55, - 0xc3, 0x26, 0x9e, 0x7c, 0x55, 0xcd, 0x9e, 0x73, 0xcd, 0x5a, 0x75, 0x48, 0x83, 0x04, 0xfa, 0xba, - 0xdb, 0xce, 0xfd, 0xcc, 0xf7, 0xcc, 0x6e, 0x55, 0xf8, 0xf3, 0x4e, 0xfb, 0xb0, 0x61, 0x05, 0xa4, - 0x4b, 0x14, 0xdd, 0xda, 0x82, 0x76, 0x83, 0xc1, 0x12, 0xa4, 0xd4, 0x42, 0x90, 0x86, 0x07, 0x5e, - 0x5d, 0x04, 0x09, 0x5f, 0x8e, 0x69, 0x4a, 0x09, 0x08, 0x27, 0x2f, 0xdd, 0xf7, 0x25, 0xdc, 0x2a, - 0x7f, 0x81, 0x65, 0xde, 0x8b, 0x4b, 0xf2, 0xc4, 0x65, 0xeb, 0x8e, 0x6f, 0x6d, 0xaa, 0xff, 0x02, - 0xb0, 0x29, 0xc7, 0x7d, 0x18, 0xdc, 0x83, 0x1d, 0xdc, 0xe4, 0x5f, 0x41, 0xdc, 0x81, 0x98, 0x78, - 0xe2, 0x51, 0x49, 0x94, 0xe5, 0xac, 0x30, 0xd5, 0xeb, 0x40, 0x4f, 0xa7, 0xcc, 0x91, 0x02, 0x26, - 0x7b, 0x38, 0x9f, 0xe9, 0xff, 0x1b, 0x0c, 0xfb, 0xd0, 0x86, 0x6e, 0xb3, 0x0f, 0xe6, 0x67, 0x48, - 0x75, 0x5b, 0x01, 0xe3, 0xc2, 0xf3, 0x8a, 0x5c, 0x73, 0x52, 0xd1, 0xef, 0xb5, 0xdb, 0x63, 0xa2, - 0x73, 0x59, 0x36, 0x2e, 0xde, 0xd9, 0xef, 0x68, 0xca, 0x41, 0x47, 0x53, 0x3e, 0x76, 0x34, 0x65, - 0xe7, 0x44, 0x8b, 0x1c, 0x9c, 0x68, 0x91, 0xa3, 0x13, 0x2d, 0xf2, 0x34, 0x2f, 0xea, 0x52, 0x67, - 0xc3, 0x70, 0x89, 0xb9, 0x75, 0xcd, 0x9f, 0x0f, 0xde, 0xb4, 0x1a, 0x0f, 0x36, 0xfc, 0xaf, 0xcf, - 0x01, 0x00, 0x00, 0xff, 0xff, 0xf7, 0xd7, 0x1d, 0x22, 0xac, 0x08, 0x00, 0x00, + // 816 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0xcf, 0x4f, 0x1b, 0x47, + 0x14, 0xf6, 0xda, 0xaa, 0xc1, 0x43, 0x81, 0xb2, 0x58, 0xc5, 0x58, 0x65, 0x97, 0x5a, 0x42, 0x58, + 0x56, 0xbd, 0x5b, 0x68, 0xa5, 0x56, 0x56, 0x2f, 0xb8, 0xf4, 0x97, 0x54, 0x57, 0xc8, 0xf4, 0x87, + 0xd4, 0x1c, 0xac, 0xf1, 0xee, 0x30, 0xac, 0xf0, 0xce, 0x58, 0x3b, 0x63, 0x1b, 0xdf, 0xa2, 0x28, + 0x87, 0x88, 0x13, 0xe7, 0x9c, 0x38, 0x45, 0x11, 0x27, 0x47, 0xe2, 0x8f, 0xe0, 0x88, 0x38, 0x71, + 0x0a, 0x91, 0x89, 0x64, 0xfe, 0x8c, 0x68, 0x77, 0x66, 0x89, 0x0d, 0x04, 0x1c, 0x1f, 0x12, 0x29, + 0x17, 0xef, 0xcc, 0xbc, 0xef, 0xbd, 0xf7, 0xbd, 0x6f, 0xde, 0xdb, 0x35, 0xc8, 0x5a, 0x94, 0xb9, + 0x94, 0x99, 0xd0, 0xb2, 0x68, 0x83, 0x70, 0x66, 0xda, 0x68, 0x0b, 0x36, 0x6a, 0x9c, 0x99, 0x35, + 0x6a, 0xed, 0x34, 0xea, 0x26, 0xdf, 0x35, 0xea, 0x1e, 0xe5, 0x54, 0xd5, 0x05, 0xd2, 0x08, 0x91, + 0x46, 0x88, 0x34, 0x04, 0x32, 0x3d, 0x03, 0x5d, 0x87, 0x50, 0x33, 0xf8, 0x15, 0x3e, 0x69, 0x4d, + 0x46, 0xaf, 0x42, 0x86, 0xcc, 0xe6, 0x4a, 0x15, 0x71, 0xb8, 0x62, 0x5a, 0xd4, 0x21, 0xd2, 0xfe, + 0xcd, 0x7d, 0xd9, 0xc5, 0x43, 0xa2, 0xe7, 0x24, 0xda, 0x65, 0xd8, 0x6c, 0xae, 0xf8, 0x0f, 0x69, + 0x98, 0x17, 0x86, 0x4a, 0xb0, 0x33, 0x25, 0x4f, 0x61, 0x4a, 0x62, 0x8a, 0xa9, 0x38, 0xf7, 0x57, + 0xa1, 0x03, 0xa6, 0x14, 0xd7, 0x90, 0x19, 0xec, 0xaa, 0x8d, 0x2d, 0x13, 0x92, 0xb6, 0x34, 0xe9, + 0xd7, 0x4d, 0xdc, 0x71, 0x11, 0xe3, 0xd0, 0x95, 0x2c, 0x32, 0x0f, 0xa3, 0x20, 0x59, 0x62, 0xf8, + 0x0f, 0xe2, 0xf0, 0x3f, 0x03, 0x76, 0x6b, 0x82, 0xbc, 0x6a, 0x80, 0xcf, 0x68, 0x8b, 0x20, 0x2f, + 0xa5, 0x2c, 0x2a, 0xd9, 0x44, 0x31, 0x75, 0x7a, 0x94, 0x4f, 0x4a, 0x2e, 0x6b, 0xb6, 0xed, 0x21, + 0xc6, 0x36, 0xb9, 0xe7, 0x10, 0x5c, 0x16, 0x30, 0x75, 0x1d, 0x8c, 0x23, 0x62, 0x57, 0xfc, 0xf8, + 0xa9, 0xe8, 0xa2, 0x92, 0x9d, 0x58, 0x4d, 0x1b, 0x22, 0xb9, 0x11, 0x26, 0x37, 0xfe, 0x0e, 0x93, + 0x17, 0x27, 0x8f, 0x5f, 0xea, 0x91, 0xfd, 0x73, 0x5d, 0x79, 0xde, 0xeb, 0xe4, 0x94, 0xf2, 0x18, + 0x22, 0xb6, 0x6f, 0x54, 0x7f, 0x07, 0x80, 0x71, 0xe8, 0x71, 0x11, 0x27, 0xf6, 0xbe, 0x71, 0x12, + 0x81, 0xb3, 0x6f, 0x2e, 0x64, 0x2f, 0x0f, 0x74, 0x65, 0xaf, 0xd7, 0xc9, 0xc9, 0x9b, 0xce, 0x33, + 0x7b, 0xc7, 0xbc, 0xad, 0xd2, 0x8c, 0x06, 0xbe, 0xba, 0xed, 0xbc, 0x8c, 0x58, 0x9d, 0x12, 0x86, + 0x32, 0xcf, 0xa2, 0x60, 0x41, 0x02, 0x36, 0x90, 0xe7, 0x50, 0xdb, 0xb1, 0x7c, 0xa0, 0x43, 0xf0, + 0xa8, 0x5a, 0x0d, 0x56, 0x19, 0x1d, 0xbd, 0x4a, 0xf5, 0x01, 0x98, 0xae, 0x09, 0x2e, 0x95, 0x7a, + 0xc0, 0x8d, 0xa5, 0x62, 0x8b, 0xb1, 0xec, 0xc4, 0xea, 0xb2, 0x71, 0x4f, 0x83, 0x1b, 0xa2, 0x96, + 0x62, 0xc2, 0x8f, 0x2d, 0xe2, 0x4e, 0xc9, 0x50, 0xc2, 0xc2, 0x0a, 0xc6, 0xe5, 0x81, 0x1e, 0xf1, + 0x25, 0x5c, 0xba, 0x29, 0xa1, 0xc0, 0x0c, 0x0a, 0xb9, 0x0c, 0x96, 0xee, 0xd4, 0xe9, 0x4a, 0xd1, + 0xae, 0x02, 0x26, 0x4a, 0x0c, 0xaf, 0xa3, 0x1a, 0xc2, 0x90, 0x23, 0xf5, 0x5b, 0x10, 0x67, 0x88, + 0xd8, 0x43, 0x08, 0x28, 0x71, 0xea, 0x5f, 0x60, 0xa6, 0x09, 0x6b, 0x8e, 0x0d, 0x39, 0xf5, 0x2a, + 0x50, 0x40, 0x02, 0x21, 0x13, 0xc5, 0xaf, 0x4f, 0x8f, 0xf2, 0x0b, 0xd2, 0xf9, 0xdf, 0x10, 0x33, + 0x18, 0xe5, 0x8b, 0xe6, 0xb5, 0x73, 0xf5, 0x27, 0x10, 0x87, 0xae, 0xcf, 0x51, 0xf6, 0xdc, 0x7c, + 0x28, 0x9f, 0x3f, 0xeb, 0x86, 0x9c, 0x75, 0xe3, 0x67, 0xea, 0x90, 0x7e, 0xc1, 0xa4, 0x4f, 0x61, + 0xf6, 0xc9, 0x81, 0x1e, 0xf1, 0xc5, 0x7a, 0xd4, 0xeb, 0xe4, 0x24, 0xc5, 0xcc, 0x6b, 0x05, 0x4c, + 0x96, 0x18, 0xfe, 0x87, 0xd8, 0x9f, 0x74, 0x99, 0x87, 0x0a, 0x98, 0x29, 0x31, 0xfc, 0x9f, 0xc3, + 0xb7, 0x6d, 0x0f, 0xb6, 0xca, 0xa8, 0x05, 0x3d, 0xfb, 0xe3, 0x97, 0x7a, 0x3b, 0xd9, 0xc7, 0x51, + 0x30, 0x56, 0x62, 0x78, 0x13, 0x91, 0x51, 0x28, 0xfe, 0x00, 0x00, 0xa7, 0xd7, 0xb8, 0xbd, 0xdb, + 0x2b, 0xc1, 0x69, 0x28, 0x7b, 0xbb, 0x4f, 0xf6, 0xd8, 0xdd, 0xb2, 0xff, 0xea, 0xcb, 0x7e, 0x78, + 0xae, 0x67, 0xb1, 0xc3, 0xb7, 0x1b, 0x55, 0xc3, 0xa2, 0xae, 0xfc, 0x04, 0x98, 0x7d, 0x43, 0xc8, + 0xdb, 0x75, 0xc4, 0x02, 0x07, 0xf6, 0xb4, 0xd7, 0xc9, 0x7d, 0xee, 0x37, 0x98, 0xd5, 0xae, 0xf8, + 0xdf, 0x22, 0x36, 0xc4, 0x9d, 0x6d, 0x80, 0x74, 0x89, 0xe1, 0x5f, 0x76, 0x91, 0xd5, 0xe0, 0xa8, + 0x84, 0x18, 0x83, 0x18, 0xb1, 0x70, 0x3a, 0xd5, 0x55, 0x90, 0xf0, 0xe4, 0x9a, 0xa5, 0x94, 0x80, + 0x70, 0xf2, 0xc6, 0xcb, 0x69, 0x8d, 0xb4, 0xcb, 0x6f, 0x61, 0x99, 0x17, 0x62, 0xa2, 0xc3, 0x2e, + 0x50, 0x7f, 0x04, 0xa0, 0x25, 0xd7, 0x43, 0x08, 0xdc, 0x87, 0x1d, 0x5d, 0xe4, 0x2f, 0x41, 0xdc, + 0x46, 0x84, 0xba, 0xe2, 0x0d, 0x98, 0x28, 0xcb, 0x5d, 0x61, 0xae, 0x5f, 0x81, 0xbe, 0x4c, 0x99, + 0x33, 0x05, 0xcc, 0x0e, 0x74, 0xae, 0xac, 0xff, 0x7b, 0x30, 0xee, 0x21, 0x0b, 0x39, 0xcd, 0x21, + 0x98, 0x5f, 0x21, 0xd5, 0x3d, 0x05, 0x4c, 0x0b, 0xcd, 0x2b, 0xf2, 0xcc, 0x4e, 0x45, 0x3f, 0xd4, + 0x6d, 0x4f, 0x89, 0xcc, 0x65, 0x99, 0xb8, 0xf8, 0xdb, 0x71, 0x57, 0x53, 0x4e, 0xba, 0x9a, 0xf2, + 0xaa, 0xab, 0x29, 0xfb, 0x17, 0x5a, 0xe4, 0xe4, 0x42, 0x8b, 0x9c, 0x5d, 0x68, 0x91, 0xff, 0xf3, + 0x22, 0x2e, 0xb3, 0x77, 0x0c, 0x87, 0x9a, 0xbb, 0x77, 0xfc, 0x53, 0xf2, 0x93, 0x56, 0xe3, 0xc1, + 0x85, 0x7f, 0xf7, 0x26, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xb6, 0xac, 0x3d, 0x59, 0x09, 0x00, 0x00, } func (this *MsgInitLockupAccount) Equal(that interface{}) bool { @@ -836,6 +877,43 @@ func (m *MsgUndelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgWithdrawReward) 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 *MsgWithdrawReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *MsgSend) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1119,6 +1197,23 @@ func (m *MsgUndelegate) Size() (n int) { return n } +func (m *MsgWithdrawReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func (m *MsgSend) Size() (n int) { if m == nil { return 0 @@ -1896,6 +1991,120 @@ func (m *MsgUndelegate) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgWithdrawReward) 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: MsgWithdrawReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = 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 *MsgSend) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto b/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto index a0a6e1a07ae..c13cec55b16 100644 --- a/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto +++ b/x/accounts/proto/cosmos/accounts/defaults/lockup/tx.proto @@ -79,6 +79,17 @@ message MsgUndelegate { cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } +// MsgWithdrawReward defines a message that enable lockup account to execute withdraw reward message +message MsgWithdrawReward { + option (cosmos.msg.v1.signer) = "sender"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"]; +} + // MsgSend defines a message that enable lockup account to execute send message message MsgSend { option (cosmos.msg.v1.signer) = "sender"; From 89abdbfc728ebebe22121d6e4c977f5827ae090d Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Thu, 18 Apr 2024 16:52:21 +0700 Subject: [PATCH 09/22] remove loop --- x/accounts/defaults/lockup/lockup.go | 158 +++++++++++++++------------ 1 file changed, 88 insertions(+), 70 deletions(-) diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index 43d6314c8a1..b49874cf55f 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -409,6 +409,17 @@ func sendMessage(ctx context.Context, msg proto.Message) ([]*codectypes.Any, err return []*codectypes.Any{respAny}, nil } +func getStakingDenom(ctx context.Context) (string, error) { + // Query account balance for the sent denom + paramsQueryReq := &stakingtypes.QueryParamsRequest{} + resp, err := accountstd.QueryModule[stakingtypes.QueryParamsResponse](ctx, paramsQueryReq) + if err != nil { + return "", err + } + + return resp.Params.BondDenom, nil +} + // TrackDelegation tracks a delegation amount for any given lockup account type // given the amount of coins currently being locked and the current account balance // of the delegation denominations. @@ -418,49 +429,53 @@ func sendMessage(ctx context.Context, msg proto.Message) ([]*codectypes.Any, err func (bva *BaseLockup) TrackDelegation( ctx context.Context, balance, lockedCoins, amount sdk.Coins, ) error { - for _, coin := range amount { - baseAmt := balance.AmountOf(coin.Denom) - lockedAmt := lockedCoins.AmountOf(coin.Denom) - delLockingAmt, err := bva.DelegatedLocking.Get(ctx, coin.Denom) + bondDenom, err := getStakingDenom(ctx) + if err != nil { + return err + } + + delAmt := amount.AmountOf(bondDenom) + baseAmt := balance.AmountOf(bondDenom) + lockedAmt := lockedCoins.AmountOf(bondDenom) + delLockingAmt, err := bva.DelegatedLocking.Get(ctx, bondDenom) + if err != nil { + return err + } + delFreeAmt, err := bva.DelegatedFree.Get(ctx, bondDenom) + if err != nil { + return err + } + + // return error if the delegation amount is zero or if the base coins does not + // exceed the desired delegation amount. + if delAmt.IsZero() || baseAmt.LT(delAmt) { + return sdkerrors.ErrInvalidCoins.Wrap("delegation attempt with zero coins or insufficient funds") + } + + // compute x and y per the specification, where: + // X := min(max(V - DV, 0), D) + // Y := D - X + x := math.MinInt(math.MaxInt(lockedAmt.Sub(delLockingAmt), math.ZeroInt()), delAmt) + y := delAmt.Sub(x) + + delLockingCoin := sdk.NewCoin(bondDenom, delLockingAmt) + delFreeCoin := sdk.NewCoin(bondDenom, delFreeAmt) + if !x.IsZero() { + xCoin := sdk.NewCoin(bondDenom, x) + newDelLocking := delLockingCoin.Add(xCoin) + err = bva.DelegatedLocking.Set(ctx, newDelLocking.Denom, newDelLocking.Amount) if err != nil { return err } - delFreeAmt, err := bva.DelegatedFree.Get(ctx, coin.Denom) + } + + if !y.IsZero() { + yCoin := sdk.NewCoin(bondDenom, y) + newDelFree := delFreeCoin.Add(yCoin) + err = bva.DelegatedFree.Set(ctx, newDelFree.Denom, newDelFree.Amount) if err != nil { return err } - - // return error if the delegation amount is zero or if the base coins does not - // exceed the desired delegation amount. - if coin.Amount.IsZero() || baseAmt.LT(coin.Amount) { - return sdkerrors.ErrInvalidCoins.Wrap("delegation attempt with zero coins or insufficient funds") - } - - // compute x and y per the specification, where: - // X := min(max(V - DV, 0), D) - // Y := D - X - x := math.MinInt(math.MaxInt(lockedAmt.Sub(delLockingAmt), math.ZeroInt()), coin.Amount) - y := coin.Amount.Sub(x) - - delLockingCoin := sdk.NewCoin(coin.Denom, delLockingAmt) - delFreeCoin := sdk.NewCoin(coin.Denom, delFreeAmt) - if !x.IsZero() { - xCoin := sdk.NewCoin(coin.Denom, x) - newDelLocking := delLockingCoin.Add(xCoin) - err = bva.DelegatedLocking.Set(ctx, newDelLocking.Denom, newDelLocking.Amount) - if err != nil { - return err - } - } - - if !y.IsZero() { - yCoin := sdk.NewCoin(coin.Denom, y) - newDelFree := delFreeCoin.Add(yCoin) - err = bva.DelegatedFree.Set(ctx, newDelFree.Denom, newDelFree.Amount) - if err != nil { - return err - } - } } return nil @@ -477,45 +492,48 @@ func (bva *BaseLockup) TrackDelegation( // // CONTRACT: The account's coins and undelegation coins must be sorted. func (bva *BaseLockup) TrackUndelegation(ctx context.Context, amount sdk.Coins) error { - for _, coin := range amount { - // return error if the undelegation amount is zero - if coin.Amount.IsZero() { - return sdkerrors.ErrInvalidCoins.Wrap("undelegation attempt with zero coins") - } - delFreeAmt, err := bva.DelegatedFree.Get(ctx, coin.Denom) + bondDenom, err := getStakingDenom(ctx) + if err != nil { + return err + } + delAmt := amount.AmountOf(bondDenom) + // return error if the undelegation amount is zero + if delAmt.IsZero() { + return sdkerrors.ErrInvalidCoins.Wrap("undelegation attempt with zero coins") + } + delFreeAmt, err := bva.DelegatedFree.Get(ctx, bondDenom) + if err != nil { + return err + } + delLockingAmt, err := bva.DelegatedLocking.Get(ctx, bondDenom) + if err != nil { + return err + } + + // compute x and y per the specification, where: + // X := min(DF, D) + // Y := min(DV, D - X) + x := math.MinInt(delFreeAmt, delAmt) + y := math.MinInt(delLockingAmt, delAmt.Sub(x)) + + delLockingCoin := sdk.NewCoin(bondDenom, delLockingAmt) + delFreeCoin := sdk.NewCoin(bondDenom, delFreeAmt) + if !x.IsZero() { + xCoin := sdk.NewCoin(bondDenom, x) + newDelFree := delFreeCoin.Sub(xCoin) + err = bva.DelegatedFree.Set(ctx, newDelFree.Denom, newDelFree.Amount) if err != nil { return err } - delLockingAmt, err := bva.DelegatedLocking.Get(ctx, coin.Denom) + } + + if !y.IsZero() { + yCoin := sdk.NewCoin(bondDenom, y) + newDelLocking := delLockingCoin.Sub(yCoin) + err = bva.DelegatedLocking.Set(ctx, newDelLocking.Denom, newDelLocking.Amount) if err != nil { return err } - - // compute x and y per the specification, where: - // X := min(DF, D) - // Y := min(DV, D - X) - x := math.MinInt(delFreeAmt, coin.Amount) - y := math.MinInt(delLockingAmt, coin.Amount.Sub(x)) - - delLockingCoin := sdk.NewCoin(coin.Denom, delLockingAmt) - delFreeCoin := sdk.NewCoin(coin.Denom, delFreeAmt) - if !x.IsZero() { - xCoin := sdk.NewCoin(coin.Denom, x) - newDelFree := delFreeCoin.Sub(xCoin) - err = bva.DelegatedFree.Set(ctx, newDelFree.Denom, newDelFree.Amount) - if err != nil { - return err - } - } - - if !y.IsZero() { - yCoin := sdk.NewCoin(coin.Denom, y) - newDelLocking := delLockingCoin.Sub(yCoin) - err = bva.DelegatedLocking.Set(ctx, newDelLocking.Denom, newDelLocking.Amount) - if err != nil { - return err - } - } } return nil From f8b28eea313741d27d3b172650d21b12a5eb2729 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Thu, 18 Apr 2024 16:59:45 +0700 Subject: [PATCH 10/22] just need to initialize bondenom for del and undel trackin --- x/accounts/defaults/lockup/lockup.go | 25 +++++++++++-------- .../lockup/periodic_locking_account.go | 25 +++++++++++-------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index b49874cf55f..81f1d07175d 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -102,18 +102,23 @@ func (bva *BaseLockup) Init(ctx context.Context, msg *lockuptypes.MsgInitLockupA if err != nil { return nil, err } + } - // Set initial value for all locked token - err = bva.DelegatedFree.Set(ctx, coin.Denom, math.ZeroInt()) - if err != nil { - return nil, err - } + bondDenom, err := getStakingDenom(ctx) + if err != nil { + return nil, err + } - // Set initial value for all locked token - err = bva.DelegatedLocking.Set(ctx, coin.Denom, math.ZeroInt()) - if err != nil { - return nil, err - } + // Set initial value for all locked token + err = bva.DelegatedFree.Set(ctx, bondDenom, math.ZeroInt()) + if err != nil { + return nil, err + } + + // Set initial value for all locked token + err = bva.DelegatedLocking.Set(ctx, bondDenom, math.ZeroInt()) + if err != nil { + return nil, err } err = bva.EndTime.Set(ctx, msg.EndTime) diff --git a/x/accounts/defaults/lockup/periodic_locking_account.go b/x/accounts/defaults/lockup/periodic_locking_account.go index 03de1add76f..4246306f63e 100644 --- a/x/accounts/defaults/lockup/periodic_locking_account.go +++ b/x/accounts/defaults/lockup/periodic_locking_account.go @@ -87,18 +87,23 @@ func (pva PeriodicLockingAccount) Init(ctx context.Context, msg *lockuptypes.Msg if err != nil { return nil, err } + } - // Set initial value for all delegated free token - err = pva.DelegatedFree.Set(ctx, coin.Denom, math.ZeroInt()) - if err != nil { - return nil, err - } + bondDenom, err := getStakingDenom(ctx) + if err != nil { + return nil, err + } - // Set initial value for all delegated locking token - err = pva.DelegatedLocking.Set(ctx, coin.Denom, math.ZeroInt()) - if err != nil { - return nil, err - } + // Set initial value for all locked token + err = pva.DelegatedFree.Set(ctx, bondDenom, math.ZeroInt()) + if err != nil { + return nil, err + } + + // Set initial value for all locked token + err = pva.DelegatedLocking.Set(ctx, bondDenom, math.ZeroInt()) + if err != nil { + return nil, err } err = pva.StartTime.Set(ctx, msg.StartTime) From 2bae4bc63e4dcb17b1b8948c10ff06cb492f09ec Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Mon, 22 Apr 2024 02:39:46 +0700 Subject: [PATCH 11/22] addressing comment --- x/accounts/defaults/lockup/continuous_locking_account.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/accounts/defaults/lockup/continuous_locking_account.go b/x/accounts/defaults/lockup/continuous_locking_account.go index d040c7532c7..c90b909cf6c 100644 --- a/x/accounts/defaults/lockup/continuous_locking_account.go +++ b/x/accounts/defaults/lockup/continuous_locking_account.go @@ -41,7 +41,7 @@ func (cva ContinuousLockingAccount) Init(ctx context.Context, msg *lockuptypes.M return nil, sdkerrors.ErrInvalidRequest.Wrapf("invalid end time %s", msg.EndTime.String()) } - if msg.EndTime.Before(msg.StartTime) || msg.EndTime.Equal(msg.StartTime) { + if !msg.EndTime.After(msg.StartTime) { return nil, sdkerrors.ErrInvalidRequest.Wrap("invalid start and end time (must be start before end)") } From a75b91a4182ba73c5430f7d0061549eff1826965 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Mon, 22 Apr 2024 14:55:41 +0700 Subject: [PATCH 12/22] remove branch execute for send coins --- x/accounts/defaults/lockup/lockup.go | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index cad853f60fc..c2cc1a450f3 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -290,25 +290,17 @@ func (bva *BaseLockup) SendCoins( responses := []*codectypes.Any{} - err = bva.branchService.Execute(ctx, func(ctx context.Context) error { - msgSend := &banktypes.MsgSend{ - FromAddress: fromAddress, - ToAddress: msg.ToAddress, - Amount: msg.Amount, - } - resp, err := sendMessage(ctx, msgSend) - if err != nil { - return err - } - - responses = append(responses, resp...) - - return nil - }) + msgSend := &banktypes.MsgSend{ + FromAddress: fromAddress, + ToAddress: msg.ToAddress, + Amount: msg.Amount, + } + resp, err := sendMessage(ctx, msgSend) if err != nil { return nil, err } + responses = append(responses, resp...) return &lockuptypes.MsgExecuteMessagesResponse{Responses: responses}, nil } From 3e749ca3c697b7dbf19cd5395edfcf6583939168 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Mon, 22 Apr 2024 15:15:20 +0700 Subject: [PATCH 13/22] del free and del locking only track bond denom --- x/accounts/defaults/lockup/lockup.go | 52 +++++++++++++++++----------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index c2cc1a450f3..7d3b378114c 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -461,6 +461,13 @@ func (bva *BaseLockup) TrackDelegation( delAmt := amount.AmountOf(bondDenom) baseAmt := balance.AmountOf(bondDenom) + + // return error if the delegation amount is zero or if the base coins does not + // exceed the desired delegation amount. + if delAmt.IsZero() || baseAmt.LT(delAmt) { + return sdkerrors.ErrInvalidCoins.Wrap("delegation attempt with zero coins for staking denom or insufficient funds") + } + lockedAmt := lockedCoins.AmountOf(bondDenom) delLockingAmt, err := bva.DelegatedLocking.Get(ctx, bondDenom) if err != nil { @@ -471,12 +478,6 @@ func (bva *BaseLockup) TrackDelegation( return err } - // return error if the delegation amount is zero or if the base coins does not - // exceed the desired delegation amount. - if delAmt.IsZero() || baseAmt.LT(delAmt) { - return sdkerrors.ErrInvalidCoins.Wrap("delegation attempt with zero coins or insufficient funds") - } - // compute x and y per the specification, where: // X := min(max(V - DV, 0), D) // Y := D - X @@ -488,7 +489,7 @@ func (bva *BaseLockup) TrackDelegation( if !x.IsZero() { xCoin := sdk.NewCoin(bondDenom, x) newDelLocking := delLockingCoin.Add(xCoin) - err = bva.DelegatedLocking.Set(ctx, newDelLocking.Denom, newDelLocking.Amount) + err = bva.DelegatedLocking.Set(ctx, bondDenom, newDelLocking.Amount) if err != nil { return err } @@ -497,7 +498,7 @@ func (bva *BaseLockup) TrackDelegation( if !y.IsZero() { yCoin := sdk.NewCoin(bondDenom, y) newDelFree := delFreeCoin.Add(yCoin) - err = bva.DelegatedFree.Set(ctx, newDelFree.Denom, newDelFree.Amount) + err = bva.DelegatedFree.Set(ctx, bondDenom, newDelFree.Amount) if err != nil { return err } @@ -524,7 +525,7 @@ func (bva *BaseLockup) TrackUndelegation(ctx context.Context, amount sdk.Coins) delAmt := amount.AmountOf(bondDenom) // return error if the undelegation amount is zero if delAmt.IsZero() { - return sdkerrors.ErrInvalidCoins.Wrap("undelegation attempt with zero coins") + return sdkerrors.ErrInvalidCoins.Wrap("undelegation attempt with zero coins for staking denom") } delFreeAmt, err := bva.DelegatedFree.Get(ctx, bondDenom) if err != nil { @@ -546,7 +547,7 @@ func (bva *BaseLockup) TrackUndelegation(ctx context.Context, amount sdk.Coins) if !x.IsZero() { xCoin := sdk.NewCoin(bondDenom, x) newDelFree := delFreeCoin.Sub(xCoin) - err = bva.DelegatedFree.Set(ctx, newDelFree.Denom, newDelFree.Amount) + err = bva.DelegatedFree.Set(ctx, bondDenom, newDelFree.Amount) if err != nil { return err } @@ -555,7 +556,7 @@ func (bva *BaseLockup) TrackUndelegation(ctx context.Context, amount sdk.Coins) if !y.IsZero() { yCoin := sdk.NewCoin(bondDenom, y) newDelLocking := delLockingCoin.Sub(yCoin) - err = bva.DelegatedLocking.Set(ctx, newDelLocking.Denom, newDelLocking.Amount) + err = bva.DelegatedLocking.Set(ctx, bondDenom, newDelLocking.Amount) if err != nil { return err } @@ -626,6 +627,16 @@ func (bva BaseLockup) IterateCoinEntries( // GetNotBondedLockedCoin returns the coin that are not spendable that are not bonded by denom // for a lockup account. If the coin by the provided denom are not locked, an coin with zero amount is returned. func (bva BaseLockup) GetNotBondedLockedCoin(ctx context.Context, lockedCoin sdk.Coin, denom string) (sdk.Coin, error) { + bondDenom, err := getStakingDenom(ctx) + if err != nil { + return sdk.Coin{}, err + } + + // if not bond denom then return the full locked coin + if bondDenom != denom { + return lockedCoin, nil + } + delegatedLockingAmt, err := bva.DelegatedLocking.Get(ctx, denom) if err != nil { return sdk.Coin{}, err @@ -665,23 +676,22 @@ func (bva BaseLockup) QueryLockupAccountBaseInfo(ctx context.Context, _ *lockupt return nil, err } - delegatedLocking := sdk.Coins{} - err = bva.IterateCoinEntries(ctx, bva.DelegatedLocking, func(key string, value math.Int) (stop bool, err error) { - delegatedLocking = append(delegatedLocking, sdk.NewCoin(key, value)) - return false, nil - }) + bondDenom, err := getStakingDenom(ctx) if err != nil { return nil, err } - delegatedFree := sdk.Coins{} - err = bva.IterateCoinEntries(ctx, bva.DelegatedFree, func(key string, value math.Int) (stop bool, err error) { - delegatedFree = append(delegatedFree, sdk.NewCoin(key, value)) - return false, nil - }) + delegatedLockingAmt, err := bva.DelegatedLocking.Get(ctx, bondDenom) + if err != nil { + return nil, err + } + delegatedLocking := sdk.NewCoins(sdk.NewCoin(bondDenom, delegatedLockingAmt)) + + delegatedFreeAmt, err := bva.DelegatedFree.Get(ctx, bondDenom) if err != nil { return nil, err } + delegatedFree := sdk.NewCoins(sdk.NewCoin(bondDenom, delegatedFreeAmt)) return &lockuptypes.QueryLockupAccountInfoResponse{ Owner: ownerAddress, From 5e5661dd05fa243a931b3c44d406e24e8010806b Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Wed, 24 Apr 2024 14:46:29 +0700 Subject: [PATCH 14/22] fix test --- x/accounts/defaults/lockup/lockup_test.go | 6 +++--- x/accounts/defaults/lockup/utils_test.go | 13 ++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/x/accounts/defaults/lockup/lockup_test.go b/x/accounts/defaults/lockup/lockup_test.go index 6d34540a85a..5e9d51669cc 100644 --- a/x/accounts/defaults/lockup/lockup_test.go +++ b/x/accounts/defaults/lockup/lockup_test.go @@ -127,7 +127,7 @@ func TestTrackingDelegation(t *testing.T) { nil, nil, nil, - sdkerrors.ErrInvalidCoins.Wrap("delegation attempt with zero coins or insufficient funds"), + sdkerrors.ErrInvalidCoins.Wrap("delegation attempt with zero coins for staking denom or insufficient funds"), }, { "zero amount", @@ -136,7 +136,7 @@ func TestTrackingDelegation(t *testing.T) { nil, nil, nil, - sdkerrors.ErrInvalidCoins.Wrap("delegation attempt with zero coins or insufficient funds"), + sdkerrors.ErrInvalidCoins.Wrap("delegation attempt with zero coins for staking denom or insufficient funds"), }, } @@ -199,7 +199,7 @@ func TestTrackingUnDelegation(t *testing.T) { sdk.Coins{sdk.NewCoin("test", math.NewInt(0))}, nil, nil, - sdkerrors.ErrInvalidCoins.Wrap("undelegation attempt with zero coins"), + sdkerrors.ErrInvalidCoins.Wrap("undelegation attempt with zero coins for staking denom"), }, } diff --git a/x/accounts/defaults/lockup/utils_test.go b/x/accounts/defaults/lockup/utils_test.go index 32912d32052..fcb72c7a11f 100644 --- a/x/accounts/defaults/lockup/utils_test.go +++ b/x/accounts/defaults/lockup/utils_test.go @@ -13,6 +13,7 @@ import ( "cosmossdk.io/math" "cosmossdk.io/x/accounts/accountstd" banktypes "cosmossdk.io/x/bank/types" + stakingtypes "cosmossdk.io/x/staking/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -60,13 +61,23 @@ func newMockContext(t *testing.T) (context.Context, store.KVStoreService) { return nil, nil }, func(ctx context.Context, req, resp ProtoMsg) error { _, ok := req.(*banktypes.QueryBalanceRequest) - require.True(t, ok) + if !ok { + _, ok = req.(*stakingtypes.QueryParamsRequest) + require.True(t, ok) + gogoproto.Merge(resp.(gogoproto.Message), &stakingtypes.QueryParamsResponse{ + Params: stakingtypes.Params{ + BondDenom: "test", + }, + }) + return nil + } gogoproto.Merge(resp.(gogoproto.Message), &banktypes.QueryBalanceResponse{ Balance: &sdk.Coin{ Denom: "test", Amount: math.NewInt(5), }, }) + return nil }, ) From d8787f0ab628edabfd119518c1a0d3160148ee8a Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Wed, 24 Apr 2024 15:45:55 +0700 Subject: [PATCH 15/22] remove branch service --- x/accounts/defaults/lockup/lockup.go | 180 +++++++++++---------------- 1 file changed, 74 insertions(+), 106 deletions(-) diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index 4299a18d921..08f22b30496 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -11,7 +11,6 @@ import ( "cosmossdk.io/collections" collcodec "cosmossdk.io/collections/codec" "cosmossdk.io/core/address" - "cosmossdk.io/core/branch" "cosmossdk.io/core/header" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" @@ -56,7 +55,6 @@ func newBaseLockup(d accountstd.Dependencies) *BaseLockup { WithdrawedCoins: collections.NewMap(d.SchemaBuilder, WithdrawedCoinsPrefix, "withdrawed_coins", collections.StringKey, sdk.IntValue), addressCodec: d.AddressCodec, headerService: d.Environment.HeaderService, - branchService: d.Environment.BranchService, EndTime: collections.NewItem(d.SchemaBuilder, EndTimePrefix, "end_time", collcodec.KeyToValueCodec[time.Time](sdk.TimeKey)), } @@ -70,7 +68,6 @@ type BaseLockup struct { DelegatedFree collections.Map[string, math.Int] DelegatedLocking collections.Map[string, math.Int] WithdrawedCoins collections.Map[string, math.Int] - branchService branch.Service addressCodec address.Codec headerService header.Service // lockup end time. @@ -156,38 +153,27 @@ func (bva *BaseLockup) Delegate( return nil, err } - responses := []*codectypes.Any{} - - err = bva.branchService.Execute(ctx, func(ctx context.Context) error { - err = bva.TrackDelegation( - ctx, - sdk.Coins{*balance}, - lockedCoins, - sdk.Coins{msg.Amount}, - ) - if err != nil { - return err - } - - msgDelegate := &stakingtypes.MsgDelegate{ - DelegatorAddress: delegatorAddress, - ValidatorAddress: msg.ValidatorAddress, - Amount: msg.Amount, - } - resp, err := sendMessage(ctx, msgDelegate) - if err != nil { - return err - } - - responses = append(responses, resp...) + err = bva.TrackDelegation( + ctx, + sdk.Coins{*balance}, + lockedCoins, + sdk.Coins{msg.Amount}, + ) + if err != nil { + return nil, err + } - return nil - }) + msgDelegate := &stakingtypes.MsgDelegate{ + DelegatorAddress: delegatorAddress, + ValidatorAddress: msg.ValidatorAddress, + Amount: msg.Amount, + } + resp, err := sendMessage(ctx, msgDelegate) if err != nil { return nil, err } - return &lockuptypes.MsgExecuteMessagesResponse{Responses: responses}, nil + return &lockuptypes.MsgExecuteMessagesResponse{Responses: resp}, nil } func (bva *BaseLockup) Undelegate( @@ -205,33 +191,22 @@ func (bva *BaseLockup) Undelegate( return nil, err } - responses := []*codectypes.Any{} - - err = bva.branchService.Execute(ctx, func(ctx context.Context) error { - err = bva.TrackUndelegation(ctx, sdk.Coins{msg.Amount}) - if err != nil { - return err - } - - msgUndelegate := &stakingtypes.MsgUndelegate{ - DelegatorAddress: delegatorAddress, - ValidatorAddress: msg.ValidatorAddress, - Amount: msg.Amount, - } - resp, err := sendMessage(ctx, msgUndelegate) - if err != nil { - return err - } - - responses = append(responses, resp...) + err = bva.TrackUndelegation(ctx, sdk.Coins{msg.Amount}) + if err != nil { + return nil, err + } - return nil - }) + msgUndelegate := &stakingtypes.MsgUndelegate{ + DelegatorAddress: delegatorAddress, + ValidatorAddress: msg.ValidatorAddress, + Amount: msg.Amount, + } + resp, err := sendMessage(ctx, msgUndelegate) if err != nil { return nil, err } - return &lockuptypes.MsgExecuteMessagesResponse{Responses: responses}, nil + return &lockuptypes.MsgExecuteMessagesResponse{Responses: resp}, nil } func (bva *BaseLockup) WithdrawReward( @@ -326,71 +301,64 @@ func (bva *BaseLockup) WithdrawUnlockedCoins( amount := sdk.Coins{} - err = bva.branchService.Execute(ctx, func(ctx context.Context) error { - for _, denom := range msg.Denoms { - balance, err := bva.getBalance(ctx, fromAddress, denom) - if err != nil { - return err - } - lockedAmt := lockedCoins.AmountOf(denom) - - // get lockedCoin from that are not bonded for the sent denom - notBondedLockedCoin, err := bva.GetNotBondedLockedCoin(ctx, sdk.NewCoin(denom, lockedAmt), denom) - if err != nil { - return err - } - - spendable, err := balance.SafeSub(notBondedLockedCoin) - if err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, - "locked amount exceeds account balance funds: %s > %s", notBondedLockedCoin, balance) - } - - withdrawedAmt, err := bva.WithdrawedCoins.Get(ctx, denom) - if err != nil { - return err - } - originalLockingAmt, err := bva.OriginalLocking.Get(ctx, denom) - if err != nil { - return err - } + for _, denom := range msg.Denoms { + balance, err := bva.getBalance(ctx, fromAddress, denom) + if err != nil { + return nil, err + } + lockedAmt := lockedCoins.AmountOf(denom) - // withdrawable amount is equal to original locking amount subtract already withdrawed amount - withdrawableAmt, err := originalLockingAmt.SafeSub(withdrawedAmt) - if err != nil { - return err - } + // get lockedCoin from that are not bonded for the sent denom + notBondedLockedCoin, err := bva.GetNotBondedLockedCoin(ctx, sdk.NewCoin(denom, lockedAmt), denom) + if err != nil { + return nil, err + } - withdrawAmt := math.MinInt(withdrawableAmt, spendable.Amount) - // if zero amount go to the next iteration - if withdrawAmt.IsZero() { - continue - } - amount = append(amount, sdk.NewCoin(denom, withdrawAmt)) + spendable, err := balance.SafeSub(notBondedLockedCoin) + if err != nil { + return nil, errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, + "locked amount exceeds account balance funds: %s > %s", notBondedLockedCoin, balance) + } - // update the withdrawed amount - err = bva.WithdrawedCoins.Set(ctx, denom, withdrawedAmt.Add(withdrawAmt)) - if err != nil { - return err - } + withdrawedAmt, err := bva.WithdrawedCoins.Get(ctx, denom) + if err != nil { + return nil, err + } + originalLockingAmt, err := bva.OriginalLocking.Get(ctx, denom) + if err != nil { + return nil, err } - if len(amount) == 0 { - return fmt.Errorf("no tokens available for withdrawing") + + // withdrawable amount is equal to original locking amount subtract already withdrawed amount + withdrawableAmt, err := originalLockingAmt.SafeSub(withdrawedAmt) + if err != nil { + return nil, err } - msgSend := &banktypes.MsgSend{ - FromAddress: fromAddress, - ToAddress: msg.ToAddress, - Amount: amount, + withdrawAmt := math.MinInt(withdrawableAmt, spendable.Amount) + // if zero amount go to the next iteration + if withdrawAmt.IsZero() { + continue } + amount = append(amount, sdk.NewCoin(denom, withdrawAmt)) - _, err = sendMessage(ctx, msgSend) + // update the withdrawed amount + err = bva.WithdrawedCoins.Set(ctx, denom, withdrawedAmt.Add(withdrawAmt)) if err != nil { - return err + return nil, err } + } + if len(amount) == 0 { + return nil, fmt.Errorf("no tokens available for withdrawing") + } - return nil - }) + msgSend := &banktypes.MsgSend{ + FromAddress: fromAddress, + ToAddress: msg.ToAddress, + Amount: amount, + } + + _, err = sendMessage(ctx, msgSend) if err != nil { return nil, err } From a67166c10bb6f295dd28c98682ef9ac58cd3cb44 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Wed, 24 Apr 2024 16:29:52 +0700 Subject: [PATCH 16/22] add e2e test for withdraw reward --- .../lockup/continous_lockup_test_suite.go | 15 ++++++++++++--- .../accounts/lockup/delayed_lockup_test_suite.go | 15 ++++++++++++--- .../accounts/lockup/periodic_lockup_test_suite.go | 15 ++++++++++++--- .../lockup/permanent_lockup_test_suite.go | 15 ++++++++++++--- 4 files changed, 48 insertions(+), 12 deletions(-) diff --git a/tests/e2e/accounts/lockup/continous_lockup_test_suite.go b/tests/e2e/accounts/lockup/continous_lockup_test_suite.go index 36749f7f410..6d1c34924fb 100644 --- a/tests/e2e/accounts/lockup/continous_lockup_test_suite.go +++ b/tests/e2e/accounts/lockup/continous_lockup_test_suite.go @@ -40,6 +40,10 @@ func (s *E2ETestSuite) TestContinuousLockingAccount() { addr, err := app.AuthKeeper.AddressCodec().BytesToString(randAcc) require.NoError(t, err) + vals, err := app.StakingKeeper.GetAllValidators(ctx) + require.NoError(t, err) + val := vals[0] + t.Run("error - execute message, wrong sender", func(t *testing.T) { msg := &types.MsgSend{ Sender: addr, @@ -109,9 +113,6 @@ func (s *E2ETestSuite) TestContinuousLockingAccount() { require.True(t, balance.Amount.Equal(math.NewInt(100))) }) t.Run("ok - execute delegate message", func(t *testing.T) { - vals, err := app.StakingKeeper.GetAllValidators(ctx) - require.NoError(t, err) - val := vals[0] msg := &types.MsgDelegate{ Sender: ownerAddrStr, ValidatorAddress: val.OperatorAddress, @@ -129,6 +130,14 @@ func (s *E2ETestSuite) TestContinuousLockingAccount() { require.NoError(t, err) require.NotNil(t, del) }) + t.Run("ok - execute withdraw reward message", func(t *testing.T) { + msg := &types.MsgWithdrawReward{ + Sender: ownerAddrStr, + ValidatorAddress: val.OperatorAddress, + } + err = s.executeTx(ctx, msg, app, accountAddr, accOwner) + require.NoError(t, err) + }) t.Run("ok - execute undelegate message", func(t *testing.T) { vals, err := app.StakingKeeper.GetAllValidators(ctx) require.NoError(t, err) diff --git a/tests/e2e/accounts/lockup/delayed_lockup_test_suite.go b/tests/e2e/accounts/lockup/delayed_lockup_test_suite.go index 73254b7f3b3..7c540f4fdde 100644 --- a/tests/e2e/accounts/lockup/delayed_lockup_test_suite.go +++ b/tests/e2e/accounts/lockup/delayed_lockup_test_suite.go @@ -39,6 +39,10 @@ func (s *E2ETestSuite) TestDelayedLockingAccount() { addr, err := app.AuthKeeper.AddressCodec().BytesToString(randAcc) require.NoError(t, err) + vals, err := app.StakingKeeper.GetAllValidators(ctx) + require.NoError(t, err) + val := vals[0] + t.Run("error - execute message, wrong sender", func(t *testing.T) { msg := &types.MsgSend{ Sender: addr, @@ -71,9 +75,6 @@ func (s *E2ETestSuite) TestDelayedLockingAccount() { require.NotNil(t, err) }) t.Run("ok - execute delegate message", func(t *testing.T) { - vals, err := app.StakingKeeper.GetAllValidators(ctx) - require.NoError(t, err) - val := vals[0] msg := &types.MsgDelegate{ Sender: ownerAddrStr, ValidatorAddress: val.OperatorAddress, @@ -91,6 +92,14 @@ func (s *E2ETestSuite) TestDelayedLockingAccount() { require.NoError(t, err) require.NotNil(t, del) }) + t.Run("ok - execute withdraw reward message", func(t *testing.T) { + msg := &types.MsgWithdrawReward{ + Sender: ownerAddrStr, + ValidatorAddress: val.OperatorAddress, + } + err = s.executeTx(ctx, msg, app, accountAddr, accOwner) + require.NoError(t, err) + }) t.Run("ok - execute undelegate message", func(t *testing.T) { vals, err := app.StakingKeeper.GetAllValidators(ctx) require.NoError(t, err) diff --git a/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go b/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go index 11647e7c94c..65f218902e9 100644 --- a/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go +++ b/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go @@ -47,6 +47,10 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() { addr, err := app.AuthKeeper.AddressCodec().BytesToString(randAcc) require.NoError(t, err) + vals, err := app.StakingKeeper.GetAllValidators(ctx) + require.NoError(t, err) + val := vals[0] + t.Run("error - execute message, wrong sender", func(t *testing.T) { msg := &types.MsgSend{ Sender: addr, @@ -129,9 +133,6 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() { s.fundAccount(app, ctx, accountAddr, sdk.Coins{sdk.NewCoin("stake", math.NewInt(100))}) t.Run("ok - execute delegate message", func(t *testing.T) { - vals, err := app.StakingKeeper.GetAllValidators(ctx) - require.NoError(t, err) - val := vals[0] msg := &types.MsgDelegate{ Sender: ownerAddrStr, ValidatorAddress: val.OperatorAddress, @@ -149,6 +150,14 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() { require.NoError(t, err) require.NotNil(t, del) }) + t.Run("ok - execute withdraw reward message", func(t *testing.T) { + msg := &types.MsgWithdrawReward{ + Sender: ownerAddrStr, + ValidatorAddress: val.OperatorAddress, + } + err = s.executeTx(ctx, msg, app, accountAddr, accOwner) + require.NoError(t, err) + }) t.Run("ok - execute undelegate message", func(t *testing.T) { vals, err := app.StakingKeeper.GetAllValidators(ctx) require.NoError(t, err) diff --git a/tests/e2e/accounts/lockup/permanent_lockup_test_suite.go b/tests/e2e/accounts/lockup/permanent_lockup_test_suite.go index a376f018865..9514f73c0fe 100644 --- a/tests/e2e/accounts/lockup/permanent_lockup_test_suite.go +++ b/tests/e2e/accounts/lockup/permanent_lockup_test_suite.go @@ -36,6 +36,10 @@ func (s *E2ETestSuite) TestPermanentLockingAccount() { addr, err := app.AuthKeeper.AddressCodec().BytesToString(randAcc) require.NoError(t, err) + vals, err := app.StakingKeeper.GetAllValidators(ctx) + require.NoError(t, err) + val := vals[0] + t.Run("error - execute message, wrong sender", func(t *testing.T) { msg := &types.MsgSend{ Sender: addr, @@ -55,9 +59,6 @@ func (s *E2ETestSuite) TestPermanentLockingAccount() { require.NotNil(t, err) }) t.Run("ok - execute delegate message", func(t *testing.T) { - vals, err := app.StakingKeeper.GetAllValidators(ctx) - require.NoError(t, err) - val := vals[0] msg := &types.MsgDelegate{ Sender: ownerAddrStr, ValidatorAddress: val.OperatorAddress, @@ -75,6 +76,14 @@ func (s *E2ETestSuite) TestPermanentLockingAccount() { require.NoError(t, err) require.NotNil(t, del) }) + t.Run("ok - execute withdraw reward message", func(t *testing.T) { + msg := &types.MsgWithdrawReward{ + Sender: ownerAddrStr, + ValidatorAddress: val.OperatorAddress, + } + err = s.executeTx(ctx, msg, app, accountAddr, accOwner) + require.NoError(t, err) + }) t.Run("ok - execute undelegate message", func(t *testing.T) { vals, err := app.StakingKeeper.GetAllValidators(ctx) require.NoError(t, err) From d968fc793886dbe3eee54a9b1d00cd04dc39d8a1 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Wed, 24 Apr 2024 16:52:51 +0700 Subject: [PATCH 17/22] add tracking check for del and undel --- .../lockup/continous_lockup_test_suite.go | 42 +++++++++++++++++++ .../lockup/delayed_lockup_test_suite.go | 10 +++++ .../lockup/periodic_lockup_test_suite.go | 10 +++++ .../lockup/permanent_lockup_test_suite.go | 10 +++++ tests/e2e/accounts/lockup/utils.go | 21 ++++++++++ x/accounts/defaults/lockup/lockup.go | 8 ++++ 6 files changed, 101 insertions(+) diff --git a/tests/e2e/accounts/lockup/continous_lockup_test_suite.go b/tests/e2e/accounts/lockup/continous_lockup_test_suite.go index 6d1c34924fb..e331579cb6c 100644 --- a/tests/e2e/accounts/lockup/continous_lockup_test_suite.go +++ b/tests/e2e/accounts/lockup/continous_lockup_test_suite.go @@ -129,6 +129,11 @@ func (s *E2ETestSuite) TestContinuousLockingAccount() { ) require.NoError(t, err) require.NotNil(t, del) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.NewInt(100))) }) t.Run("ok - execute withdraw reward message", func(t *testing.T) { msg := &types.MsgWithdrawReward{ @@ -157,5 +162,42 @@ func (s *E2ETestSuite) TestContinuousLockingAccount() { ) require.NoError(t, err) require.Equal(t, len(ubd.Entries), 1) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) + }) + + // Update context time to end time + ctx = ctx.WithHeaderInfo(header.Info{ + Time: currentTime.Add(time.Minute), + }) + + // test if tracking delegate work perfectly + t.Run("ok - execute delegate message", func(t *testing.T) { + msg := &types.MsgDelegate{ + Sender: ownerAddrStr, + ValidatorAddress: val.OperatorAddress, + Amount: sdk.NewCoin("stake", math.NewInt(100)), + } + err = s.executeTx(ctx, msg, app, accountAddr, accOwner) + require.NoError(t, err) + + valbz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.OperatorAddress) + require.NoError(t, err) + + del, err := app.StakingKeeper.Delegations.Get( + ctx, collections.Join(sdk.AccAddress(accountAddr), sdk.ValAddress(valbz)), + ) + require.NoError(t, err) + require.NotNil(t, del) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) + delFree := lockupAccountInfoResponse.DelegatedFree + require.True(t, delFree.AmountOf("stake").Equal(math.NewInt(100))) }) } diff --git a/tests/e2e/accounts/lockup/delayed_lockup_test_suite.go b/tests/e2e/accounts/lockup/delayed_lockup_test_suite.go index 7c540f4fdde..1b5a8784eeb 100644 --- a/tests/e2e/accounts/lockup/delayed_lockup_test_suite.go +++ b/tests/e2e/accounts/lockup/delayed_lockup_test_suite.go @@ -91,6 +91,11 @@ func (s *E2ETestSuite) TestDelayedLockingAccount() { ) require.NoError(t, err) require.NotNil(t, del) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.NewInt(100))) }) t.Run("ok - execute withdraw reward message", func(t *testing.T) { msg := &types.MsgWithdrawReward{ @@ -119,6 +124,11 @@ func (s *E2ETestSuite) TestDelayedLockingAccount() { ) require.NoError(t, err) require.Equal(t, len(ubd.Entries), 1) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) }) // Update context time diff --git a/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go b/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go index 65f218902e9..98990962a77 100644 --- a/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go +++ b/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go @@ -149,6 +149,11 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() { ) require.NoError(t, err) require.NotNil(t, del) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.NewInt(100))) }) t.Run("ok - execute withdraw reward message", func(t *testing.T) { msg := &types.MsgWithdrawReward{ @@ -177,5 +182,10 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() { ) require.NoError(t, err) require.Equal(t, len(ubd.Entries), 1) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) }) } diff --git a/tests/e2e/accounts/lockup/permanent_lockup_test_suite.go b/tests/e2e/accounts/lockup/permanent_lockup_test_suite.go index 9514f73c0fe..2ddec4ddf30 100644 --- a/tests/e2e/accounts/lockup/permanent_lockup_test_suite.go +++ b/tests/e2e/accounts/lockup/permanent_lockup_test_suite.go @@ -75,6 +75,11 @@ func (s *E2ETestSuite) TestPermanentLockingAccount() { ) require.NoError(t, err) require.NotNil(t, del) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.NewInt(100))) }) t.Run("ok - execute withdraw reward message", func(t *testing.T) { msg := &types.MsgWithdrawReward{ @@ -103,6 +108,11 @@ func (s *E2ETestSuite) TestPermanentLockingAccount() { ) require.NoError(t, err) require.Equal(t, len(ubd.Entries), 1) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delLocking := lockupAccountInfoResponse.DelegatedLocking + require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) }) s.fundAccount(app, ctx, accountAddr, sdk.Coins{sdk.NewCoin("stake", math.NewInt(1000))}) diff --git a/tests/e2e/accounts/lockup/utils.go b/tests/e2e/accounts/lockup/utils.go index d486b33d38e..f636459dd06 100644 --- a/tests/e2e/accounts/lockup/utils.go +++ b/tests/e2e/accounts/lockup/utils.go @@ -5,14 +5,18 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "google.golang.org/protobuf/runtime/protoiface" "cosmossdk.io/simapp" + "cosmossdk.io/x/accounts/defaults/lockup/types" "cosmossdk.io/x/bank/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" ) +type ProtoMsg = protoiface.MessageV1 + var ( ownerAddr = secp256k1.GenPrivKey().PubKey().Address() accOwner = sdk.AccAddress(ownerAddr) @@ -48,6 +52,23 @@ func (s *E2ETestSuite) executeTx(ctx sdk.Context, msg sdk.Msg, app *simapp.SimAp return err } +func (s *E2ETestSuite) queryAcc(ctx sdk.Context, req sdk.Msg, app *simapp.SimApp, accAddr []byte) (ProtoMsg, error) { + resp, err := app.AccountsKeeper.Query(ctx, accAddr, req) + return resp, err +} + func (s *E2ETestSuite) fundAccount(app *simapp.SimApp, ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) { require.NoError(s.T(), testutil.FundAccount(ctx, app.BankKeeper, addr, amt)) } + +func (s *E2ETestSuite) queryLockupAccInfo(t *testing.T, ctx sdk.Context, app *simapp.SimApp, accAddr []byte) *types.QueryLockupAccountInfoResponse { + req := &types.QueryLockupAccountInfoRequest{} + resp, err := s.queryAcc(ctx, req, app, accAddr) + require.NoError(t, err) + require.NotNil(t, resp) + + lockupAccountInfoResponse, ok := resp.(*types.QueryLockupAccountInfoResponse) + require.True(t, ok) + + return lockupAccountInfoResponse +} diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index 08f22b30496..fb50fc6a0b3 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -658,6 +658,14 @@ func (bva BaseLockup) QueryLockupAccountBaseInfo(ctx context.Context, _ *lockupt } delegatedFree := sdk.NewCoins(sdk.NewCoin(bondDenom, delegatedFreeAmt)) + fmt.Println(lockuptypes.QueryLockupAccountInfoResponse{ + Owner: ownerAddress, + OriginalLocking: originalLocking, + DelegatedLocking: delegatedLocking, + DelegatedFree: delegatedFree, + EndTime: &endTime, + }) + return &lockuptypes.QueryLockupAccountInfoResponse{ Owner: ownerAddress, OriginalLocking: originalLocking, From 74f856a4b309f564d045a6daebc3cc7fa61f0c75 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Thu, 25 Apr 2024 08:48:47 +0700 Subject: [PATCH 18/22] minor --- x/accounts/defaults/lockup/periodic_locking_account.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/x/accounts/defaults/lockup/periodic_locking_account.go b/x/accounts/defaults/lockup/periodic_locking_account.go index fb88c28cad2..71013980d9d 100644 --- a/x/accounts/defaults/lockup/periodic_locking_account.go +++ b/x/accounts/defaults/lockup/periodic_locking_account.go @@ -200,10 +200,7 @@ func (pva PeriodicLockingAccount) GetLockCoinsInfo(ctx context.Context, blockTim unlockedCoins = unlockedCoins.Add(period.Amount...) // update the start time of the next period - err = pva.StartTime.Set(ctx, currentPeriodStartTime.Add(period.Length)) - if err != nil { - return true, err - } + currentPeriodStartTime = currentPeriodStartTime.Add(period.Length) return false, nil }) if err != nil { @@ -267,10 +264,7 @@ func (pva PeriodicLockingAccount) GetLockCoinInfoWithDenom(ctx context.Context, unlocked = unlocked.Add(sdk.NewCoin(denom, period.Amount.AmountOf(denom))) // update the start time of the next period - err = pva.StartTime.Set(ctx, currentPeriodStartTime.Add(period.Length)) - if err != nil { - return true, err - } + currentPeriodStartTime = currentPeriodStartTime.Add(period.Length) return false, nil }) if err != nil { From 0bcfadde38dff17872c9a98dfb8b4dcbf8b16dda Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Thu, 25 Apr 2024 09:30:26 +0700 Subject: [PATCH 19/22] remove print log --- x/accounts/defaults/lockup/lockup.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index fb50fc6a0b3..08f22b30496 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -658,14 +658,6 @@ func (bva BaseLockup) QueryLockupAccountBaseInfo(ctx context.Context, _ *lockupt } delegatedFree := sdk.NewCoins(sdk.NewCoin(bondDenom, delegatedFreeAmt)) - fmt.Println(lockuptypes.QueryLockupAccountInfoResponse{ - Owner: ownerAddress, - OriginalLocking: originalLocking, - DelegatedLocking: delegatedLocking, - DelegatedFree: delegatedFree, - EndTime: &endTime, - }) - return &lockuptypes.QueryLockupAccountInfoResponse{ Owner: ownerAddress, OriginalLocking: originalLocking, From 28eb59a058a31f58eb74ee29627b9b6739448084 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Thu, 25 Apr 2024 09:38:35 +0700 Subject: [PATCH 20/22] fix test --- .../lockup/periodic_lockup_test_suite.go | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go b/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go index 98990962a77..33be5172452 100644 --- a/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go +++ b/tests/e2e/accounts/lockup/periodic_lockup_test_suite.go @@ -1,6 +1,7 @@ package lockup import ( + "fmt" "testing" "time" @@ -40,8 +41,12 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() { Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(500))), Length: time.Minute, }, + { + Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(500))), + Length: time.Minute, + }, }, - }, sdk.Coins{sdk.NewCoin("stake", math.NewInt(1000))}) + }, sdk.Coins{sdk.NewCoin("stake", math.NewInt(1500))}) require.NoError(t, err) addr, err := app.AuthKeeper.AddressCodec().BytesToString(randAcc) @@ -129,9 +134,6 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() { require.True(t, balance.Amount.Equal(math.NewInt(500))) }) - // Fund acc since we withdraw all the funds - s.fundAccount(app, ctx, accountAddr, sdk.Coins{sdk.NewCoin("stake", math.NewInt(100))}) - t.Run("ok - execute delegate message", func(t *testing.T) { msg := &types.MsgDelegate{ Sender: ownerAddrStr, @@ -152,6 +154,7 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() { // check if tracking is updated accordingly lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + fmt.Println(lockupAccountInfoResponse) delLocking := lockupAccountInfoResponse.DelegatedLocking require.True(t, delLocking.AmountOf("stake").Equal(math.NewInt(100))) }) @@ -188,4 +191,34 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() { delLocking := lockupAccountInfoResponse.DelegatedLocking require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt())) }) + + // Update context time + // After third period 1500stake should be unlock + ctx = ctx.WithHeaderInfo(header.Info{ + Time: currentTime.Add(time.Minute * 3), + }) + + t.Run("ok - execute delegate message", func(t *testing.T) { + msg := &types.MsgDelegate{ + Sender: ownerAddrStr, + ValidatorAddress: val.OperatorAddress, + Amount: sdk.NewCoin("stake", math.NewInt(100)), + } + err = s.executeTx(ctx, msg, app, accountAddr, accOwner) + require.NoError(t, err) + + valbz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.OperatorAddress) + require.NoError(t, err) + + del, err := app.StakingKeeper.Delegations.Get( + ctx, collections.Join(sdk.AccAddress(accountAddr), sdk.ValAddress(valbz)), + ) + require.NoError(t, err) + require.NotNil(t, del) + + // check if tracking is updated accordingly + lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr) + delFree := lockupAccountInfoResponse.DelegatedFree + require.True(t, delFree.AmountOf("stake").Equal(math.NewInt(100))) + }) } From bfb1e18f87993973b1a8742960a0928d5979abb6 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Mon, 29 Apr 2024 15:00:17 +0700 Subject: [PATCH 21/22] minor --- x/accounts/defaults/lockup/sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/accounts/defaults/lockup/sonar-project.properties b/x/accounts/defaults/lockup/sonar-project.properties index 84929aa7ef1..1d025ad1069 100644 --- a/x/accounts/defaults/lockup/sonar-project.properties +++ b/x/accounts/defaults/lockup/sonar-project.properties @@ -1,4 +1,4 @@ -sonar.projectKey=cosmos-sdk-x-accounts-lockup +sonar.projectKey=cosmos-sdk-x-accounts-defaults-lockup sonar.organization=cosmos sonar.projectName=Cosmos SDK - x/accounts/defaults/lockup From 4a13043286b6c2d0f5dd99a9fe5fd911cbc08749 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Mon, 29 Apr 2024 15:05:45 +0700 Subject: [PATCH 22/22] minor --- .github/workflows/test.yml | 8 -------- .../defaults/lockup/sonar-project.properties | 15 --------------- 2 files changed, 23 deletions(-) delete mode 100644 x/accounts/defaults/lockup/sonar-project.properties diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b8e796d8d98..f99936eafda 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -722,14 +722,6 @@ jobs: run: | cd x/accounts/defaults/lockup go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock' ./... - - name: sonarcloud - if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }} - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - projectBaseDir: x/accounts/defaults/lockup/ test-x-tx: runs-on: ubuntu-latest diff --git a/x/accounts/defaults/lockup/sonar-project.properties b/x/accounts/defaults/lockup/sonar-project.properties deleted file mode 100644 index 1d025ad1069..00000000000 --- a/x/accounts/defaults/lockup/sonar-project.properties +++ /dev/null @@ -1,15 +0,0 @@ -sonar.projectKey=cosmos-sdk-x-accounts-defaults-lockup -sonar.organization=cosmos - -sonar.projectName=Cosmos SDK - x/accounts/defaults/lockup -sonar.project.monorepo.enabled=true - -sonar.sources=. -sonar.exclusions=**/*_test.go -sonar.tests=. -sonar.test.inclusions=**/*_test.go -sonar.go.coverage.reportPaths=coverage.out - -sonar.sourceEncoding=UTF-8 -sonar.scm.provider=git -sonar.pullrequest.github.summary_comment=true \ No newline at end of file