From 476da132051d5d3bdecab929f1e77e910b8b4a8a Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Wed, 29 May 2024 15:38:07 -0400 Subject: [PATCH] fix!(manifest): only poa is allowed to burn tokens --- api/manifest/v1/genesis.pulsar.go | 7 +- api/manifest/v1/tx.pulsar.go | 153 ++++++++++++++------------- interchaintest/helpers/manifest.go | 7 ++ interchaintest/mainfest_test.go | 55 ++++++++++ interchaintest/poa_group_test.go | 2 +- proto/manifest/v1/genesis.proto | 9 +- proto/manifest/v1/tx.proto | 31 +++--- x/manifest/client/cli/tx.go | 2 +- x/manifest/keeper/msg_server.go | 13 ++- x/manifest/keeper/msg_server_test.go | 40 ++++--- x/manifest/types/genesis.pb.go | 7 +- x/manifest/types/msgs.go | 6 +- x/manifest/types/tx.pb.go | 105 +++++++++--------- 13 files changed, 264 insertions(+), 173 deletions(-) diff --git a/api/manifest/v1/genesis.pulsar.go b/api/manifest/v1/genesis.pulsar.go index 86fcdf5..cdc5414 100644 --- a/api/manifest/v1/genesis.pulsar.go +++ b/api/manifest/v1/genesis.pulsar.go @@ -2106,7 +2106,8 @@ func (x *Params) GetInflation() *Inflation { return nil } -// StakeHolders is the list of addresses and their percentage of the inflation distribution +// StakeHolders is the list of addresses and their percentage of the inflation +// distribution type StakeHolders struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2114,8 +2115,8 @@ type StakeHolders struct { // manifest address Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - // percentage is the micro denom % of tokens this address gets on a distribution. - // 100% = 100_000_000 total. so 1_000000 = 1%. + // percentage is the micro denom % of tokens this address gets on a + // distribution. 100% = 100_000_000 total. so 1_000000 = 1%. Percentage int32 `protobuf:"varint,2,opt,name=percentage,proto3" json:"percentage,omitempty"` } diff --git a/api/manifest/v1/tx.pulsar.go b/api/manifest/v1/tx.pulsar.go index 9399448..325af92 100644 --- a/api/manifest/v1/tx.pulsar.go +++ b/api/manifest/v1/tx.pulsar.go @@ -1780,14 +1780,14 @@ func (x *_MsgBurnHeldBalance_2_list) IsValid() bool { var ( md_MsgBurnHeldBalance protoreflect.MessageDescriptor - fd_MsgBurnHeldBalance_sender protoreflect.FieldDescriptor + fd_MsgBurnHeldBalance_authority protoreflect.FieldDescriptor fd_MsgBurnHeldBalance_burn_coins protoreflect.FieldDescriptor ) func init() { file_manifest_v1_tx_proto_init() md_MsgBurnHeldBalance = File_manifest_v1_tx_proto.Messages().ByName("MsgBurnHeldBalance") - fd_MsgBurnHeldBalance_sender = md_MsgBurnHeldBalance.Fields().ByName("sender") + fd_MsgBurnHeldBalance_authority = md_MsgBurnHeldBalance.Fields().ByName("authority") fd_MsgBurnHeldBalance_burn_coins = md_MsgBurnHeldBalance.Fields().ByName("burn_coins") } @@ -1856,9 +1856,9 @@ func (x *fastReflection_MsgBurnHeldBalance) Interface() protoreflect.ProtoMessag // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_MsgBurnHeldBalance) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.Sender != "" { - value := protoreflect.ValueOfString(x.Sender) - if !f(fd_MsgBurnHeldBalance_sender, value) { + if x.Authority != "" { + value := protoreflect.ValueOfString(x.Authority) + if !f(fd_MsgBurnHeldBalance_authority, value) { return } } @@ -1883,8 +1883,8 @@ func (x *fastReflection_MsgBurnHeldBalance) Range(f func(protoreflect.FieldDescr // a repeated field is populated if it is non-empty. func (x *fastReflection_MsgBurnHeldBalance) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "manifest.v1.MsgBurnHeldBalance.sender": - return x.Sender != "" + case "manifest.v1.MsgBurnHeldBalance.authority": + return x.Authority != "" case "manifest.v1.MsgBurnHeldBalance.burn_coins": return len(x.BurnCoins) != 0 default: @@ -1903,8 +1903,8 @@ func (x *fastReflection_MsgBurnHeldBalance) Has(fd protoreflect.FieldDescriptor) // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgBurnHeldBalance) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "manifest.v1.MsgBurnHeldBalance.sender": - x.Sender = "" + case "manifest.v1.MsgBurnHeldBalance.authority": + x.Authority = "" case "manifest.v1.MsgBurnHeldBalance.burn_coins": x.BurnCoins = nil default: @@ -1923,8 +1923,8 @@ func (x *fastReflection_MsgBurnHeldBalance) Clear(fd protoreflect.FieldDescripto // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_MsgBurnHeldBalance) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "manifest.v1.MsgBurnHeldBalance.sender": - value := x.Sender + case "manifest.v1.MsgBurnHeldBalance.authority": + value := x.Authority return protoreflect.ValueOfString(value) case "manifest.v1.MsgBurnHeldBalance.burn_coins": if len(x.BurnCoins) == 0 { @@ -1952,8 +1952,8 @@ func (x *fastReflection_MsgBurnHeldBalance) Get(descriptor protoreflect.FieldDes // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgBurnHeldBalance) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "manifest.v1.MsgBurnHeldBalance.sender": - x.Sender = value.Interface().(string) + case "manifest.v1.MsgBurnHeldBalance.authority": + x.Authority = value.Interface().(string) case "manifest.v1.MsgBurnHeldBalance.burn_coins": lv := value.List() clv := lv.(*_MsgBurnHeldBalance_2_list) @@ -1984,8 +1984,8 @@ func (x *fastReflection_MsgBurnHeldBalance) Mutable(fd protoreflect.FieldDescrip } value := &_MsgBurnHeldBalance_2_list{list: &x.BurnCoins} return protoreflect.ValueOfList(value) - case "manifest.v1.MsgBurnHeldBalance.sender": - panic(fmt.Errorf("field sender of message manifest.v1.MsgBurnHeldBalance is not mutable")) + case "manifest.v1.MsgBurnHeldBalance.authority": + panic(fmt.Errorf("field authority of message manifest.v1.MsgBurnHeldBalance is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: manifest.v1.MsgBurnHeldBalance")) @@ -1999,7 +1999,7 @@ func (x *fastReflection_MsgBurnHeldBalance) Mutable(fd protoreflect.FieldDescrip // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_MsgBurnHeldBalance) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "manifest.v1.MsgBurnHeldBalance.sender": + case "manifest.v1.MsgBurnHeldBalance.authority": return protoreflect.ValueOfString("") case "manifest.v1.MsgBurnHeldBalance.burn_coins": list := []*types.Coin{} @@ -2073,7 +2073,7 @@ func (x *fastReflection_MsgBurnHeldBalance) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - l = len(x.Sender) + l = len(x.Authority) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } @@ -2128,10 +2128,10 @@ func (x *fastReflection_MsgBurnHeldBalance) ProtoMethods() *protoiface.Methods { dAtA[i] = 0x12 } } - if len(x.Sender) > 0 { - i -= len(x.Sender) - copy(dAtA[i:], x.Sender) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Sender))) + if len(x.Authority) > 0 { + i -= len(x.Authority) + copy(dAtA[i:], x.Authority) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Authority))) i-- dAtA[i] = 0xa } @@ -2186,7 +2186,7 @@ func (x *fastReflection_MsgBurnHeldBalance) ProtoMethods() *protoiface.Methods { switch fieldNum { case 1: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2214,7 +2214,7 @@ func (x *fastReflection_MsgBurnHeldBalance) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Sender = string(dAtA[iNdEx:postIndex]) + x.Authority = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -2780,7 +2780,8 @@ func (x *MsgPayoutStakeholders) GetPayout() *types.Coin { return nil } -// MsgPayoutStakeholdersResponse defines the response structure for executing a MsgPayoutStakeholders message. +// MsgPayoutStakeholdersResponse defines the response structure for executing a +// MsgPayoutStakeholders message. type MsgPayoutStakeholdersResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2813,9 +2814,9 @@ type MsgBurnHeldBalance struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // authority is the address of the controlling account. - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // payout is the amount of tokens paid to the current stakeholders. + // sender is the address of the tokenholder. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // burn_coins are the coins to be burned by the tokenholder. BurnCoins []*types.Coin `protobuf:"bytes,2,rep,name=burn_coins,json=burnCoins,proto3" json:"burn_coins,omitempty"` } @@ -2839,9 +2840,9 @@ func (*MsgBurnHeldBalance) Descriptor() ([]byte, []int) { return file_manifest_v1_tx_proto_rawDescGZIP(), []int{4} } -func (x *MsgBurnHeldBalance) GetSender() string { +func (x *MsgBurnHeldBalance) GetAuthority() string { if x != nil { - return x.Sender + return x.Authority } return "" } @@ -2853,7 +2854,8 @@ func (x *MsgBurnHeldBalance) GetBurnCoins() []*types.Coin { return nil } -// MsgBurnHeldBalanceResponse defines the response structure for executing a MsgBurnHeldBalance message. +// MsgBurnHeldBalanceResponse defines the response structure for executing a +// MsgBurnHeldBalance message. type MsgBurnHeldBalanceResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2921,52 +2923,53 @@ var file_manifest_v1_tx_proto_rawDesc = []byte{ 0x79, 0x6f, 0x75, 0x74, 0x3a, 0x12, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x22, 0x1f, 0x0a, 0x1d, 0x4d, 0x73, 0x67, 0x50, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x68, 0x6f, 0x6c, 0x64, 0x65, 0x72, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xda, 0x01, 0x0a, 0x12, 0x4d, 0x73, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xe3, 0x01, 0x0a, 0x12, 0x4d, 0x73, 0x67, 0x42, 0x75, 0x72, 0x6e, 0x48, 0x65, 0x6c, 0x64, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, - 0x12, 0x30, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, - 0x65, 0x72, 0x12, 0x80, 0x01, 0x0a, 0x0a, 0x62, 0x75, 0x72, 0x6e, 0x5f, 0x63, 0x6f, 0x69, 0x6e, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, - 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, - 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, - 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x09, 0x62, 0x75, 0x72, 0x6e, - 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x3a, 0x0f, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x06, - 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x1c, 0x0a, 0x1a, 0x4d, 0x73, 0x67, 0x42, 0x75, 0x72, - 0x6e, 0x48, 0x65, 0x6c, 0x64, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xa3, 0x02, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x52, 0x0a, 0x0c, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1c, 0x2e, 0x6d, - 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x24, 0x2e, 0x6d, 0x61, 0x6e, - 0x69, 0x66, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x64, 0x0a, 0x12, 0x50, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x68, - 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x73, 0x12, 0x22, 0x2e, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, - 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x50, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x53, 0x74, - 0x61, 0x6b, 0x65, 0x68, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x73, 0x1a, 0x2a, 0x2e, 0x6d, 0x61, 0x6e, - 0x69, 0x66, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x50, 0x61, 0x79, 0x6f, - 0x75, 0x74, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x68, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5b, 0x0a, 0x0f, 0x42, 0x75, 0x72, 0x6e, 0x48, 0x65, - 0x6c, 0x64, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1f, 0x2e, 0x6d, 0x61, 0x6e, 0x69, - 0x66, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x42, 0x75, 0x72, 0x6e, 0x48, - 0x65, 0x6c, 0x64, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x1a, 0x27, 0x2e, 0x6d, 0x61, 0x6e, - 0x69, 0x66, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x42, 0x75, 0x72, 0x6e, - 0x48, 0x65, 0x6c, 0x64, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0xa9, 0x01, 0x0a, 0x0f, 0x63, - 0x6f, 0x6d, 0x2e, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x42, 0x07, - 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x66, 0x74, 0x65, 0x64, 0x69, 0x6e, 0x69, 0x74, - 0x2f, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2d, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x72, - 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2f, 0x76, 0x31, - 0x3b, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x4d, 0x58, - 0x58, 0xaa, 0x02, 0x0b, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2e, 0x56, 0x31, 0xca, - 0x02, 0x0b, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x17, - 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0c, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, - 0x73, 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x36, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x61, + 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x80, 0x01, 0x0a, 0x0a, 0x62, 0x75, 0x72, + 0x6e, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, + 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, + 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, + 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, + 0x52, 0x09, 0x62, 0x75, 0x72, 0x6e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x3a, 0x12, 0xe8, 0xa0, 0x1f, + 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x22, + 0x1c, 0x0a, 0x1a, 0x4d, 0x73, 0x67, 0x42, 0x75, 0x72, 0x6e, 0x48, 0x65, 0x6c, 0x64, 0x42, 0x61, + 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xa3, 0x02, + 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x52, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1c, 0x2e, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, + 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x1a, 0x24, 0x2e, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2e, 0x76, + 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x64, 0x0a, 0x12, 0x50, 0x61, 0x79, + 0x6f, 0x75, 0x74, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x68, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x73, 0x12, + 0x22, 0x2e, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, + 0x67, 0x50, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x68, 0x6f, 0x6c, 0x64, + 0x65, 0x72, 0x73, 0x1a, 0x2a, 0x2e, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2e, 0x76, + 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x50, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x53, 0x74, 0x61, 0x6b, 0x65, + 0x68, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x5b, 0x0a, 0x0f, 0x42, 0x75, 0x72, 0x6e, 0x48, 0x65, 0x6c, 0x64, 0x42, 0x61, 0x6c, 0x61, 0x6e, + 0x63, 0x65, 0x12, 0x1f, 0x2e, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, + 0x2e, 0x4d, 0x73, 0x67, 0x42, 0x75, 0x72, 0x6e, 0x48, 0x65, 0x6c, 0x64, 0x42, 0x61, 0x6c, 0x61, + 0x6e, 0x63, 0x65, 0x1a, 0x27, 0x2e, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2e, 0x76, + 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x42, 0x75, 0x72, 0x6e, 0x48, 0x65, 0x6c, 0x64, 0x42, 0x61, 0x6c, + 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, + 0xb0, 0x2a, 0x01, 0x42, 0xa9, 0x01, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x61, 0x6e, 0x69, + 0x66, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, + 0x69, 0x66, 0x74, 0x65, 0x64, 0x69, 0x6e, 0x69, 0x74, 0x2f, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, + 0x73, 0x74, 0x2d, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x61, + 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, + 0x73, 0x74, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x4d, 0x58, 0x58, 0xaa, 0x02, 0x0b, 0x4d, 0x61, 0x6e, + 0x69, 0x66, 0x65, 0x73, 0x74, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0b, 0x4d, 0x61, 0x6e, 0x69, 0x66, + 0x65, 0x73, 0x74, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x17, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, + 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x0c, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/interchaintest/helpers/manifest.go b/interchaintest/helpers/manifest.go index a7aec5c..e24b184 100644 --- a/interchaintest/helpers/manifest.go +++ b/interchaintest/helpers/manifest.go @@ -31,3 +31,10 @@ func ManifestQueryParams(ctx context.Context, node *cosmos.ChainNode) (*manifest res, err := manifesttypes.NewQueryClient(node.GrpcConn).Params(ctx, &manifesttypes.QueryParamsRequest{}) return res.GetParams(), err } + +func ManifestBurnTokens(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, keyName string, amount string, flags ...string) (sdk.TxResponse, error) { + txCmd := []string{"tx", "manifest", "burn-coins", amount} + fmt.Println("ManifestBurnTokens", txCmd) + cmd := TxCommandBuilder(ctx, chain, txCmd, keyName, flags...) + return ExecuteTransaction(ctx, chain, cmd) +} diff --git a/interchaintest/mainfest_test.go b/interchaintest/mainfest_test.go index 5eaae91..5cd3f0f 100644 --- a/interchaintest/mainfest_test.go +++ b/interchaintest/mainfest_test.go @@ -232,6 +232,61 @@ func TestManifestModule(t *testing.T) { require.ErrorContains(t, err, "invalid decimal coin expression") }) + t.Run("fail: invalid burn authority", func(t *testing.T) { + accBal, err := appChain.GetBalance(ctx, uaddr, Denom) + require.NoError(t, err) + o, err := helpers.ManifestBurnTokens(t, ctx, appChain, uaddr, "1"+Denom) + require.NoError(t, err) // The tx is successful but the burn fails + tx, err := appChain.GetTransaction(o.TxHash) + require.NoError(t, err) + require.NotEqual(t, tx.Code, uint32(0x0)) // The burn failed + require.Contains(t, tx.RawLog, "invalid authority") + accBal2, err := appChain.GetBalance(ctx, uaddr, Denom) + require.NoError(t, err) + require.EqualValues(t, accBal, accBal2) + }) + + t.Run("success: burn tokens as poa admin", func(t *testing.T) { + poaAdminAddr := poaAdmin.FormattedAddress() + accBal, err := appChain.GetBalance(ctx, poaAdminAddr, Denom) + require.NoError(t, err) + o, err := helpers.ManifestBurnTokens(t, ctx, appChain, poaAdminAddr, "1"+Denom) + require.NoError(t, err) + tx, err := appChain.GetTransaction(o.TxHash) + require.NoError(t, err) + require.Equal(t, tx.Code, uint32(0x0)) + accBal2, err := appChain.GetBalance(ctx, poaAdminAddr, Denom) + require.NoError(t, err) + require.EqualValues(t, accBal2, accBal.Sub(sdkmath.OneInt())) + }) + + t.Run("fail: burn unknown denom as poa admin", func(t *testing.T) { + poaAdminAddr := poaAdmin.FormattedAddress() + accBal, err := appChain.GetBalance(ctx, poaAdminAddr, Denom) + require.NoError(t, err) + o, err := helpers.ManifestBurnTokens(t, ctx, appChain, poaAdminAddr, "1foobar") + require.NoError(t, err) // The tx is successful but the burn fails + tx, err := appChain.GetTransaction(o.TxHash) + require.NoError(t, err) + require.NotEqual(t, tx.Code, uint32(0x0)) // The burn failed + require.Contains(t, tx.RawLog, "insufficient funds ") + accBal2, err := appChain.GetBalance(ctx, poaAdminAddr, Denom) + require.NoError(t, err) + require.EqualValues(t, accBal, accBal2) + }) + + t.Run("fail: burn invalid coin expression as poa admin", func(t *testing.T) { + poaAdminAddr := poaAdmin.FormattedAddress() + accBal, err := appChain.GetBalance(ctx, poaAdminAddr, Denom) + require.NoError(t, err) + _, err = helpers.ManifestBurnTokens(t, ctx, appChain, poaAdminAddr, "foobar") + require.Error(t, err) + require.Contains(t, err.Error(), "invalid decimal coin expression") + accBal2, err := appChain.GetBalance(ctx, poaAdminAddr, Denom) + require.NoError(t, err) + require.EqualValues(t, accBal, accBal2) + }) + t.Cleanup(func() { CopyCoverageFromContainer(ctx, t, client, appChain.GetNode().ContainerID(), appChain.HomeDir()) _ = ic.Close() diff --git a/interchaintest/poa_group_test.go b/interchaintest/poa_group_test.go index 056184e..5a21367 100644 --- a/interchaintest/poa_group_test.go +++ b/interchaintest/poa_group_test.go @@ -565,7 +565,7 @@ func createManifestPayoutProposal(authority string, payout sdk.Coin) manifesttyp func createManifestBurnProposal(sender string, amounts sdk.Coins) manifesttypes.MsgBurnHeldBalance { return manifesttypes.MsgBurnHeldBalance{ - Sender: sender, + Authority: sender, BurnCoins: amounts, } } diff --git a/proto/manifest/v1/genesis.proto b/proto/manifest/v1/genesis.proto index be1fdc0..d91517c 100644 --- a/proto/manifest/v1/genesis.proto +++ b/proto/manifest/v1/genesis.proto @@ -9,7 +9,7 @@ option go_package = "github.com/liftedinit/manifest-ledger/x/manifest/types"; // GenesisState defines the module genesis state message GenesisState { // Params defines all the paramaters of the module. - Params params = 1 [(gogoproto.nullable) = false]; + Params params = 1 [ (gogoproto.nullable) = false ]; } // Params defines the set of module parameters. @@ -23,15 +23,16 @@ message Params { Inflation inflation = 2; } -// StakeHolders is the list of addresses and their percentage of the inflation distribution +// StakeHolders is the list of addresses and their percentage of the inflation +// distribution message StakeHolders { option (gogoproto.equal) = true; // manifest address string address = 1; - // percentage is the micro denom % of tokens this address gets on a distribution. - // 100% = 100_000_000 total. so 1_000000 = 1%. + // percentage is the micro denom % of tokens this address gets on a + // distribution. 100% = 100_000_000 total. so 1_000000 = 1%. int32 percentage = 2; } diff --git a/proto/manifest/v1/tx.proto b/proto/manifest/v1/tx.proto index db9a3b9..4fabe1a 100644 --- a/proto/manifest/v1/tx.proto +++ b/proto/manifest/v1/tx.proto @@ -20,7 +20,8 @@ service Msg { rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); // PayoutStakeholders allows the authority to manually pay out stakeholders. - rpc PayoutStakeholders(MsgPayoutStakeholders) returns (MsgPayoutStakeholdersResponse); + rpc PayoutStakeholders(MsgPayoutStakeholders) + returns (MsgPayoutStakeholdersResponse); // BurnHeldBalance allows a tokenholder to burn coins they own. rpc BurnHeldBalance(MsgBurnHeldBalance) returns (MsgBurnHeldBalanceResponse); @@ -33,12 +34,12 @@ message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; // authority is the address of the controlling account. - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // params defines the parameters to update. // // NOTE: All parameters must be supplied. - Params params = 2 [(gogoproto.nullable) = false]; + Params params = 2 [ (gogoproto.nullable) = false ]; } // MsgUpdateParamsResponse defines the response structure for executing a @@ -53,36 +54,38 @@ message MsgPayoutStakeholders { option (gogoproto.equal) = false; // authority is the address of the controlling account. - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // payout is the amount of tokens paid to the current stakeholders. cosmos.base.v1beta1.Coin payout = 2 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true, - (amino.encoding) = "legacy_coins", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", (gogoproto.castrepeated) = "cosmossdk.io/api/cosmos/base/v1beta1.Coins" ]; } -// MsgPayoutStakeholdersResponse defines the response structure for executing a MsgPayoutStakeholders message. +// MsgPayoutStakeholdersResponse defines the response structure for executing a +// MsgPayoutStakeholders message. message MsgPayoutStakeholdersResponse {} // MsgPayoutStakeholders is the Msg/BurnHeldBalance request type. message MsgBurnHeldBalance { - option (cosmos.msg.v1.signer) = "sender"; + option (cosmos.msg.v1.signer) = "authority"; option (gogoproto.equal) = false; // sender is the address of the tokenholder. - string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // burn_coins are the coins to be burned by the tokenholder. repeated cosmos.base.v1beta1.Coin burn_coins = 2 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true, - (amino.encoding) = "legacy_coins", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; } -// MsgBurnHeldBalanceResponse defines the response structure for executing a MsgBurnHeldBalance message. +// MsgBurnHeldBalanceResponse defines the response structure for executing a +// MsgBurnHeldBalance message. message MsgBurnHeldBalanceResponse {} diff --git a/x/manifest/client/cli/tx.go b/x/manifest/client/cli/tx.go index e4baa5b..e0be91b 100644 --- a/x/manifest/client/cli/tx.go +++ b/x/manifest/client/cli/tx.go @@ -139,7 +139,7 @@ func MsgBurnCoins() *cobra.Command { } msg := &types.MsgBurnHeldBalance{ - Sender: sender.String(), + Authority: sender.String(), BurnCoins: coins, } diff --git a/x/manifest/keeper/msg_server.go b/x/manifest/keeper/msg_server.go index 9a8bff6..3ef21c6 100644 --- a/x/manifest/keeper/msg_server.go +++ b/x/manifest/keeper/msg_server.go @@ -51,15 +51,18 @@ func (ms msgServer) PayoutStakeholders(ctx context.Context, req *types.MsgPayout } // BurnHeldBalance implements types.MsgServer. -func (ms msgServer) BurnHeldBalance(ctx context.Context, msg *types.MsgBurnHeldBalance) (*types.MsgBurnHeldBalanceResponse, error) { - addr, err := sdk.AccAddressFromBech32(msg.Sender) +func (ms msgServer) BurnHeldBalance(ctx context.Context, req *types.MsgBurnHeldBalance) (*types.MsgBurnHeldBalanceResponse, error) { + if ms.k.authority != req.Authority { + return nil, fmt.Errorf("invalid authority; expected %s, got %s", ms.k.authority, req.Authority) + } + addr, err := sdk.AccAddressFromBech32(req.Authority) if err != nil { return nil, err } - if err := ms.k.bankKeeper.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, msg.BurnCoins); err != nil { - return nil, fmt.Errorf("not enough balance to burn %s: %w", msg.BurnCoins, err) + if err := ms.k.bankKeeper.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, req.BurnCoins); err != nil { + return nil, fmt.Errorf("not enough balance to burn %s: %w", req.BurnCoins, err) } - return &types.MsgBurnHeldBalanceResponse{}, ms.k.bankKeeper.BurnCoins(ctx, types.ModuleName, msg.BurnCoins) + return &types.MsgBurnHeldBalanceResponse{}, ms.k.bankKeeper.BurnCoins(ctx, types.ModuleName, req.BurnCoins) } diff --git a/x/manifest/keeper/msg_server_test.go b/x/manifest/keeper/msg_server_test.go index 927156d..daae24a 100644 --- a/x/manifest/keeper/msg_server_test.go +++ b/x/manifest/keeper/msg_server_test.go @@ -244,13 +244,14 @@ func TestBurnCoins(t *testing.T) { k := f.App.ManifestKeeper k.SetAuthority(authority.String()) ms := keeper.NewMsgServerImpl(k) + _, _, acc := testdata.KeyTestPubAddr() type tc struct { name string initial sdk.Coins burn sdk.Coins expected sdk.Coins - address string + address sdk.AccAddress success bool } @@ -263,19 +264,21 @@ func TestBurnCoins(t *testing.T) { initial: sdk.NewCoins(), burn: sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(7))), expected: sdk.NewCoins(), + address: authority, }, { name: "fail; bad address", initial: sdk.NewCoins(), burn: sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(7))), expected: sdk.NewCoins(), - address: "xyz", + address: sdk.AccAddress{0x0}, }, { - name: "success; burn 1 token successfully", + name: "success; burn tokens successfully", initial: sdk.NewCoins(stake, mfx), burn: sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(7))), expected: sdk.NewCoins(mfx, stake.SubAmount(sdkmath.NewInt(7))), + address: authority, success: true, }, { @@ -283,30 +286,33 @@ func TestBurnCoins(t *testing.T) { initial: sdk.NewCoins(stake, mfx), burn: sdk.NewCoins(sdk.NewCoin("umfx", sdkmath.NewInt(9)), sdk.NewCoin("stake", sdkmath.NewInt(7))), expected: sdk.NewCoins(mfx.SubAmount(sdkmath.NewInt(9)), stake.SubAmount(sdkmath.NewInt(7))), + address: authority, success: true, }, + { + name: "fail; invalid authority", + initial: sdk.NewCoins(stake, mfx), + burn: sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(7))), + expected: sdk.NewCoins(stake, mfx), + address: acc, + }, } for _, c := range cases { c := c t.Run(c.name, func(t *testing.T) { - _, _, acc := testdata.KeyTestPubAddr() - if c.address == "" { - c.address = acc.String() - } - // setup initial balances for the new account if len(c.initial) > 0 { require.NoError(t, f.App.BankKeeper.MintCoins(f.Ctx, "mint", c.initial)) - require.NoError(t, f.App.BankKeeper.SendCoinsFromModuleToAccount(f.Ctx, "mint", acc, c.initial)) + require.NoError(t, f.App.BankKeeper.SendCoinsFromModuleToAccount(f.Ctx, "mint", c.address, c.initial)) } // validate initial balance - require.Equal(t, c.initial, f.App.BankKeeper.GetAllBalances(f.Ctx, acc)) + require.Equal(t, c.initial, f.App.BankKeeper.GetAllBalances(f.Ctx, c.address)) // burn coins _, err := ms.BurnHeldBalance(f.Ctx, &types.MsgBurnHeldBalance{ - Sender: c.address, + Authority: c.address.String(), BurnCoins: c.burn, }) if c.success { @@ -315,7 +321,17 @@ func TestBurnCoins(t *testing.T) { require.Error(t, err) } - require.Equal(t, c.expected, f.App.BankKeeper.GetAllBalances(f.Ctx, acc)) + allBalance := f.App.BankKeeper.GetAllBalances(f.Ctx, c.address) + require.Equal(t, c.expected, allBalance) + + // burn the rest of the coins to reset the balance to 0 for the next test if the test was successful + if c.success { + _, err = ms.BurnHeldBalance(f.Ctx, &types.MsgBurnHeldBalance{ + Authority: c.address.String(), + BurnCoins: allBalance, + }) + require.NoError(t, err) + } }) } } diff --git a/x/manifest/types/genesis.pb.go b/x/manifest/types/genesis.pb.go index 149c7c3..369f588 100644 --- a/x/manifest/types/genesis.pb.go +++ b/x/manifest/types/genesis.pb.go @@ -122,12 +122,13 @@ func (m *Params) GetInflation() *Inflation { return nil } -// StakeHolders is the list of addresses and their percentage of the inflation distribution +// StakeHolders is the list of addresses and their percentage of the inflation +// distribution type StakeHolders struct { // manifest address Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - // percentage is the micro denom % of tokens this address gets on a distribution. - // 100% = 100_000_000 total. so 1_000000 = 1%. + // percentage is the micro denom % of tokens this address gets on a + // distribution. 100% = 100_000_000 total. so 1_000000 = 1%. Percentage int32 `protobuf:"varint,2,opt,name=percentage,proto3" json:"percentage,omitempty"` } diff --git a/x/manifest/types/msgs.go b/x/manifest/types/msgs.go index 91062a2..65015b8 100644 --- a/x/manifest/types/msgs.go +++ b/x/manifest/types/msgs.go @@ -94,7 +94,7 @@ func NewMsgBurnHeldBalance( coins sdk.Coins, ) *MsgBurnHeldBalance { return &MsgBurnHeldBalance{ - Sender: sender.String(), + Authority: sender.String(), BurnCoins: coins, } } @@ -112,13 +112,13 @@ func (msg MsgBurnHeldBalance) GetSignBytes() []byte { // GetSigners returns the expected signers for the message. func (msg *MsgBurnHeldBalance) GetSigners() []sdk.AccAddress { - addr, _ := sdk.AccAddressFromBech32(msg.Sender) + addr, _ := sdk.AccAddressFromBech32(msg.Authority) return []sdk.AccAddress{addr} } // ValidateBasic does a sanity check on the provided data. func (msg *MsgBurnHeldBalance) Validate() error { - if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return errors.Wrap(err, "invalid authority address") } diff --git a/x/manifest/types/tx.pb.go b/x/manifest/types/tx.pb.go index b565f97..8a9cb1a 100644 --- a/x/manifest/types/tx.pb.go +++ b/x/manifest/types/tx.pb.go @@ -187,7 +187,8 @@ func (m *MsgPayoutStakeholders) GetPayout() types.Coin { return types.Coin{} } -// MsgPayoutStakeholdersResponse defines the response structure for executing a MsgPayoutStakeholders message. +// MsgPayoutStakeholdersResponse defines the response structure for executing a +// MsgPayoutStakeholders message. type MsgPayoutStakeholdersResponse struct { } @@ -226,9 +227,9 @@ var xxx_messageInfo_MsgPayoutStakeholdersResponse proto.InternalMessageInfo // MsgPayoutStakeholders is the Msg/BurnHeldBalance request type. type MsgBurnHeldBalance struct { - // authority is the address of the controlling account. - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // payout is the amount of tokens paid to the current stakeholders. + // sender is the address of the tokenholder. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // burn_coins are the coins to be burned by the tokenholder. BurnCoins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=burn_coins,json=burnCoins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"burn_coins"` } @@ -265,9 +266,9 @@ func (m *MsgBurnHeldBalance) XXX_DiscardUnknown() { var xxx_messageInfo_MsgBurnHeldBalance proto.InternalMessageInfo -func (m *MsgBurnHeldBalance) GetSender() string { +func (m *MsgBurnHeldBalance) GetAuthority() string { if m != nil { - return m.Sender + return m.Authority } return "" } @@ -279,7 +280,8 @@ func (m *MsgBurnHeldBalance) GetBurnCoins() github_com_cosmos_cosmos_sdk_types.C return nil } -// MsgBurnHeldBalanceResponse defines the response structure for executing a MsgBurnHeldBalance message. +// MsgBurnHeldBalanceResponse defines the response structure for executing a +// MsgBurnHeldBalance message. type MsgBurnHeldBalanceResponse struct { } @@ -328,44 +330,43 @@ func init() { func init() { proto.RegisterFile("manifest/v1/tx.proto", fileDescriptor_7e3feee7606c5280) } var fileDescriptor_7e3feee7606c5280 = []byte{ - // 588 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xb1, 0x6b, 0xdb, 0x4e, - 0x14, 0xb6, 0x92, 0xdf, 0x2f, 0xe0, 0x4b, 0xa8, 0xa9, 0xea, 0x12, 0x5b, 0xa4, 0xb2, 0x31, 0x85, - 0x1a, 0x83, 0x75, 0x75, 0x0a, 0x19, 0xbc, 0x55, 0x85, 0x92, 0xc5, 0x60, 0x1c, 0xba, 0xb4, 0x43, - 0x38, 0x5b, 0x97, 0xf3, 0x61, 0xe9, 0x4e, 0xe8, 0xce, 0x26, 0xa6, 0x4b, 0xe8, 0xdc, 0xa1, 0x73, - 0xa7, 0x42, 0x97, 0xd2, 0xc9, 0x43, 0xff, 0x88, 0x8c, 0xa1, 0x53, 0xe9, 0xd0, 0x06, 0x7b, 0x70, - 0xff, 0x8c, 0x22, 0xe9, 0xe4, 0x38, 0x8a, 0xb1, 0xa1, 0x8b, 0x74, 0xba, 0xf7, 0xbd, 0xef, 0xbd, - 0xef, 0x7b, 0x0f, 0x81, 0xbc, 0x87, 0x18, 0x3d, 0xc3, 0x42, 0xc2, 0x51, 0x03, 0xca, 0x73, 0xcb, - 0x0f, 0xb8, 0xe4, 0xfa, 0x6e, 0x72, 0x6b, 0x8d, 0x1a, 0xc6, 0x7e, 0x8f, 0x0b, 0x8f, 0x0b, 0xe8, - 0x09, 0x12, 0x82, 0x3c, 0x41, 0x62, 0x94,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0x79, 0x03, 0x72, 0xe9, 0xc1, 0x95, 0xd2, 0xe9, 0x29, 0x80, 0xf1, - 0x64, 0x03, 0x20, 0x21, 0x37, 0xfe, 0xbf, 0x08, 0xfd, 0xb5, 0xdb, 0x97, 0x53, 0x53, 0xbb, 0x9a, - 0x9a, 0xda, 0xf5, 0xd4, 0xd4, 0x3e, 0xcc, 0xcc, 0xcc, 0xd5, 0xcc, 0xcc, 0xfc, 0x98, 0x99, 0x99, - 0xd7, 0x47, 0x4b, 0x93, 0x73, 0xe9, 0x99, 0xc4, 0x0e, 0x65, 0x54, 0xc2, 0x84, 0xbe, 0xee, 0x62, - 0x87, 0xe0, 0x00, 0x9e, 0x2f, 0x6e, 0xe2, 0x69, 0x76, 0x77, 0xa2, 0xff, 0xc4, 0xb3, 0xbf, 0x01, - 0x00, 0x00, 0xff, 0xff, 0xe9, 0x1e, 0xeb, 0x7c, 0xe4, 0x04, 0x00, 0x00, + // 572 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x31, 0x6b, 0xdb, 0x40, + 0x14, 0xb6, 0x92, 0x36, 0x90, 0x4b, 0x68, 0xa8, 0xea, 0x12, 0x5b, 0xa4, 0xb2, 0x31, 0x85, 0x1a, + 0x83, 0x75, 0x38, 0x85, 0x0c, 0xd9, 0xaa, 0x42, 0xc9, 0x62, 0x30, 0x0e, 0x5d, 0xda, 0x21, 0x9c, + 0xad, 0xcb, 0xf9, 0xb0, 0xa4, 0x13, 0x7a, 0x67, 0x13, 0xd3, 0x25, 0x74, 0xee, 0xd0, 0xb9, 0x53, + 0xa1, 0x4b, 0xe9, 0xe4, 0xa1, 0x3f, 0x22, 0x63, 0xe8, 0xd4, 0xa9, 0x0d, 0xf6, 0xe0, 0xfe, 0x8c, + 0x22, 0xe9, 0xe4, 0x38, 0x8a, 0x71, 0x20, 0x8b, 0x74, 0xba, 0xf7, 0xbd, 0xef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 0xdd, 0xbb, 0xb1, 0x6d, 0x99, 0x2d, 0x32, + 0x9e, 0xaf, 0x8a, 0xa6, 0xdc, 0xba, 0x83, 0xf4, 0x25, 0xfb, 0x55, 0xc9, 0xe6, 0xde, 0xc6, 0x18, + 0xb5, 0xbb, 0x31, 0xf3, 0x2a, 0xef, 0xd1, 0x4e, 0x76, 0x82, 0xa5, 0x6c, 0x7a, 0x06, 0x60, 0xbc, + 0xb8, 0x03, 0x90, 0x92, 0x1b, 0x0f, 0xcf, 0x23, 0x8b, 0xed, 0xd6, 0xc5, 0xc4, 0xd4, 0x2e, 0x27, + 0xa6, 0x76, 0x35, 0x31, 0xb5, 0xcf, 0x53, 0x33, 0x77, 0x39, 0x35, 0x73, 0xbf, 0xa7, 0x66, 0xee, + 0xdd, 0xc1, 0xc2, 0xf0, 0x5c, 0x7e, 0x2a, 0xa9, 0xc3, 0x7d, 0x2e, 0x71, 0x4a, 0x5f, 0x77, 0xa9, + 0xc3, 0x68, 0x88, 0xcf, 0xe6, 0x37, 0xc9, 0x40, 0x3b, 0x1b, 0xf1, 0x0f, 0xe3, 0xe5, 0xff, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xdb, 0xb3, 0x0b, 0x8a, 0xed, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -690,10 +691,10 @@ func (m *MsgBurnHeldBalance) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x12 } } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) i-- dAtA[i] = 0xa } @@ -788,7 +789,7 @@ func (m *MsgBurnHeldBalance) Size() (n int) { } var l int _ = l - l = len(m.Sender) + l = len(m.Authority) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1177,7 +1178,7 @@ func (m *MsgBurnHeldBalance) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1205,7 +1206,7 @@ func (m *MsgBurnHeldBalance) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sender = string(dAtA[iNdEx:postIndex]) + m.Authority = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 {