Extend BaseAccount instead of ModuleAccount
Some checks failed
Protobuf / lint (pull_request) Successful in 8s
Integration Tests / test-integration (pull_request) Failing after 1m4s
E2E Tests / test-e2e (pull_request) Failing after 1m17s
Unit Tests / test-unit (pull_request) Successful in 1m1s
SDK Tests / sdk_tests_nameservice_expiry (pull_request) Successful in 5m22s
SDK Tests / sdk_tests_authority_auctions (pull_request) Successful in 11m5s
SDK Tests / sdk_tests (pull_request) Successful in 14m26s

This commit is contained in:
Prathamesh Musale 2025-05-16 11:49:09 +05:30
parent ae68e301ba
commit 3d87a74557
7 changed files with 236 additions and 91 deletions

View File

@ -17,15 +17,17 @@ import (
) )
var ( var (
md_LockupAccount protoreflect.MessageDescriptor md_LockupAccount protoreflect.MessageDescriptor
fd_LockupAccount_module_account protoreflect.FieldDescriptor fd_LockupAccount_base_account protoreflect.FieldDescriptor
fd_LockupAccount_distribution protoreflect.FieldDescriptor fd_LockupAccount_name protoreflect.FieldDescriptor
fd_LockupAccount_distribution protoreflect.FieldDescriptor
) )
func init() { func init() {
file_cerc_types_v1_lockup_proto_init() file_cerc_types_v1_lockup_proto_init()
md_LockupAccount = File_cerc_types_v1_lockup_proto.Messages().ByName("LockupAccount") md_LockupAccount = File_cerc_types_v1_lockup_proto.Messages().ByName("LockupAccount")
fd_LockupAccount_module_account = md_LockupAccount.Fields().ByName("module_account") fd_LockupAccount_base_account = md_LockupAccount.Fields().ByName("base_account")
fd_LockupAccount_name = md_LockupAccount.Fields().ByName("name")
fd_LockupAccount_distribution = md_LockupAccount.Fields().ByName("distribution") fd_LockupAccount_distribution = md_LockupAccount.Fields().ByName("distribution")
} }
@ -94,9 +96,15 @@ func (x *fastReflection_LockupAccount) Interface() protoreflect.ProtoMessage {
// While iterating, mutating operations may only be performed // While iterating, mutating operations may only be performed
// on the current field descriptor. // on the current field descriptor.
func (x *fastReflection_LockupAccount) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { func (x *fastReflection_LockupAccount) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
if x.ModuleAccount != nil { if x.BaseAccount != nil {
value := protoreflect.ValueOfMessage(x.ModuleAccount.ProtoReflect()) value := protoreflect.ValueOfMessage(x.BaseAccount.ProtoReflect())
if !f(fd_LockupAccount_module_account, value) { if !f(fd_LockupAccount_base_account, value) {
return
}
}
if x.Name != "" {
value := protoreflect.ValueOfString(x.Name)
if !f(fd_LockupAccount_name, value) {
return return
} }
} }
@ -121,8 +129,10 @@ func (x *fastReflection_LockupAccount) Range(f func(protoreflect.FieldDescriptor
// a repeated field is populated if it is non-empty. // a repeated field is populated if it is non-empty.
func (x *fastReflection_LockupAccount) Has(fd protoreflect.FieldDescriptor) bool { func (x *fastReflection_LockupAccount) Has(fd protoreflect.FieldDescriptor) bool {
switch fd.FullName() { switch fd.FullName() {
case "cerc.types.v1.LockupAccount.module_account": case "cerc.types.v1.LockupAccount.base_account":
return x.ModuleAccount != nil return x.BaseAccount != nil
case "cerc.types.v1.LockupAccount.name":
return x.Name != ""
case "cerc.types.v1.LockupAccount.distribution": case "cerc.types.v1.LockupAccount.distribution":
return x.Distribution != "" return x.Distribution != ""
default: default:
@ -141,8 +151,10 @@ func (x *fastReflection_LockupAccount) Has(fd protoreflect.FieldDescriptor) bool
// Clear is a mutating operation and unsafe for concurrent use. // Clear is a mutating operation and unsafe for concurrent use.
func (x *fastReflection_LockupAccount) Clear(fd protoreflect.FieldDescriptor) { func (x *fastReflection_LockupAccount) Clear(fd protoreflect.FieldDescriptor) {
switch fd.FullName() { switch fd.FullName() {
case "cerc.types.v1.LockupAccount.module_account": case "cerc.types.v1.LockupAccount.base_account":
x.ModuleAccount = nil x.BaseAccount = nil
case "cerc.types.v1.LockupAccount.name":
x.Name = ""
case "cerc.types.v1.LockupAccount.distribution": case "cerc.types.v1.LockupAccount.distribution":
x.Distribution = "" x.Distribution = ""
default: default:
@ -161,9 +173,12 @@ func (x *fastReflection_LockupAccount) Clear(fd protoreflect.FieldDescriptor) {
// of the value; to obtain a mutable reference, use Mutable. // of the value; to obtain a mutable reference, use Mutable.
func (x *fastReflection_LockupAccount) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { func (x *fastReflection_LockupAccount) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
switch descriptor.FullName() { switch descriptor.FullName() {
case "cerc.types.v1.LockupAccount.module_account": case "cerc.types.v1.LockupAccount.base_account":
value := x.ModuleAccount value := x.BaseAccount
return protoreflect.ValueOfMessage(value.ProtoReflect()) return protoreflect.ValueOfMessage(value.ProtoReflect())
case "cerc.types.v1.LockupAccount.name":
value := x.Name
return protoreflect.ValueOfString(value)
case "cerc.types.v1.LockupAccount.distribution": case "cerc.types.v1.LockupAccount.distribution":
value := x.Distribution value := x.Distribution
return protoreflect.ValueOfString(value) return protoreflect.ValueOfString(value)
@ -187,8 +202,10 @@ func (x *fastReflection_LockupAccount) Get(descriptor protoreflect.FieldDescript
// Set is a mutating operation and unsafe for concurrent use. // Set is a mutating operation and unsafe for concurrent use.
func (x *fastReflection_LockupAccount) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { func (x *fastReflection_LockupAccount) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
switch fd.FullName() { switch fd.FullName() {
case "cerc.types.v1.LockupAccount.module_account": case "cerc.types.v1.LockupAccount.base_account":
x.ModuleAccount = value.Message().Interface().(*types.ModuleAccount) x.BaseAccount = value.Message().Interface().(*types.BaseAccount)
case "cerc.types.v1.LockupAccount.name":
x.Name = value.Interface().(string)
case "cerc.types.v1.LockupAccount.distribution": case "cerc.types.v1.LockupAccount.distribution":
x.Distribution = value.Interface().(string) x.Distribution = value.Interface().(string)
default: default:
@ -211,11 +228,13 @@ func (x *fastReflection_LockupAccount) Set(fd protoreflect.FieldDescriptor, valu
// Mutable is a mutating operation and unsafe for concurrent use. // Mutable is a mutating operation and unsafe for concurrent use.
func (x *fastReflection_LockupAccount) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { func (x *fastReflection_LockupAccount) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
switch fd.FullName() { switch fd.FullName() {
case "cerc.types.v1.LockupAccount.module_account": case "cerc.types.v1.LockupAccount.base_account":
if x.ModuleAccount == nil { if x.BaseAccount == nil {
x.ModuleAccount = new(types.ModuleAccount) x.BaseAccount = new(types.BaseAccount)
} }
return protoreflect.ValueOfMessage(x.ModuleAccount.ProtoReflect()) return protoreflect.ValueOfMessage(x.BaseAccount.ProtoReflect())
case "cerc.types.v1.LockupAccount.name":
panic(fmt.Errorf("field name of message cerc.types.v1.LockupAccount is not mutable"))
case "cerc.types.v1.LockupAccount.distribution": case "cerc.types.v1.LockupAccount.distribution":
panic(fmt.Errorf("field distribution of message cerc.types.v1.LockupAccount is not mutable")) panic(fmt.Errorf("field distribution of message cerc.types.v1.LockupAccount is not mutable"))
default: default:
@ -231,9 +250,11 @@ func (x *fastReflection_LockupAccount) Mutable(fd protoreflect.FieldDescriptor)
// For lists, maps, and messages, this returns a new, empty, mutable value. // For lists, maps, and messages, this returns a new, empty, mutable value.
func (x *fastReflection_LockupAccount) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { func (x *fastReflection_LockupAccount) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
switch fd.FullName() { switch fd.FullName() {
case "cerc.types.v1.LockupAccount.module_account": case "cerc.types.v1.LockupAccount.base_account":
m := new(types.ModuleAccount) m := new(types.BaseAccount)
return protoreflect.ValueOfMessage(m.ProtoReflect()) return protoreflect.ValueOfMessage(m.ProtoReflect())
case "cerc.types.v1.LockupAccount.name":
return protoreflect.ValueOfString("")
case "cerc.types.v1.LockupAccount.distribution": case "cerc.types.v1.LockupAccount.distribution":
return protoreflect.ValueOfString("") return protoreflect.ValueOfString("")
default: default:
@ -305,8 +326,12 @@ func (x *fastReflection_LockupAccount) ProtoMethods() *protoiface.Methods {
var n int var n int
var l int var l int
_ = l _ = l
if x.ModuleAccount != nil { if x.BaseAccount != nil {
l = options.Size(x.ModuleAccount) l = options.Size(x.BaseAccount)
n += 1 + l + runtime.Sov(uint64(l))
}
l = len(x.Name)
if l > 0 {
n += 1 + l + runtime.Sov(uint64(l)) n += 1 + l + runtime.Sov(uint64(l))
} }
l = len(x.Distribution) l = len(x.Distribution)
@ -347,10 +372,17 @@ func (x *fastReflection_LockupAccount) ProtoMethods() *protoiface.Methods {
copy(dAtA[i:], x.Distribution) copy(dAtA[i:], x.Distribution)
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Distribution))) i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Distribution)))
i-- i--
dAtA[i] = 0x1a
}
if len(x.Name) > 0 {
i -= len(x.Name)
copy(dAtA[i:], x.Name)
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Name)))
i--
dAtA[i] = 0x12 dAtA[i] = 0x12
} }
if x.ModuleAccount != nil { if x.BaseAccount != nil {
encoded, err := options.Marshal(x.ModuleAccount) encoded, err := options.Marshal(x.BaseAccount)
if err != nil { if err != nil {
return protoiface.MarshalOutput{ return protoiface.MarshalOutput{
NoUnkeyedLiterals: input.NoUnkeyedLiterals, NoUnkeyedLiterals: input.NoUnkeyedLiterals,
@ -414,7 +446,7 @@ func (x *fastReflection_LockupAccount) ProtoMethods() *protoiface.Methods {
switch fieldNum { switch fieldNum {
case 1: case 1:
if wireType != 2 { if wireType != 2 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ModuleAccount", wireType) return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BaseAccount", wireType)
} }
var msglen int var msglen int
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
@ -441,14 +473,46 @@ func (x *fastReflection_LockupAccount) ProtoMethods() *protoiface.Methods {
if postIndex > l { if postIndex > l {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
} }
if x.ModuleAccount == nil { if x.BaseAccount == nil {
x.ModuleAccount = &types.ModuleAccount{} x.BaseAccount = &types.BaseAccount{}
} }
if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.ModuleAccount); err != nil { if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.BaseAccount); err != nil {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err
} }
iNdEx = postIndex iNdEx = postIndex
case 2: case 2:
if wireType != 2 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Name", 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.Name = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 { if wireType != 2 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Distribution", wireType) return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Distribution", wireType)
} }
@ -528,14 +592,17 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
// LockupAccount extends the Cosmos SDK ModuleAccount with a distribution field. // LockupAccount extends the Cosmos SDK BaseAccount with a name and distribution
// field. It satisfies the ModuleAccountI interface to allow querying it as a
// module account.
type LockupAccount struct { type LockupAccount struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
ModuleAccount *types.ModuleAccount `protobuf:"bytes,1,opt,name=module_account,json=moduleAccount,proto3" json:"module_account,omitempty"` BaseAccount *types.BaseAccount `protobuf:"bytes,1,opt,name=base_account,json=baseAccount,proto3" json:"base_account,omitempty"`
Distribution string `protobuf:"bytes,2,opt,name=distribution,proto3" json:"distribution,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Distribution string `protobuf:"bytes,3,opt,name=distribution,proto3" json:"distribution,omitempty"`
} }
func (x *LockupAccount) Reset() { func (x *LockupAccount) Reset() {
@ -558,13 +625,20 @@ func (*LockupAccount) Descriptor() ([]byte, []int) {
return file_cerc_types_v1_lockup_proto_rawDescGZIP(), []int{0} return file_cerc_types_v1_lockup_proto_rawDescGZIP(), []int{0}
} }
func (x *LockupAccount) GetModuleAccount() *types.ModuleAccount { func (x *LockupAccount) GetBaseAccount() *types.BaseAccount {
if x != nil { if x != nil {
return x.ModuleAccount return x.BaseAccount
} }
return nil return nil
} }
func (x *LockupAccount) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *LockupAccount) GetDistribution() string { func (x *LockupAccount) GetDistribution() string {
if x != nil { if x != nil {
return x.Distribution return x.Distribution
@ -584,15 +658,18 @@ var file_cerc_types_v1_lockup_proto_rawDesc = []byte{
0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x61, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x61,
0x75, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x75, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
0xdb, 0x01, 0x0a, 0x0d, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x8b, 0x02, 0x0a, 0x0d, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e,
0x74, 0x12, 0x4f, 0x0a, 0x0e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x74, 0x12, 0x49, 0x0a, 0x0c, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e,
0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73,
0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x42, 0x61,
0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x04, 0xd0, 0x73, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x04, 0xd0, 0xde, 0x1f, 0x01, 0x52,
0xde, 0x1f, 0x01, 0x52, 0x0d, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x0b, 0x62, 0x61, 0x73, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04,
0x6e, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65,
0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e,
0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x55, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75,
0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x77, 0x88, 0xa0, 0x1f, 0x00, 0xca, 0xb4, 0x2d, 0x22, 0x63, 0x6f,
0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61,
0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49,
0xca, 0xb4, 0x2d, 0x1c, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x76, 0xca, 0xb4, 0x2d, 0x1c, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x76,
0x31, 0x2e, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x31, 0x2e, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49,
0x8a, 0xe7, 0xb0, 0x2a, 0x15, 0x6c, 0x61, 0x63, 0x6f, 0x6e, 0x69, 0x63, 0x2f, 0x4c, 0x6f, 0x63, 0x8a, 0xe7, 0xb0, 0x2a, 0x15, 0x6c, 0x61, 0x63, 0x6f, 0x6e, 0x69, 0x63, 0x2f, 0x4c, 0x6f, 0x63,
@ -626,11 +703,11 @@ func file_cerc_types_v1_lockup_proto_rawDescGZIP() []byte {
var file_cerc_types_v1_lockup_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_cerc_types_v1_lockup_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_cerc_types_v1_lockup_proto_goTypes = []interface{}{ var file_cerc_types_v1_lockup_proto_goTypes = []interface{}{
(*LockupAccount)(nil), // 0: cerc.types.v1.LockupAccount (*LockupAccount)(nil), // 0: cerc.types.v1.LockupAccount
(*types.ModuleAccount)(nil), // 1: cosmos.auth.v1beta1.ModuleAccount (*types.BaseAccount)(nil), // 1: cosmos.auth.v1beta1.BaseAccount
} }
var file_cerc_types_v1_lockup_proto_depIdxs = []int32{ var file_cerc_types_v1_lockup_proto_depIdxs = []int32{
1, // 0: cerc.types.v1.LockupAccount.module_account:type_name -> cosmos.auth.v1beta1.ModuleAccount 1, // 0: cerc.types.v1.LockupAccount.base_account:type_name -> cosmos.auth.v1beta1.BaseAccount
1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension type_name

View File

@ -33,6 +33,7 @@ modules:
- account: registry - account: registry
- account: record_rent - account: record_rent
- account: authority_rent - account: authority_rent
- account: lps_lockup
- name: bank - name: bank
config: config:
"@type": cosmos.bank.module.v1.Module "@type": cosmos.bank.module.v1.Module

View File

@ -22,11 +22,11 @@ const (
flagAppendMode = "append" flagAppendMode = "append"
) )
// AddGenesisLockupAccountCmd returns add-genesis-module-account cobra Command. // AddGenesisLockupAccountCmd returns add-genesis-lockup-account cobra Command.
func AddGenesisLockupAccountCmd() *cobra.Command { func AddGenesisLockupAccountCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "add-genesis-lockup-account <module_name> <coin>[,<coin>...]", Use: "add-genesis-lockup-account <account_name> <coin>[,<coin>...]",
Short: "Add genesis accounts for given participants to genesis.json", Short: "Add genesis lockup account with give name",
Args: cobra.ExactArgs(2), Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd) clientCtx := client.GetClientContextFromCmd(cmd)
@ -63,10 +63,10 @@ func AddGenesisAccount(
accAddr := moduleAccount.GetAddress() accAddr := moduleAccount.GetAddress()
balances := banktypes.Balance{Address: accAddr.String(), Coins: coins.Sort()} balances := banktypes.Balance{Address: accAddr.String(), Coins: coins.Sort()}
var genAccount authtypes.GenesisAccount genAccount := &types.LockupAccount{
genAccount = &types.LockupAccount{ BaseAccount: moduleAccount.BaseAccount,
ModuleAccount: moduleAccount, Name: moduleAccount.Name,
Distribution: "", Distribution: "",
} }
if err := genAccount.Validate(); err != nil { if err := genAccount.Validate(); err != nil {

View File

@ -30,7 +30,7 @@ import (
"git.vdb.to/cerc-io/laconicd/app" "git.vdb.to/cerc-io/laconicd/app"
"git.vdb.to/cerc-io/laconicd/app/params" "git.vdb.to/cerc-io/laconicd/app/params"
"git.vdb.to/cerc-io/laconicd/gql" "git.vdb.to/cerc-io/laconicd/gql"
"git.vdb.to/cerc-io/laconicd/x/types" types "git.vdb.to/cerc-io/laconicd/x/types/v1"
) )
const EnvPrefix = "LACONIC" const EnvPrefix = "LACONIC"
@ -149,7 +149,7 @@ func ProvideClientContext(
clientCtx.HomeDir = "" clientCtx.HomeDir = ""
clientCtx.KeyringDir = "" clientCtx.KeyringDir = ""
// Custom ZenithAccount type needs to be registered to be able to use it for adding azimuthId in auth accounts // Custom LockupAccount type needs to be registered
interfaceRegistry.RegisterImplementations((*types.LockupAccountI)(nil), &types.LockupAccount{}) interfaceRegistry.RegisterImplementations((*types.LockupAccountI)(nil), &types.LockupAccount{})
interfaceRegistry.RegisterImplementations((*authtypes.GenesisAccount)(nil), &types.LockupAccount{}) interfaceRegistry.RegisterImplementations((*authtypes.GenesisAccount)(nil), &types.LockupAccount{})

View File

@ -8,16 +8,19 @@ import "gogoproto/gogo.proto";
option go_package = "git.vdb.to/cerc-io/laconicd/x/types/v1"; option go_package = "git.vdb.to/cerc-io/laconicd/x/types/v1";
// LockupAccount extends the Cosmos SDK ModuleAccount with a distribution field. // LockupAccount extends the Cosmos SDK BaseAccount with a name and distribution
// field. It satisfies the ModuleAccountI interface to allow querying it as a
// module account.
message LockupAccount { message LockupAccount {
option (amino.name) = "laconic/LockupAccount"; option (amino.name) = "laconic/LockupAccount";
option (amino.message_encoding) = "lockup_account"; option (amino.message_encoding) = "lockup_account";
option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = false;
option (cosmos_proto.implements_interface) =
"cosmos.auth.v1beta1.ModuleAccountI";
option (cosmos_proto.implements_interface) = "cerc.types.v1.LockupAccountI"; option (cosmos_proto.implements_interface) = "cerc.types.v1.LockupAccountI";
cosmos.auth.v1beta1.ModuleAccount module_account = 1 cosmos.auth.v1beta1.BaseAccount base_account = 1 [ (gogoproto.embed) = true ];
[ (gogoproto.embed) = true ]; string name = 2;
string distribution = 2; string distribution = 3;
} }

View File

@ -12,7 +12,7 @@ var (
_ LockupAccountI = (*LockupAccount)(nil) _ LockupAccountI = (*LockupAccount)(nil)
) )
// LockupAccountI defines an account interface for accounts with lockup distribution // LockupAccountI defines an account interface for lockup account with token distribution
type LockupAccountI interface { type LockupAccountI interface {
sdk.ModuleAccountI sdk.ModuleAccountI
@ -21,14 +21,31 @@ type LockupAccountI interface {
// Validate checks for errors on the account fields // Validate checks for errors on the account fields
func (la LockupAccount) Validate() error { func (la LockupAccount) Validate() error {
if la.ModuleAccount == nil { if la.BaseAccount == nil {
return errors.New("uninitialized LockupAccount: ModuleAccount is nil") return errors.New("uninitialized LockupAccount: BaseAccount is nil")
} }
return la.ModuleAccount.Validate() return la.BaseAccount.Validate()
} }
// GetAzimuthId returns the Azimuth Id associated with the account // HasPermission returns whether or not the account has permission.
// Return false as the lockup account doesn't have any permissions
func (la LockupAccount) HasPermission(permission string) bool {
return false
}
// GetName returns the name of the holder's module
func (la LockupAccount) GetName() string {
return la.Name
}
// GetPermissions returns permissions granted to the module account
// Return empty as the lockup account doesn't have any permissions
func (la LockupAccount) GetPermissions() []string {
return []string{}
}
// GetDistribution returns the total token distribution
func (la LockupAccount) GetDistribution() string { func (la LockupAccount) GetDistribution() string {
return la.Distribution return la.Distribution
} }

View File

@ -26,10 +26,13 @@ var _ = math.Inf
// proto package needs to be updated. // proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// LockupAccount extends the Cosmos SDK ModuleAccount with a distribution field. // LockupAccount extends the Cosmos SDK BaseAccount with a name and distribution
// field. It satisfies the ModuleAccountI interface to allow querying it as a
// module account.
type LockupAccount struct { type LockupAccount struct {
*types.ModuleAccount `protobuf:"bytes,1,opt,name=module_account,json=moduleAccount,proto3,embedded=module_account" json:"module_account,omitempty"` *types.BaseAccount `protobuf:"bytes,1,opt,name=base_account,json=baseAccount,proto3,embedded=base_account" json:"base_account,omitempty"`
Distribution string `protobuf:"bytes,2,opt,name=distribution,proto3" json:"distribution,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Distribution string `protobuf:"bytes,3,opt,name=distribution,proto3" json:"distribution,omitempty"`
} }
func (m *LockupAccount) Reset() { *m = LockupAccount{} } func (m *LockupAccount) Reset() { *m = LockupAccount{} }
@ -72,27 +75,28 @@ func init() {
func init() { proto.RegisterFile("cerc/types/v1/lockup.proto", fileDescriptor_8fa58dc19f6348bf) } func init() { proto.RegisterFile("cerc/types/v1/lockup.proto", fileDescriptor_8fa58dc19f6348bf) }
var fileDescriptor_8fa58dc19f6348bf = []byte{ var fileDescriptor_8fa58dc19f6348bf = []byte{
// 312 bytes of a gzipped FileDescriptorProto // 335 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0x4e, 0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0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72,
0x8a, 0x7e, 0x05, 0x3c, 0x7e, 0x92, 0xd8, 0xc0, 0xc1, 0x64, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x0c, 0x51, 0x6a, 0xe9, 0x99, 0x25, 0x7a, 0x65, 0x29, 0x49, 0x7a, 0xa0, 0x60, 0x4f, 0x2d, 0x4a,
0x1f, 0x66, 0x3d, 0xd4, 0xb7, 0x01, 0x00, 0x00, 0xd6, 0xcd, 0xcc, 0xd7, 0x87, 0x1a, 0x9b, 0xa2, 0x5f, 0x01, 0x8f, 0xcf, 0x24, 0x36, 0x70, 0xb0,
0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x2e, 0x89, 0x9d, 0x6b, 0xe7, 0x01, 0x00, 0x00,
} }
func (m *LockupAccount) Marshal() (dAtA []byte, err error) { func (m *LockupAccount) Marshal() (dAtA []byte, err error) {
@ -120,11 +124,18 @@ func (m *LockupAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
copy(dAtA[i:], m.Distribution) copy(dAtA[i:], m.Distribution)
i = encodeVarintLockup(dAtA, i, uint64(len(m.Distribution))) i = encodeVarintLockup(dAtA, i, uint64(len(m.Distribution)))
i-- i--
dAtA[i] = 0x1a
}
if len(m.Name) > 0 {
i -= len(m.Name)
copy(dAtA[i:], m.Name)
i = encodeVarintLockup(dAtA, i, uint64(len(m.Name)))
i--
dAtA[i] = 0x12 dAtA[i] = 0x12
} }
if m.ModuleAccount != nil { if m.BaseAccount != nil {
{ {
size, err := m.ModuleAccount.MarshalToSizedBuffer(dAtA[:i]) size, err := m.BaseAccount.MarshalToSizedBuffer(dAtA[:i])
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -154,8 +165,12 @@ func (m *LockupAccount) Size() (n int) {
} }
var l int var l int
_ = l _ = l
if m.ModuleAccount != nil { if m.BaseAccount != nil {
l = m.ModuleAccount.Size() l = m.BaseAccount.Size()
n += 1 + l + sovLockup(uint64(l))
}
l = len(m.Name)
if l > 0 {
n += 1 + l + sovLockup(uint64(l)) n += 1 + l + sovLockup(uint64(l))
} }
l = len(m.Distribution) l = len(m.Distribution)
@ -202,7 +217,7 @@ func (m *LockupAccount) Unmarshal(dAtA []byte) error {
switch fieldNum { switch fieldNum {
case 1: case 1:
if wireType != 2 { if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ModuleAccount", wireType) return fmt.Errorf("proto: wrong wireType = %d for field BaseAccount", wireType)
} }
var msglen int var msglen int
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
@ -229,14 +244,46 @@ func (m *LockupAccount) Unmarshal(dAtA []byte) error {
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
if m.ModuleAccount == nil { if m.BaseAccount == nil {
m.ModuleAccount = &types.ModuleAccount{} m.BaseAccount = &types.BaseAccount{}
} }
if err := m.ModuleAccount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { if err := m.BaseAccount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err return err
} }
iNdEx = postIndex iNdEx = postIndex
case 2: case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowLockup
}
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 ErrInvalidLengthLockup
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthLockup
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Name = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 { if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Distribution", wireType) return fmt.Errorf("proto: wrong wireType = %d for field Distribution", wireType)
} }