Merge changes for mainnet #74
2
Makefile
2
Makefile
@ -43,7 +43,7 @@ build-linux:
|
||||
|
||||
$(BUILD_TARGETS): go.sum $(BUILDDIR)/
|
||||
@echo "--> installing laconicd"
|
||||
go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./...
|
||||
go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./cmd/laconicd
|
||||
|
||||
$(BUILDDIR)/:
|
||||
mkdir -p $(BUILDDIR)/
|
||||
|
@ -27,6 +27,8 @@ Run with a single node fixture:
|
||||
./scripts/init.sh clean
|
||||
```
|
||||
|
||||
See [lockup.md](./lockup.md) for lockup account usage.
|
||||
|
||||
## Tests
|
||||
|
||||
Run tests:
|
||||
|
755
api/cerc/types/v1/lockup.pulsar.go
Normal file
755
api/cerc/types/v1/lockup.pulsar.go
Normal file
@ -0,0 +1,755 @@
|
||||
// Code generated by protoc-gen-go-pulsar. DO NOT EDIT.
|
||||
package typesv1
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
runtime "github.com/cosmos/cosmos-proto/runtime"
|
||||
_ "github.com/cosmos/cosmos-sdk/types/tx/amino"
|
||||
types "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoiface "google.golang.org/protobuf/runtime/protoiface"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
io "io"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
var (
|
||||
md_LockupAccount protoreflect.MessageDescriptor
|
||||
fd_LockupAccount_base_account protoreflect.FieldDescriptor
|
||||
fd_LockupAccount_name protoreflect.FieldDescriptor
|
||||
fd_LockupAccount_distribution protoreflect.FieldDescriptor
|
||||
)
|
||||
|
||||
func init() {
|
||||
file_cerc_types_v1_lockup_proto_init()
|
||||
md_LockupAccount = File_cerc_types_v1_lockup_proto.Messages().ByName("LockupAccount")
|
||||
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")
|
||||
}
|
||||
|
||||
var _ protoreflect.Message = (*fastReflection_LockupAccount)(nil)
|
||||
|
||||
type fastReflection_LockupAccount LockupAccount
|
||||
|
||||
func (x *LockupAccount) ProtoReflect() protoreflect.Message {
|
||||
return (*fastReflection_LockupAccount)(x)
|
||||
}
|
||||
|
||||
func (x *LockupAccount) slowProtoReflect() protoreflect.Message {
|
||||
mi := &file_cerc_types_v1_lockup_proto_msgTypes[0]
|
||||
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_LockupAccount_messageType fastReflection_LockupAccount_messageType
|
||||
var _ protoreflect.MessageType = fastReflection_LockupAccount_messageType{}
|
||||
|
||||
type fastReflection_LockupAccount_messageType struct{}
|
||||
|
||||
func (x fastReflection_LockupAccount_messageType) Zero() protoreflect.Message {
|
||||
return (*fastReflection_LockupAccount)(nil)
|
||||
}
|
||||
func (x fastReflection_LockupAccount_messageType) New() protoreflect.Message {
|
||||
return new(fastReflection_LockupAccount)
|
||||
}
|
||||
func (x fastReflection_LockupAccount_messageType) Descriptor() protoreflect.MessageDescriptor {
|
||||
return md_LockupAccount
|
||||
}
|
||||
|
||||
// Descriptor returns message descriptor, which contains only the protobuf
|
||||
// type information for the message.
|
||||
func (x *fastReflection_LockupAccount) Descriptor() protoreflect.MessageDescriptor {
|
||||
return md_LockupAccount
|
||||
}
|
||||
|
||||
// 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_LockupAccount) Type() protoreflect.MessageType {
|
||||
return _fastReflection_LockupAccount_messageType
|
||||
}
|
||||
|
||||
// New returns a newly allocated and mutable empty message.
|
||||
func (x *fastReflection_LockupAccount) New() protoreflect.Message {
|
||||
return new(fastReflection_LockupAccount)
|
||||
}
|
||||
|
||||
// Interface unwraps the message reflection interface and
|
||||
// returns the underlying ProtoMessage interface.
|
||||
func (x *fastReflection_LockupAccount) Interface() protoreflect.ProtoMessage {
|
||||
return (*LockupAccount)(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_LockupAccount) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
||||
if x.BaseAccount != nil {
|
||||
value := protoreflect.ValueOfMessage(x.BaseAccount.ProtoReflect())
|
||||
if !f(fd_LockupAccount_base_account, value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if x.Name != "" {
|
||||
value := protoreflect.ValueOfString(x.Name)
|
||||
if !f(fd_LockupAccount_name, value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if x.Distribution != "" {
|
||||
value := protoreflect.ValueOfString(x.Distribution)
|
||||
if !f(fd_LockupAccount_distribution, 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_LockupAccount) Has(fd protoreflect.FieldDescriptor) bool {
|
||||
switch fd.FullName() {
|
||||
case "cerc.types.v1.LockupAccount.base_account":
|
||||
return x.BaseAccount != nil
|
||||
case "cerc.types.v1.LockupAccount.name":
|
||||
return x.Name != ""
|
||||
case "cerc.types.v1.LockupAccount.distribution":
|
||||
return x.Distribution != ""
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.types.v1.LockupAccount"))
|
||||
}
|
||||
panic(fmt.Errorf("message cerc.types.v1.LockupAccount 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_LockupAccount) Clear(fd protoreflect.FieldDescriptor) {
|
||||
switch fd.FullName() {
|
||||
case "cerc.types.v1.LockupAccount.base_account":
|
||||
x.BaseAccount = nil
|
||||
case "cerc.types.v1.LockupAccount.name":
|
||||
x.Name = ""
|
||||
case "cerc.types.v1.LockupAccount.distribution":
|
||||
x.Distribution = ""
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.types.v1.LockupAccount"))
|
||||
}
|
||||
panic(fmt.Errorf("message cerc.types.v1.LockupAccount 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_LockupAccount) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch descriptor.FullName() {
|
||||
case "cerc.types.v1.LockupAccount.base_account":
|
||||
value := x.BaseAccount
|
||||
return protoreflect.ValueOfMessage(value.ProtoReflect())
|
||||
case "cerc.types.v1.LockupAccount.name":
|
||||
value := x.Name
|
||||
return protoreflect.ValueOfString(value)
|
||||
case "cerc.types.v1.LockupAccount.distribution":
|
||||
value := x.Distribution
|
||||
return protoreflect.ValueOfString(value)
|
||||
default:
|
||||
if descriptor.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.types.v1.LockupAccount"))
|
||||
}
|
||||
panic(fmt.Errorf("message cerc.types.v1.LockupAccount 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_LockupAccount) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
||||
switch fd.FullName() {
|
||||
case "cerc.types.v1.LockupAccount.base_account":
|
||||
x.BaseAccount = value.Message().Interface().(*types.BaseAccount)
|
||||
case "cerc.types.v1.LockupAccount.name":
|
||||
x.Name = value.Interface().(string)
|
||||
case "cerc.types.v1.LockupAccount.distribution":
|
||||
x.Distribution = value.Interface().(string)
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.types.v1.LockupAccount"))
|
||||
}
|
||||
panic(fmt.Errorf("message cerc.types.v1.LockupAccount 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_LockupAccount) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch fd.FullName() {
|
||||
case "cerc.types.v1.LockupAccount.base_account":
|
||||
if x.BaseAccount == nil {
|
||||
x.BaseAccount = new(types.BaseAccount)
|
||||
}
|
||||
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":
|
||||
panic(fmt.Errorf("field distribution of message cerc.types.v1.LockupAccount is not mutable"))
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.types.v1.LockupAccount"))
|
||||
}
|
||||
panic(fmt.Errorf("message cerc.types.v1.LockupAccount 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_LockupAccount) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
switch fd.FullName() {
|
||||
case "cerc.types.v1.LockupAccount.base_account":
|
||||
m := new(types.BaseAccount)
|
||||
return protoreflect.ValueOfMessage(m.ProtoReflect())
|
||||
case "cerc.types.v1.LockupAccount.name":
|
||||
return protoreflect.ValueOfString("")
|
||||
case "cerc.types.v1.LockupAccount.distribution":
|
||||
return protoreflect.ValueOfString("")
|
||||
default:
|
||||
if fd.IsExtension() {
|
||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: cerc.types.v1.LockupAccount"))
|
||||
}
|
||||
panic(fmt.Errorf("message cerc.types.v1.LockupAccount 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_LockupAccount) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||
switch d.FullName() {
|
||||
default:
|
||||
panic(fmt.Errorf("%s is not a oneof field in cerc.types.v1.LockupAccount", 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_LockupAccount) 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_LockupAccount) 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_LockupAccount) 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_LockupAccount) ProtoMethods() *protoiface.Methods {
|
||||
size := func(input protoiface.SizeInput) protoiface.SizeOutput {
|
||||
x := input.Message.Interface().(*LockupAccount)
|
||||
if x == nil {
|
||||
return protoiface.SizeOutput{
|
||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
||||
Size: 0,
|
||||
}
|
||||
}
|
||||
options := runtime.SizeInputToOptions(input)
|
||||
_ = options
|
||||
var n int
|
||||
var l int
|
||||
_ = l
|
||||
if x.BaseAccount != nil {
|
||||
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))
|
||||
}
|
||||
l = len(x.Distribution)
|
||||
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().(*LockupAccount)
|
||||
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.Distribution) > 0 {
|
||||
i -= len(x.Distribution)
|
||||
copy(dAtA[i:], x.Distribution)
|
||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Distribution)))
|
||||
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
|
||||
}
|
||||
if x.BaseAccount != nil {
|
||||
encoded, err := options.Marshal(x.BaseAccount)
|
||||
if err != nil {
|
||||
return protoiface.MarshalOutput{
|
||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
||||
Buf: input.Buf,
|
||||
}, err
|
||||
}
|
||||
i -= len(encoded)
|
||||
copy(dAtA[i:], encoded)
|
||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded)))
|
||||
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().(*LockupAccount)
|
||||
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: LockupAccount: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: LockupAccount: 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 BaseAccount", wireType)
|
||||
}
|
||||
var msglen int
|
||||
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++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
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
|
||||
}
|
||||
if x.BaseAccount == nil {
|
||||
x.BaseAccount = &types.BaseAccount{}
|
||||
}
|
||||
if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.BaseAccount); err != nil {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
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 {
|
||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Distribution", 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.Distribution = 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,
|
||||
}
|
||||
}
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.0
|
||||
// protoc (unknown)
|
||||
// source: cerc/types/v1/lockup.proto
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// 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 {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
BaseAccount *types.BaseAccount `protobuf:"bytes,1,opt,name=base_account,json=baseAccount,proto3" json:"base_account,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() {
|
||||
*x = LockupAccount{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_cerc_types_v1_lockup_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *LockupAccount) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*LockupAccount) ProtoMessage() {}
|
||||
|
||||
// Deprecated: Use LockupAccount.ProtoReflect.Descriptor instead.
|
||||
func (*LockupAccount) Descriptor() ([]byte, []int) {
|
||||
return file_cerc_types_v1_lockup_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *LockupAccount) GetBaseAccount() *types.BaseAccount {
|
||||
if x != nil {
|
||||
return x.BaseAccount
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *LockupAccount) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *LockupAccount) GetDistribution() string {
|
||||
if x != nil {
|
||||
return x.Distribution
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_cerc_types_v1_lockup_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_cerc_types_v1_lockup_proto_rawDesc = []byte{
|
||||
0x0a, 0x1a, 0x63, 0x65, 0x72, 0x63, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f,
|
||||
0x6c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x63, 0x65,
|
||||
0x72, 0x63, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x11, 0x61, 0x6d, 0x69,
|
||||
0x6e, 0x6f, 0x2f, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19,
|
||||
0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73,
|
||||
0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f,
|
||||
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,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
|
||||
0x8b, 0x02, 0x0a, 0x0d, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x12, 0x49, 0x0a, 0x0c, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73,
|
||||
0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x42, 0x61,
|
||||
0x73, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x04, 0xd0, 0xde, 0x1f, 0x01, 0x52,
|
||||
0x0b, 0x62, 0x61, 0x73, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65,
|
||||
0x12, 0x22, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e,
|
||||
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,
|
||||
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,
|
||||
0x6b, 0x75, 0x70, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x92, 0xe7, 0xb0, 0x2a, 0x0e, 0x6c,
|
||||
0x6f, 0x63, 0x6b, 0x75, 0x70, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0xad, 0x01,
|
||||
0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x65, 0x72, 0x63, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73,
|
||||
0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4c, 0x6f, 0x63, 0x6b, 0x75, 0x70, 0x50, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x50, 0x01, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x2e, 0x76, 0x64, 0x62, 0x2e, 0x74, 0x6f, 0x2f, 0x63,
|
||||
0x65, 0x72, 0x63, 0x2d, 0x69, 0x6f, 0x2f, 0x6c, 0x61, 0x63, 0x6f, 0x6e, 0x69, 0x63, 0x64, 0x2f,
|
||||
0x61, 0x70, 0x69, 0x2f, 0x63, 0x65, 0x72, 0x63, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x76,
|
||||
0x31, 0x3b, 0x74, 0x79, 0x70, 0x65, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x54, 0x58, 0xaa,
|
||||
0x02, 0x0d, 0x43, 0x65, 0x72, 0x63, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x56, 0x31, 0xca,
|
||||
0x02, 0x0d, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x54, 0x79, 0x70, 0x65, 0x73, 0x5c, 0x56, 0x31, 0xe2,
|
||||
0x02, 0x19, 0x43, 0x65, 0x72, 0x63, 0x5c, 0x54, 0x79, 0x70, 0x65, 0x73, 0x5c, 0x56, 0x31, 0x5c,
|
||||
0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0f, 0x43, 0x65,
|
||||
0x72, 0x63, 0x3a, 0x3a, 0x54, 0x79, 0x70, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_cerc_types_v1_lockup_proto_rawDescOnce sync.Once
|
||||
file_cerc_types_v1_lockup_proto_rawDescData = file_cerc_types_v1_lockup_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_cerc_types_v1_lockup_proto_rawDescGZIP() []byte {
|
||||
file_cerc_types_v1_lockup_proto_rawDescOnce.Do(func() {
|
||||
file_cerc_types_v1_lockup_proto_rawDescData = protoimpl.X.CompressGZIP(file_cerc_types_v1_lockup_proto_rawDescData)
|
||||
})
|
||||
return file_cerc_types_v1_lockup_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_cerc_types_v1_lockup_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_cerc_types_v1_lockup_proto_goTypes = []interface{}{
|
||||
(*LockupAccount)(nil), // 0: cerc.types.v1.LockupAccount
|
||||
(*types.BaseAccount)(nil), // 1: cosmos.auth.v1beta1.BaseAccount
|
||||
}
|
||||
var file_cerc_types_v1_lockup_proto_depIdxs = []int32{
|
||||
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 input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_cerc_types_v1_lockup_proto_init() }
|
||||
func file_cerc_types_v1_lockup_proto_init() {
|
||||
if File_cerc_types_v1_lockup_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_cerc_types_v1_lockup_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*LockupAccount); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_cerc_types_v1_lockup_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_cerc_types_v1_lockup_proto_goTypes,
|
||||
DependencyIndexes: file_cerc_types_v1_lockup_proto_depIdxs,
|
||||
MessageInfos: file_cerc_types_v1_lockup_proto_msgTypes,
|
||||
}.Build()
|
||||
File_cerc_types_v1_lockup_proto = out.File
|
||||
file_cerc_types_v1_lockup_proto_rawDesc = nil
|
||||
file_cerc_types_v1_lockup_proto_goTypes = nil
|
||||
file_cerc_types_v1_lockup_proto_depIdxs = nil
|
||||
}
|
79
app/ante.go
Normal file
79
app/ante.go
Normal file
@ -0,0 +1,79 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"math"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdkmath "cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
|
||||
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||
)
|
||||
|
||||
// Reference: https://github.com/cosmos/cosmos-sdk/blob/v0.50.10/x/auth/ante/validator_tx_fee.go#L15
|
||||
|
||||
// checkTxFeeWithValidatorMinGasPrices implements the default fee logic, where the minimum price per
|
||||
// unit of gas is fixed and set by each validator, can the tx priority is computed from the gas price.
|
||||
func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) {
|
||||
feeTx, ok := tx.(sdk.FeeTx)
|
||||
if !ok {
|
||||
return nil, 0, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
|
||||
}
|
||||
|
||||
feeCoins := feeTx.GetFee()
|
||||
gas := feeTx.GetGas()
|
||||
|
||||
// Only allow alnt as a fee token
|
||||
for _, coin := range feeCoins {
|
||||
if coin.Denom != params.CoinUnit {
|
||||
return nil, 0, errorsmod.Wrapf(sdkerrors.ErrInvalidCoins, "invalid fee denom %s, only %s is accepted", coin.Denom, params.CoinUnit)
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that the provided fees meet a minimum threshold for the validator,
|
||||
// if this is a CheckTx. This is only for local mempool purposes, and thus
|
||||
// is only ran on check tx.
|
||||
if ctx.IsCheckTx() {
|
||||
minGasPrices := ctx.MinGasPrices()
|
||||
if !minGasPrices.IsZero() {
|
||||
requiredFees := make(sdk.Coins, len(minGasPrices))
|
||||
|
||||
// Determine the required fees by multiplying each required minimum gas
|
||||
// price by the gas limit, where fee = ceil(minGasPrice * gasLimit).
|
||||
glDec := sdkmath.LegacyNewDec(int64(gas))
|
||||
for i, gp := range minGasPrices {
|
||||
fee := gp.Amount.Mul(glDec)
|
||||
requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt())
|
||||
}
|
||||
|
||||
if !feeCoins.IsAnyGTE(requiredFees) {
|
||||
return nil, 0, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
priority := getTxPriority(feeCoins, int64(gas))
|
||||
return feeCoins, priority, nil
|
||||
}
|
||||
|
||||
// getTxPriority returns a naive tx priority based on the amount of the smallest denomination of the gas price
|
||||
// provided in a transaction.
|
||||
// NOTE: This implementation should be used with a great consideration as it opens potential attack vectors
|
||||
// where txs with multiple coins could not be prioritize as expected.
|
||||
func getTxPriority(fee sdk.Coins, gas int64) int64 {
|
||||
var priority int64
|
||||
for _, c := range fee {
|
||||
p := int64(math.MaxInt64)
|
||||
gasPrice := c.Amount.QuoRaw(gas)
|
||||
if gasPrice.IsInt64() {
|
||||
p = gasPrice.Int64()
|
||||
}
|
||||
if priority == 0 || p < priority {
|
||||
priority = p
|
||||
}
|
||||
}
|
||||
|
||||
return priority
|
||||
}
|
71
app/app.go
71
app/app.go
@ -12,11 +12,13 @@ import (
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
evidencekeeper "cosmossdk.io/x/evidence/keeper"
|
||||
|
||||
auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper"
|
||||
bondkeeper "git.vdb.to/cerc-io/laconicd/x/bond/keeper"
|
||||
onboardingkeeper "git.vdb.to/cerc-io/laconicd/x/onboarding/keeper"
|
||||
registrykeeper "git.vdb.to/cerc-io/laconicd/x/registry/keeper"
|
||||
types "git.vdb.to/cerc-io/laconicd/x/types/v1"
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
@ -26,8 +28,11 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/server/api"
|
||||
"github.com/cosmos/cosmos-sdk/server/config"
|
||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/ante"
|
||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
|
||||
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
|
||||
@ -43,6 +48,7 @@ import (
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
|
||||
_ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects
|
||||
_ "cosmossdk.io/x/evidence" // import for side-effects
|
||||
_ "git.vdb.to/cerc-io/laconicd/x/auction/module" // import for side-effects
|
||||
_ "git.vdb.to/cerc-io/laconicd/x/bond/module" // import for side-effects
|
||||
_ "git.vdb.to/cerc-io/laconicd/x/onboarding/module" // import for side-effects
|
||||
@ -88,6 +94,7 @@ type LaconicApp struct {
|
||||
GovKeeper *govkeeper.Keeper
|
||||
CrisisKeeper *crisiskeeper.Keeper
|
||||
ConsensusParamsKeeper consensuskeeper.Keeper
|
||||
EvidenceKeeper evidencekeeper.Keeper
|
||||
|
||||
// laconic keepers
|
||||
AuctionKeeper *auctionkeeper.Keeper // (Use * as per ProvideModule implementation)
|
||||
@ -161,6 +168,7 @@ func NewLaconicApp(
|
||||
&app.GovKeeper,
|
||||
&app.CrisisKeeper,
|
||||
&app.ConsensusParamsKeeper,
|
||||
&app.EvidenceKeeper,
|
||||
&app.AuctionKeeper,
|
||||
&app.BondKeeper,
|
||||
&app.RegistryKeeper,
|
||||
@ -169,6 +177,10 @@ func NewLaconicApp(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Register custom interfaces
|
||||
RegisterCustomInterfaces(app.interfaceRegistry)
|
||||
RegisterCustomLegacyAminoCodec(app.legacyAmino)
|
||||
|
||||
app.App = appBuilder.Build(db, traceStore, baseAppOptions...)
|
||||
|
||||
// register streaming services
|
||||
@ -185,6 +197,9 @@ func NewLaconicApp(
|
||||
app.sm = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, make(map[string]module.AppModuleSimulation, 0))
|
||||
app.sm.RegisterStoreDecoders()
|
||||
|
||||
// set custom ante handlers
|
||||
app.setCustomAnteHandler()
|
||||
|
||||
if err := app.Load(loadLatest); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -232,3 +247,59 @@ func (app *LaconicApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.AP
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func RegisterCustomInterfaces(interfaceRegistry codectypes.InterfaceRegistry) {
|
||||
// Custom LockupAccount type needs to be registered to be able to use it as a genesis account
|
||||
interfaceRegistry.RegisterImplementations((*authtypes.GenesisAccount)(nil), &types.LockupAccount{})
|
||||
|
||||
// LockupAccount extends auth Account
|
||||
interfaceRegistry.RegisterInterface(
|
||||
"cosmos.auth.v1beta1.AccountI",
|
||||
(*sdk.AccountI)(nil),
|
||||
&types.LockupAccount{},
|
||||
)
|
||||
|
||||
// LockupAccount extends auth ModuleAccount
|
||||
interfaceRegistry.RegisterInterface(
|
||||
"cosmos.auth.v1beta1.ModuleAccountI",
|
||||
(*sdk.ModuleAccountI)(nil),
|
||||
&types.LockupAccount{},
|
||||
)
|
||||
|
||||
interfaceRegistry.RegisterInterface(
|
||||
"cosmos.auth.v1beta1.GenesisAccount",
|
||||
(*authtypes.GenesisAccount)(nil),
|
||||
&types.LockupAccount{},
|
||||
)
|
||||
|
||||
interfaceRegistry.RegisterInterface(
|
||||
"cerc.types.v1.LockupAccountI",
|
||||
(*types.LockupAccountI)(nil),
|
||||
&types.LockupAccount{},
|
||||
)
|
||||
}
|
||||
|
||||
func RegisterCustomLegacyAminoCodec(registrar *codec.LegacyAmino) {
|
||||
registrar.RegisterInterface((*types.LockupAccountI)(nil), nil)
|
||||
registrar.RegisterConcrete(&types.LockupAccount{}, "laconic/LockupAccount", nil)
|
||||
}
|
||||
|
||||
// setCustomAnteHandler overwrites default ante handlers with custom ante handlers
|
||||
// Reference: https://github.com/cosmos/cosmos-sdk/blob/v0.50.10/x/auth/tx/config/config.go#L149
|
||||
func (app *LaconicApp) setCustomAnteHandler() {
|
||||
anteHandler, err := ante.NewAnteHandler(
|
||||
ante.HandlerOptions{
|
||||
AccountKeeper: app.AccountKeeper,
|
||||
BankKeeper: app.BankKeeper,
|
||||
SignModeHandler: app.txConfig.SignModeHandler(),
|
||||
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
|
||||
TxFeeChecker: checkTxFeeWithValidatorMinGasPrices,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Set the AnteHandler for the app
|
||||
app.SetAnteHandler(anteHandler)
|
||||
}
|
||||
|
@ -6,11 +6,11 @@ modules:
|
||||
# During begin block slashing happens after distr.BeginBlocker so that
|
||||
# there is nothing left over in the validator fee pool, so as to keep the CanWithdrawInvariant invariant.
|
||||
# NOTE: staking module is required if HistoricalEntries param > 0
|
||||
begin_blockers: [distribution, slashing, staking]
|
||||
begin_blockers: [distribution, slashing, evidence, staking]
|
||||
end_blockers: [crisis, gov, staking, auction, registry]
|
||||
# NOTE: The genutils module must occur after staking so that pools are properly initialized with tokens from genesis accounts.
|
||||
# NOTE: The genutils module must also occur after auth so that it can access the params from auth.
|
||||
init_genesis: [auth, bank, distribution, staking, slashing, gov, crisis, genutil, auction, bond, registry, onboarding]
|
||||
init_genesis: [auth, bank, distribution, staking, slashing, gov, crisis, genutil, evidence, auction, bond, registry, onboarding]
|
||||
override_store_keys:
|
||||
- module_name: auth
|
||||
kv_store_key: acc
|
||||
@ -33,6 +33,7 @@ modules:
|
||||
- account: registry
|
||||
- account: record_rent
|
||||
- account: authority_rent
|
||||
- account: lps_lockup
|
||||
- name: bank
|
||||
config:
|
||||
"@type": cosmos.bank.module.v1.Module
|
||||
@ -62,6 +63,9 @@ modules:
|
||||
- name: crisis
|
||||
config:
|
||||
"@type": cosmos.crisis.module.v1.Module
|
||||
- name: evidence
|
||||
config:
|
||||
"@type": cosmos.evidence.module.v1.Module
|
||||
- name: bond
|
||||
config:
|
||||
"@type": cerc.bond.module.v1.Module
|
||||
|
@ -10,11 +10,14 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
CoinUnit = "lnt"
|
||||
BaseCoinUnit = "alnt"
|
||||
LntExponent = 18
|
||||
// Registered token
|
||||
LpsCoinUnit = "lps"
|
||||
LpsBaseCoinUnit = "alps"
|
||||
LpsExponent = 18
|
||||
|
||||
DefaultBondDenom = BaseCoinUnit
|
||||
// Native token, only denominated in alnt
|
||||
// Used for staking, fees and laconic module ops
|
||||
CoinUnit = "alnt"
|
||||
|
||||
// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address.
|
||||
Bech32PrefixAccAddr = "laconic"
|
||||
@ -39,12 +42,11 @@ func init() {
|
||||
}
|
||||
|
||||
func RegisterDenoms() {
|
||||
err := sdk.RegisterDenom(CoinUnit, math.LegacyOneDec())
|
||||
err := sdk.RegisterDenom(LpsCoinUnit, math.LegacyOneDec())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = sdk.RegisterDenom(BaseCoinUnit, math.LegacyNewDecWithPrec(1, LntExponent))
|
||||
err = sdk.RegisterDenom(LpsBaseCoinUnit, math.LegacyNewDecWithPrec(1, LpsExponent))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
154
cmd/laconicd/cmd/add_genesis_lockup_account.go
Normal file
154
cmd/laconicd/cmd/add_genesis_lockup_account.go
Normal file
@ -0,0 +1,154 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
|
||||
types "git.vdb.to/cerc-io/laconicd/x/types/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
flagAppendMode = "append"
|
||||
)
|
||||
|
||||
// AddGenesisLockupAccountCmd returns add-genesis-lockup-account cobra Command.
|
||||
func AddGenesisLockupAccountCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "add-genesis-lockup-account <account_name> <distribution-json-file> <coin>[,<coin>...]",
|
||||
Short: "Add genesis lockup account with give name",
|
||||
Args: cobra.ExactArgs(3),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
serverCtx := server.GetServerContextFromCmd(cmd)
|
||||
config := serverCtx.Config
|
||||
|
||||
config.SetRoot(clientCtx.HomeDir)
|
||||
|
||||
moduleName := args[0]
|
||||
distributionFilePath := args[1]
|
||||
|
||||
var distribution map[string]interface{}
|
||||
distributionBytes, err := os.ReadFile(distributionFilePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read %s file: %w", distributionFilePath, err)
|
||||
}
|
||||
if err = json.Unmarshal(distributionBytes, &distribution); err != nil {
|
||||
return fmt.Errorf("distribution is invalid json: %v", err)
|
||||
}
|
||||
|
||||
appendflag, _ := cmd.Flags().GetBool(flagAppendMode)
|
||||
|
||||
return AddGenesisLockupAccount(clientCtx.Codec, moduleName, string(distributionBytes), appendflag, config.GenesisFile(), args[2])
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().Bool(flagAppendMode, false, "append the coins to an account already in the genesis.json file")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func AddGenesisLockupAccount(
|
||||
cdc codec.Codec,
|
||||
moduleName string,
|
||||
distribution string,
|
||||
appendAcct bool,
|
||||
genesisFileURL, amountStr string,
|
||||
) error {
|
||||
coins, err := sdk.ParseCoinsNormalized(amountStr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse coins: %w", err)
|
||||
}
|
||||
|
||||
// create concrete account type based on input parameters
|
||||
moduleAccount := authtypes.NewEmptyModuleAccount(moduleName)
|
||||
accAddr := moduleAccount.GetAddress()
|
||||
balances := banktypes.Balance{Address: accAddr.String(), Coins: coins.Sort()}
|
||||
|
||||
genAccount := &types.LockupAccount{
|
||||
BaseAccount: moduleAccount.BaseAccount,
|
||||
Name: moduleAccount.Name,
|
||||
Distribution: distribution,
|
||||
}
|
||||
|
||||
if err := genAccount.Validate(); err != nil {
|
||||
return fmt.Errorf("failed to validate new genesis account: %w", err)
|
||||
}
|
||||
|
||||
appState, appGenesis, err := genutiltypes.GenesisStateFromGenFile(genesisFileURL)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
|
||||
}
|
||||
|
||||
authGenState := authtypes.GetGenesisStateFromAppState(cdc, appState)
|
||||
|
||||
accs, err := authtypes.UnpackAccounts(authGenState.Accounts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get accounts from any: %w", err)
|
||||
}
|
||||
|
||||
bankGenState := banktypes.GetGenesisStateFromAppState(cdc, appState)
|
||||
if accs.Contains(accAddr) {
|
||||
if !appendAcct {
|
||||
return fmt.Errorf(" Account %s already exists\nUse `append` flag to append account at existing address", accAddr)
|
||||
}
|
||||
|
||||
genesisB := banktypes.GetGenesisStateFromAppState(cdc, appState)
|
||||
for idx, acc := range genesisB.Balances {
|
||||
if acc.Address != accAddr.String() {
|
||||
continue
|
||||
}
|
||||
|
||||
updatedCoins := acc.Coins.Add(coins...)
|
||||
bankGenState.Balances[idx] = banktypes.Balance{Address: accAddr.String(), Coins: updatedCoins.Sort()}
|
||||
break
|
||||
}
|
||||
} else {
|
||||
// Add the new account to the set of genesis accounts and sanitize the accounts afterwards.
|
||||
accs = append(accs, genAccount)
|
||||
accs = authtypes.SanitizeGenesisAccounts(accs)
|
||||
|
||||
genAccs, err := authtypes.PackAccounts(accs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to convert accounts into any's: %w", err)
|
||||
}
|
||||
authGenState.Accounts = genAccs
|
||||
|
||||
authGenStateBz, err := cdc.MarshalJSON(&authGenState)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal auth genesis state: %w", err)
|
||||
}
|
||||
appState[authtypes.ModuleName] = authGenStateBz
|
||||
|
||||
bankGenState.Balances = append(bankGenState.Balances, balances)
|
||||
}
|
||||
|
||||
bankGenState.Balances = banktypes.SanitizeGenesisBalances(bankGenState.Balances)
|
||||
|
||||
bankGenState.Supply = bankGenState.Supply.Add(balances.Coins...)
|
||||
|
||||
bankGenStateBz, err := cdc.MarshalJSON(bankGenState)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal bank genesis state: %w", err)
|
||||
}
|
||||
appState[banktypes.ModuleName] = bankGenStateBz
|
||||
|
||||
appStateJSON, err := json.Marshal(appState)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal application genesis state: %w", err)
|
||||
}
|
||||
|
||||
appGenesis.AppState = appStateJSON
|
||||
return genutil.ExportGenesisFile(appGenesis, genesisFileURL)
|
||||
}
|
@ -58,10 +58,14 @@ func initRootCmd(rootCmd *cobra.Command, txConfig client.TxConfig, basicManager
|
||||
startCmd.RunE = newStartCmd.RunE
|
||||
})
|
||||
|
||||
// Capture the genesis command from genutilcli and add new commands
|
||||
genesisCmd := genutilcli.Commands(txConfig, basicManager, app.DefaultNodeHome)
|
||||
genesisCmd.AddCommand(AddGenesisLockupAccountCmd())
|
||||
|
||||
// add keybase, auxiliary RPC, query, genesis, and tx child commands
|
||||
rootCmd.AddCommand(
|
||||
server.StatusCommand(),
|
||||
genutilcli.Commands(txConfig, basicManager, app.DefaultNodeHome),
|
||||
genesisCmd,
|
||||
queryCommand(),
|
||||
txCommand(),
|
||||
keys.Commands(),
|
||||
|
@ -21,15 +21,16 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
|
||||
"git.vdb.to/cerc-io/laconicd/app"
|
||||
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||
"git.vdb.to/cerc-io/laconicd/gql"
|
||||
types "git.vdb.to/cerc-io/laconicd/x/types/v1"
|
||||
)
|
||||
|
||||
const EnvPrefix = "LACONIC"
|
||||
@ -100,7 +101,7 @@ func NewRootCmd() *cobra.Command {
|
||||
|
||||
// overwrite the minimum gas price from the app configuration
|
||||
srvCfg := serverconfig.DefaultConfig()
|
||||
srvCfg.MinGasPrices = fmt.Sprintf("0%s", sdk.DefaultBondDenom)
|
||||
srvCfg.MinGasPrices = fmt.Sprintf("0%s", params.CoinUnit)
|
||||
|
||||
// overwrite the block timeout
|
||||
cmtCfg := cmtcfg.DefaultConfig()
|
||||
@ -135,7 +136,7 @@ func ProvideClientContext(
|
||||
WithTxConfig(txConfig).
|
||||
WithLegacyAmino(legacyAmino).
|
||||
WithInput(os.Stdin).
|
||||
WithAccountRetriever(types.AccountRetriever{}).
|
||||
WithAccountRetriever(authtypes.AccountRetriever{}).
|
||||
WithHomeDir(app.DefaultNodeHome).
|
||||
WithViper(EnvPrefix) // env variable prefix
|
||||
|
||||
@ -148,6 +149,10 @@ func ProvideClientContext(
|
||||
clientCtx.HomeDir = ""
|
||||
clientCtx.KeyringDir = ""
|
||||
|
||||
// Custom LockupAccount type needs to be registered
|
||||
interfaceRegistry.RegisterImplementations((*types.LockupAccountI)(nil), &types.LockupAccount{})
|
||||
interfaceRegistry.RegisterImplementations((*authtypes.GenesisAccount)(nil), &types.LockupAccount{})
|
||||
|
||||
return clientCtx
|
||||
}
|
||||
|
||||
|
1
go.mod
1
go.mod
@ -23,6 +23,7 @@ require (
|
||||
cosmossdk.io/math v1.3.0
|
||||
cosmossdk.io/store v1.1.1
|
||||
cosmossdk.io/tools/confix v0.1.0
|
||||
cosmossdk.io/x/evidence v0.1.1
|
||||
github.com/99designs/gqlgen v0.17.22
|
||||
github.com/cometbft/cometbft v0.38.12
|
||||
github.com/cosmos/cosmos-db v1.0.2
|
||||
|
2
go.sum
2
go.sum
@ -20,6 +20,8 @@ cosmossdk.io/store v1.1.1 h1:NA3PioJtWDVU7cHHeyvdva5J/ggyLDkyH0hGHl2804Y=
|
||||
cosmossdk.io/store v1.1.1/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
|
||||
cosmossdk.io/tools/confix v0.1.0 h1:2OOZTtQsDT5e7P3FM5xqM0bPfluAxZlAwxqaDmYBE+E=
|
||||
cosmossdk.io/tools/confix v0.1.0/go.mod h1:TdXKVYs4gEayav5wM+JHT+kTU2J7fozFNqoVaN+8CdY=
|
||||
cosmossdk.io/x/evidence v0.1.1 h1:Ks+BLTa3uftFpElLTDp9L76t2b58htjVbSZ86aoK/E4=
|
||||
cosmossdk.io/x/evidence v0.1.1/go.mod h1:OoDsWlbtuyqS70LY51aX8FBTvguQqvFrt78qL7UzeNc=
|
||||
cosmossdk.io/x/tx v0.13.5 h1:FdnU+MdmFWn1pTsbfU0OCf2u6mJ8cqc1H4OMG418MLw=
|
||||
cosmossdk.io/x/tx v0.13.5/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
|
47
lockup.md
Normal file
47
lockup.md
Normal file
@ -0,0 +1,47 @@
|
||||
# Lockup Account Usage
|
||||
|
||||
* Add a genesis lockup account:
|
||||
|
||||
```bash
|
||||
laconicd genesis add-genesis-lockup-account <account_name> <distribution-json-file> <coin>[,<coin>...]
|
||||
|
||||
# Example
|
||||
# laconicd genesis add-genesis-lockup-account lps_lockup distribution.json 1000alps
|
||||
```
|
||||
|
||||
* This adds a `LockupAccount` with given name and balance in the genesis file
|
||||
|
||||
* The lockup account can be queried as shown below once the chain starts
|
||||
|
||||
* Query a lockup account:
|
||||
|
||||
```bash
|
||||
laconicd query auth module-account <account_name>
|
||||
|
||||
# Example
|
||||
# laconicd query auth module-account lps_lockup
|
||||
# account:
|
||||
# type: laconic/LockupAccount
|
||||
# value:
|
||||
# base_account:
|
||||
# account_number: "1"
|
||||
# address: laconic1mprsxp9jqe0d0lp88fxuccthwgy7tqgt5x9y65
|
||||
# distribution: |-
|
||||
# {
|
||||
# ...
|
||||
```
|
||||
|
||||
* Query a lockup account's balance:
|
||||
|
||||
```bash
|
||||
laconicd query bank balances <address>
|
||||
|
||||
# Example
|
||||
lockup_account_address=$(laconicd query auth module-account lps_lockup -o json | jq -r '.account.value.base_account.address')
|
||||
laconicd query bank balances $lockup_account_address
|
||||
balances:
|
||||
- amount: "1000"
|
||||
denom: alps
|
||||
pagination:
|
||||
total: "1"
|
||||
```
|
26
proto/cerc/types/v1/lockup.proto
Normal file
26
proto/cerc/types/v1/lockup.proto
Normal file
@ -0,0 +1,26 @@
|
||||
syntax = "proto3";
|
||||
package cerc.types.v1;
|
||||
|
||||
import "amino/amino.proto";
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "cosmos/auth/v1beta1/auth.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
|
||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/types/v1";
|
||||
|
||||
// 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 {
|
||||
option (amino.name) = "laconic/LockupAccount";
|
||||
option (amino.message_encoding) = "lockup_account";
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
option (cosmos_proto.implements_interface) =
|
||||
"cosmos.auth.v1beta1.ModuleAccountI";
|
||||
option (cosmos_proto.implements_interface) = "cerc.types.v1.LockupAccountI";
|
||||
|
||||
cosmos.auth.v1beta1.BaseAccount base_account = 1 [ (gogoproto.embed) = true ];
|
||||
string name = 2;
|
||||
string distribution = 3;
|
||||
}
|
@ -1,11 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
KEY="alice"
|
||||
CHAINID=${CHAINID:-"laconic_9000-1"}
|
||||
MONIKER=${MONIKER:-"localtestnet"}
|
||||
KEYRING=${KEYRING:-"test"}
|
||||
DENOM=${DENOM:-"alnt"}
|
||||
STAKING_AMOUNT=${STAKING_AMOUNT:-"1000000000000000"}
|
||||
BALANCE=${BALANCE:-"1000000000000000000000000000000"} # 10^32 alnt
|
||||
STAKING_AMOUNT=${STAKING_AMOUNT:-"1000000000000000"} # 10^15 alnt
|
||||
MIN_GAS_PRICE=${MIN_GAS_PRICE:-"0.001"}
|
||||
LOGLEVEL=${LOGLEVEL:-"info"}
|
||||
|
||||
@ -126,11 +129,9 @@ if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data" ]; then
|
||||
fi
|
||||
|
||||
# Allocate genesis accounts (cosmos formatted addresses)
|
||||
# 10^30 alnt | 10^12 lnt
|
||||
laconicd genesis add-genesis-account $KEY 1000000000000000000000000000000$DENOM --keyring-backend $KEYRING
|
||||
laconicd genesis add-genesis-account $KEY ${BALANCE}${DENOM} --keyring-backend $KEYRING
|
||||
|
||||
# Sign genesis transaction
|
||||
# 10^15 alnt
|
||||
laconicd genesis gentx $KEY $STAKING_AMOUNT$DENOM --keyring-backend $KEYRING --chain-id $CHAINID
|
||||
|
||||
# Collect genesis tx
|
||||
|
@ -1,11 +1,13 @@
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
pruningtypes "cosmossdk.io/store/pruning/types"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
||||
@ -16,12 +18,14 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
|
||||
laconicApp "git.vdb.to/cerc-io/laconicd/app"
|
||||
auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module"
|
||||
bondmodule "git.vdb.to/cerc-io/laconicd/x/bond/module"
|
||||
registrymodule "git.vdb.to/cerc-io/laconicd/x/registry/module"
|
||||
|
||||
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||
_ "git.vdb.to/cerc-io/laconicd/app/params" // import for side-effects (see init)
|
||||
"git.vdb.to/cerc-io/laconicd/testutil/network"
|
||||
)
|
||||
@ -54,16 +58,40 @@ func NewTestNetworkFixture() network.TestFixture {
|
||||
return app
|
||||
}
|
||||
|
||||
encodingConfig := testutil.MakeTestEncodingConfig(
|
||||
auth.AppModuleBasic{},
|
||||
bank.AppModuleBasic{},
|
||||
staking.AppModuleBasic{},
|
||||
auctionmodule.AppModule{},
|
||||
bondmodule.AppModule{},
|
||||
registrymodule.AppModule{},
|
||||
)
|
||||
|
||||
genesisState := app.DefaultGenesis()
|
||||
genesisState, err = updateStakingGenesisBondDenom(genesisState, encodingConfig.Codec)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to update genesis state: %v", err))
|
||||
}
|
||||
|
||||
return network.TestFixture{
|
||||
AppConstructor: appCtr,
|
||||
GenesisState: app.DefaultGenesis(),
|
||||
EncodingConfig: testutil.MakeTestEncodingConfig(
|
||||
auth.AppModuleBasic{},
|
||||
bank.AppModuleBasic{},
|
||||
staking.AppModuleBasic{},
|
||||
auctionmodule.AppModule{},
|
||||
bondmodule.AppModule{},
|
||||
registrymodule.AppModule{},
|
||||
),
|
||||
GenesisState: genesisState,
|
||||
EncodingConfig: encodingConfig,
|
||||
}
|
||||
}
|
||||
|
||||
func updateStakingGenesisBondDenom(genesisState map[string]json.RawMessage, codec codec.Codec) (map[string]json.RawMessage, error) {
|
||||
var stakingGenesis stakingtypes.GenesisState
|
||||
if err := codec.UnmarshalJSON(genesisState[stakingtypes.ModuleName], &stakingGenesis); err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
stakingGenesis.Params.BondDenom = params.CoinUnit
|
||||
|
||||
stakingGenesisBz, err := codec.MarshalJSON(&stakingGenesis)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
genesisState[stakingtypes.ModuleName] = stakingGenesisBz
|
||||
|
||||
return genesisState, nil
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||
integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration"
|
||||
types "git.vdb.to/cerc-io/laconicd/x/auction"
|
||||
)
|
||||
@ -337,9 +338,9 @@ func (kts *KeeperTestSuite) createAuctionAndCommitBid(commitBid bool) (*types.Au
|
||||
Signer: accounts[0].String(),
|
||||
CommitsDuration: 5 * time.Minute,
|
||||
RevealsDuration: 5 * time.Minute,
|
||||
CommitFee: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000)),
|
||||
RevealFee: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000)),
|
||||
MinimumBid: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000000)),
|
||||
CommitFee: sdk.NewCoin(params.CoinUnit, sdkmath.NewInt(1000)),
|
||||
RevealFee: sdk.NewCoin(params.CoinUnit, sdkmath.NewInt(1000)),
|
||||
MinimumBid: sdk.NewCoin(params.CoinUnit, sdkmath.NewInt(1000000)),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||
integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration"
|
||||
types "git.vdb.to/cerc-io/laconicd/x/bond"
|
||||
)
|
||||
@ -185,7 +186,7 @@ func (kts *KeeperTestSuite) TestGrpcGetModuleBalance() {
|
||||
if !test.errResponse {
|
||||
kts.Require().Nil(err)
|
||||
kts.Require().NotNil(resp.GetBalance())
|
||||
kts.Require().Equal(resp.GetBalance(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))))
|
||||
kts.Require().Equal(resp.GetBalance(), sdk.NewCoins(sdk.NewCoin(params.CoinUnit, math.NewInt(10))))
|
||||
} else {
|
||||
kts.Require().NotNil(err)
|
||||
kts.Require().Error(err)
|
||||
@ -201,7 +202,7 @@ func (kts *KeeperTestSuite) createBond() (*types.Bond, error) {
|
||||
// Create funded account(s)
|
||||
accounts := simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, accCount, math.NewInt(1000))
|
||||
|
||||
bond, err := k.CreateBond(ctx, accounts[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10))))
|
||||
bond, err := k.CreateBond(ctx, accounts[0], sdk.NewCoins(sdk.NewCoin(params.CoinUnit, math.NewInt(10))))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
|
||||
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||
auctionTypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
||||
auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper"
|
||||
auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module"
|
||||
@ -82,8 +83,8 @@ func (tf *TestFixture) Setup() error {
|
||||
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
||||
authtypes.ProtoBaseAccount,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
addresscodec.NewBech32Codec(params.Bech32PrefixAccAddr),
|
||||
params.Bech32PrefixAccAddr,
|
||||
authority.String(),
|
||||
)
|
||||
|
||||
@ -161,5 +162,5 @@ func (tf *TestFixture) Setup() error {
|
||||
type BondDenomProvider struct{}
|
||||
|
||||
func (bdp BondDenomProvider) BondDenom(ctx context.Context) (string, error) {
|
||||
return sdk.DefaultBondDenom, nil
|
||||
return params.CoinUnit, nil
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||
integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration"
|
||||
bondTypes "git.vdb.to/cerc-io/laconicd/x/bond"
|
||||
types "git.vdb.to/cerc-io/laconicd/x/registry"
|
||||
@ -51,7 +52,7 @@ func (kts *KeeperTestSuite) createBond() (*bondTypes.Bond, error) {
|
||||
// Create a funded account
|
||||
kts.accounts = simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, 1, math.NewInt(1000000000000))
|
||||
|
||||
bond, err := kts.BondKeeper.CreateBond(ctx, kts.accounts[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(1000000000))))
|
||||
bond, err := kts.BondKeeper.CreateBond(ctx, kts.accounts[0], sdk.NewCoins(sdk.NewCoin(params.CoinUnit, math.NewInt(1000000000))))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ import (
|
||||
_ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank
|
||||
_ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
|
||||
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||
)
|
||||
|
||||
// package-wide network lock to only allow one test network at a time
|
||||
@ -148,8 +150,8 @@ func DefaultConfig(factory TestFixtureFactory) Config {
|
||||
TimeoutCommit: 2 * time.Second,
|
||||
ChainID: "chain-" + unsafe.Str(6),
|
||||
NumValidators: 4,
|
||||
BondDenom: sdk.DefaultBondDenom,
|
||||
MinGasPrices: fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom),
|
||||
BondDenom: params.CoinUnit,
|
||||
MinGasPrices: fmt.Sprintf("0.000006%s", params.CoinUnit),
|
||||
AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction),
|
||||
StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction),
|
||||
BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction),
|
||||
|
@ -5,11 +5,12 @@ import (
|
||||
fmt "fmt"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// DefaultMaxBondAmountTokens are the default parameter values.
|
||||
var DefaultMaxBondAmountTokens = sdkmath.NewInt(1000000000000) // 10^12 alnt
|
||||
var DefaultMaxBondAmountTokens = sdkmath.NewInt(1000000000000) // 10^12
|
||||
|
||||
func NewParams(maxBondAmount sdk.Coin) Params {
|
||||
return Params{MaxBondAmount: maxBondAmount}
|
||||
@ -17,7 +18,7 @@ func NewParams(maxBondAmount sdk.Coin) Params {
|
||||
|
||||
// DefaultParams returns default module parameters
|
||||
func DefaultParams() Params {
|
||||
return NewParams(sdk.NewCoin(sdk.DefaultBondDenom, DefaultMaxBondAmountTokens))
|
||||
return NewParams(sdk.NewCoin(params.CoinUnit, DefaultMaxBondAmountTokens))
|
||||
}
|
||||
|
||||
// Validate checks that the parameters have valid values
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
|
||||
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||
auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction"
|
||||
registrytypes "git.vdb.to/cerc-io/laconicd/x/registry"
|
||||
"git.vdb.to/cerc-io/laconicd/x/registry/helpers"
|
||||
@ -295,7 +296,7 @@ func (k Keeper) createAuthority(ctx sdk.Context, name string, owner string, isRo
|
||||
moduleParams.AuthorityAuctionCommitFee,
|
||||
moduleParams.AuthorityAuctionRevealFee,
|
||||
moduleParams.AuthorityAuctionMinimumBid,
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(0)),
|
||||
sdk.NewCoin(params.CoinUnit, math.NewInt(0)),
|
||||
0,
|
||||
ownerAddress,
|
||||
)
|
||||
|
@ -6,26 +6,28 @@ import (
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"git.vdb.to/cerc-io/laconicd/app/params"
|
||||
)
|
||||
|
||||
// Default parameter values.
|
||||
var (
|
||||
// DefaultRecordRent is the default record rent for 1 time period (see expiry time).
|
||||
DefaultRecordRent = sdkmath.NewInt(1000000) // 10^6 alnt
|
||||
DefaultRecordRent = sdkmath.NewInt(1000000) // 10^6
|
||||
|
||||
// DefaultRecordExpiryTime is the default record expiry time (1 year).
|
||||
DefaultRecordExpiryTime = time.Hour * 24 * 365
|
||||
|
||||
DefaultAuthorityRent = sdkmath.NewInt(1000000) // 10^6 alnt
|
||||
DefaultAuthorityRent = sdkmath.NewInt(1000000) // 10^6
|
||||
DefaultAuthorityExpiryTime = time.Hour * 24 * 365
|
||||
DefaultAuthorityGracePeriod = time.Hour * 24 * 2
|
||||
|
||||
DefaultAuthorityAuctionEnabled = false
|
||||
DefaultCommitsDuration = time.Hour * 24
|
||||
DefaultRevealsDuration = time.Hour * 24
|
||||
DefaultCommitFee = sdkmath.NewInt(1000000) // 10^6 alnt
|
||||
DefaultRevealFee = sdkmath.NewInt(1000000) // 10^6 alnt
|
||||
DefaultMinimumBid = sdkmath.NewInt(5000000) // 5 * 10^6 alnt
|
||||
DefaultCommitFee = sdkmath.NewInt(1000000) // 10^6
|
||||
DefaultRevealFee = sdkmath.NewInt(1000000) // 10^6
|
||||
DefaultMinimumBid = sdkmath.NewInt(5000000) // 5 * 10^6
|
||||
)
|
||||
|
||||
// NewParams creates a new Params instance
|
||||
@ -60,13 +62,13 @@ func NewParams(
|
||||
// DefaultParams returns a default set of parameters.
|
||||
func DefaultParams() Params {
|
||||
return NewParams(
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultRecordRent), DefaultRecordExpiryTime,
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultAuthorityRent),
|
||||
sdk.NewCoin(params.CoinUnit, DefaultRecordRent), DefaultRecordExpiryTime,
|
||||
sdk.NewCoin(params.CoinUnit, DefaultAuthorityRent),
|
||||
DefaultAuthorityExpiryTime, DefaultAuthorityGracePeriod, DefaultAuthorityAuctionEnabled, DefaultCommitsDuration,
|
||||
DefaultRevealsDuration,
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultCommitFee),
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultRevealFee),
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, DefaultMinimumBid),
|
||||
sdk.NewCoin(params.CoinUnit, DefaultCommitFee),
|
||||
sdk.NewCoin(params.CoinUnit, DefaultRevealFee),
|
||||
sdk.NewCoin(params.CoinUnit, DefaultMinimumBid),
|
||||
)
|
||||
}
|
||||
|
||||
|
51
x/types/v1/lockup.go
Normal file
51
x/types/v1/lockup.go
Normal file
@ -0,0 +1,51 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
)
|
||||
|
||||
var (
|
||||
_ authtypes.GenesisAccount = (*LockupAccount)(nil)
|
||||
_ LockupAccountI = (*LockupAccount)(nil)
|
||||
)
|
||||
|
||||
// LockupAccountI defines an account interface for lockup account with token distribution
|
||||
type LockupAccountI interface {
|
||||
sdk.ModuleAccountI
|
||||
|
||||
GetDistribution() string
|
||||
}
|
||||
|
||||
// Validate checks for errors on the account fields
|
||||
func (la LockupAccount) Validate() error {
|
||||
if la.BaseAccount == nil {
|
||||
return errors.New("uninitialized LockupAccount: BaseAccount is nil")
|
||||
}
|
||||
|
||||
return la.BaseAccount.Validate()
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return la.Distribution
|
||||
}
|
422
x/types/v1/lockup.pb.go
Normal file
422
x/types/v1/lockup.pb.go
Normal file
@ -0,0 +1,422 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: cerc/types/v1/lockup.proto
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
_ "github.com/cosmos/cosmos-sdk/types/tx/amino"
|
||||
types "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// 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 {
|
||||
*types.BaseAccount `protobuf:"bytes,1,opt,name=base_account,json=baseAccount,proto3,embedded=base_account" json:"base_account,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) String() string { return proto.CompactTextString(m) }
|
||||
func (*LockupAccount) ProtoMessage() {}
|
||||
func (*LockupAccount) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_8fa58dc19f6348bf, []int{0}
|
||||
}
|
||||
func (m *LockupAccount) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *LockupAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_LockupAccount.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 *LockupAccount) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_LockupAccount.Merge(m, src)
|
||||
}
|
||||
func (m *LockupAccount) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *LockupAccount) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_LockupAccount.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_LockupAccount proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*LockupAccount)(nil), "cerc.types.v1.LockupAccount")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("cerc/types/v1/lockup.proto", fileDescriptor_8fa58dc19f6348bf) }
|
||||
|
||||
var fileDescriptor_8fa58dc19f6348bf = []byte{
|
||||
// 335 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0x4e, 0x2d, 0x4a,
|
||||
0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, 0xcf, 0xc9, 0x4f, 0xce, 0x2e, 0x2d,
|
||||
0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0xc9, 0xe9, 0x81, 0xe5, 0xf4, 0xca, 0x0c,
|
||||
0xa5, 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x85, 0x94, 0x64, 0x72, 0x7e,
|
||||
0x71, 0x6e, 0x7e, 0x71, 0x3c, 0x98, 0xa7, 0x0f, 0xe1, 0x40, 0xa5, 0xe4, 0x20, 0x3c, 0xfd, 0xc4,
|
||||
0xd2, 0x92, 0x0c, 0xfd, 0x32, 0xc3, 0xa4, 0xd4, 0x92, 0x44, 0x43, 0x30, 0x07, 0x2a, 0x2f, 0x92,
|
||||
0x9e, 0x9f, 0x9e, 0x0f, 0xd1, 0x07, 0x62, 0x41, 0x44, 0x95, 0xba, 0x99, 0xb8, 0x78, 0x7d, 0xc0,
|
||||
0x6e, 0x70, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x11, 0xf2, 0xe4, 0xe2, 0x49, 0x4a, 0x2c, 0x4e,
|
||||
0x8d, 0x4f, 0x84, 0xf0, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x14, 0xf4, 0xa0, 0x96, 0x81,
|
||||
0x4d, 0x84, 0x1a, 0xaf, 0xe7, 0x94, 0x58, 0x9c, 0x0a, 0xd5, 0xe7, 0xc4, 0x72, 0xe1, 0x9e, 0x3c,
|
||||
0x63, 0x10, 0x77, 0x12, 0x42, 0x48, 0x48, 0x88, 0x8b, 0x25, 0x2f, 0x31, 0x37, 0x55, 0x82, 0x49,
|
||||
0x81, 0x51, 0x83, 0x33, 0x08, 0xcc, 0x16, 0x52, 0xe2, 0xe2, 0x49, 0xc9, 0x2c, 0x2e, 0x29, 0xca,
|
||||
0x4c, 0x2a, 0x2d, 0xc9, 0xcc, 0xcf, 0x93, 0x60, 0x06, 0xcb, 0xa1, 0x88, 0x59, 0x95, 0x77, 0x2c,
|
||||
0x90, 0x67, 0x38, 0xb5, 0x45, 0x57, 0x09, 0x9b, 0x9d, 0xbe, 0xf9, 0x29, 0xa5, 0x39, 0x30, 0x2b,
|
||||
0x3c, 0x4f, 0x6d, 0xd1, 0x95, 0x41, 0x09, 0x35, 0x3d, 0x14, 0xdf, 0x78, 0x76, 0x3d, 0xdf, 0xa0,
|
||||
0x25, 0x9a, 0x93, 0x98, 0x9c, 0x9f, 0x97, 0x99, 0xac, 0x8f, 0x22, 0x35, 0xe9, 0xf9, 0x06, 0x2d,
|
||||
0x3e, 0x48, 0xf0, 0xc3, 0xfc, 0xea, 0xe4, 0x70, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c,
|
||||
0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72,
|
||||
0x0c, 0x51, 0x6a, 0xe9, 0x99, 0x25, 0x7a, 0x65, 0x29, 0x49, 0x7a, 0xa0, 0x60, 0x4f, 0x2d, 0x4a,
|
||||
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) {
|
||||
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 *LockupAccount) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *LockupAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Distribution) > 0 {
|
||||
i -= len(m.Distribution)
|
||||
copy(dAtA[i:], m.Distribution)
|
||||
i = encodeVarintLockup(dAtA, i, uint64(len(m.Distribution)))
|
||||
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
|
||||
}
|
||||
if m.BaseAccount != nil {
|
||||
{
|
||||
size, err := m.BaseAccount.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintLockup(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintLockup(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovLockup(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *LockupAccount) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.BaseAccount != nil {
|
||||
l = m.BaseAccount.Size()
|
||||
n += 1 + l + sovLockup(uint64(l))
|
||||
}
|
||||
l = len(m.Name)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovLockup(uint64(l))
|
||||
}
|
||||
l = len(m.Distribution)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovLockup(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovLockup(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozLockup(x uint64) (n int) {
|
||||
return sovLockup(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *LockupAccount) 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 ErrIntOverflowLockup
|
||||
}
|
||||
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: LockupAccount: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: LockupAccount: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field BaseAccount", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowLockup
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthLockup
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthLockup
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.BaseAccount == nil {
|
||||
m.BaseAccount = &types.BaseAccount{}
|
||||
}
|
||||
if err := m.BaseAccount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
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 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Distribution", 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.Distribution = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipLockup(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthLockup
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipLockup(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowLockup
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowLockup
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowLockup
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthLockup
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupLockup
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthLockup
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthLockup = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowLockup = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupLockup = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
Loading…
Reference in New Issue
Block a user