mirror of
				https://github.com/0glabs/0g-chain.git
				synced 2025-10-31 23:08:32 +00:00 
			
		
		
		
	feat: add CommunityPoolLendWithdrawalPermission (#1562)
* feat: add CommunityPoolLendWithdrawalPermission * update kvtool to master branch * register with PubProposal legacy amino codec * register missing legacy amino codec PubProposal
This commit is contained in:
		
							parent
							
								
									56f697fba6
								
							
						
					
					
						commit
						8c1c29a03a
					
				| @ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ | ||||
| - (deps) [#1477] Migrate to CometBFT. | ||||
| - (x/incentive) [#1512] Add grpc query service. | ||||
| - (deps) [#1544] Bump confio/ics23/go to v0.9.0, cosmos/keyring to v1.2.0. | ||||
| - (x/committee) [#1562] Add CommunityPoolLendWithdrawPermission | ||||
| - (x/community) [#1563] Include x/community module pool balance in x/distribution | ||||
|   community_pool query response. | ||||
| 
 | ||||
| @ -232,6 +233,8 @@ the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.38.4/CHANGELOG.md). | ||||
| 
 | ||||
| 
 | ||||
| [#1563]: https://github.com/Kava-Labs/kava/pull/1563 | ||||
| [#1562]: https://github.com/Kava-Labs/kava/pull/1562 | ||||
| [#1550]: https://github.com/Kava-Labs/kava/pull/1550 | ||||
| [#1544]: https://github.com/Kava-Labs/kava/pull/1544 | ||||
| [#1477]: https://github.com/Kava-Labs/kava/pull/1477 | ||||
| [#1512]: https://github.com/Kava-Labs/kava/pull/1512 | ||||
|  | ||||
| @ -685,6 +685,7 @@ func NewApp( | ||||
| 	committeeGovRouter := govv1beta1.NewRouter() | ||||
| 	committeeGovRouter. | ||||
| 		AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). | ||||
| 		AddRoute(communitytypes.RouterKey, community.NewCommunityPoolProposalHandler(app.communityKeeper)). | ||||
| 		AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)). | ||||
| 		AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.distrKeeper)). | ||||
| 		AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.upgradeKeeper)) | ||||
|  | ||||
| @ -138,6 +138,7 @@ | ||||
|    | ||||
| - [kava/committee/v1beta1/permissions.proto](#kava/committee/v1beta1/permissions.proto) | ||||
|     - [AllowedParamsChange](#kava.committee.v1beta1.AllowedParamsChange) | ||||
|     - [CommunityPoolLendWithdrawPermission](#kava.committee.v1beta1.CommunityPoolLendWithdrawPermission) | ||||
|     - [GodPermission](#kava.committee.v1beta1.GodPermission) | ||||
|     - [ParamsChangePermission](#kava.committee.v1beta1.ParamsChangePermission) | ||||
|     - [SoftwareUpgradePermission](#kava.committee.v1beta1.SoftwareUpgradePermission) | ||||
| @ -2323,6 +2324,16 @@ AllowedParamsChange contains data on the allowed parameter changes for subspace, | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| <a name="kava.committee.v1beta1.CommunityPoolLendWithdrawPermission"></a> | ||||
| 
 | ||||
| ### CommunityPoolLendWithdrawPermission | ||||
| CommunityPoolLendWithdrawPermission allows submission of CommunityPoolLendWithdrawProposal | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| <a name="kava.committee.v1beta1.GodPermission"></a> | ||||
| 
 | ||||
| ### GodPermission | ||||
|  | ||||
| @ -21,6 +21,11 @@ message TextPermission { | ||||
|   option (cosmos_proto.implements_interface) = "Permission"; | ||||
| } | ||||
| 
 | ||||
| // CommunityPoolLendWithdrawPermission allows submission of CommunityPoolLendWithdrawProposal | ||||
| message CommunityPoolLendWithdrawPermission { | ||||
|   option (cosmos_proto.implements_interface) = "Permission"; | ||||
| } | ||||
| 
 | ||||
| // ParamsChangePermission allows any parameter or sub parameter change proposal. | ||||
| message ParamsChangePermission { | ||||
|   option (cosmos_proto.implements_interface) = "Permission"; | ||||
|  | ||||
| @ -1 +1 @@ | ||||
| Subproject commit 9111087667b4ec136a4dd684762e41515a240a0f | ||||
| Subproject commit ea6bd5386c80d372c52f0801ff91923eb0dab56f | ||||
| @ -12,6 +12,7 @@ import ( | ||||
| 	govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" | ||||
| 	proposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" | ||||
| 	upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||||
| 	communitytypes "github.com/kava-labs/kava/x/community/types" | ||||
| 	kavadisttypes "github.com/kava-labs/kava/x/kavadist/types" | ||||
| ) | ||||
| 
 | ||||
| @ -47,7 +48,7 @@ func init() { | ||||
| 	RegisterProposalTypeCodec(govv1beta1.TextProposal{}, "cosmos-sdk/TextProposal") | ||||
| 	RegisterProposalTypeCodec(upgradetypes.SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal") | ||||
| 	RegisterProposalTypeCodec(upgradetypes.CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal") | ||||
| 
 | ||||
| 	RegisterProposalTypeCodec(communitytypes.CommunityPoolLendWithdrawProposal{}, "kava/CommunityPoolLendWithdrawProposal") | ||||
| } | ||||
| 
 | ||||
| // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the module.
 | ||||
| @ -69,6 +70,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { | ||||
| 	cdc.RegisterConcrete(TextPermission{}, "kava/TextPermission", nil) | ||||
| 	cdc.RegisterConcrete(SoftwareUpgradePermission{}, "kava/SoftwareUpgradePermission", nil) | ||||
| 	cdc.RegisterConcrete(ParamsChangePermission{}, "kava/ParamsChangePermission", nil) | ||||
| 	cdc.RegisterConcrete(CommunityPoolLendWithdrawPermission{}, "kava/CommunityPoolLendWithdrawPermission", nil) | ||||
| 
 | ||||
| 	// Msgs
 | ||||
| 	legacy.RegisterAminoMsg(cdc, &MsgSubmitProposal{}, "kava/MsgSubmitProposal") | ||||
| @ -104,6 +106,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { | ||||
| 		&TextPermission{}, | ||||
| 		&SoftwareUpgradePermission{}, | ||||
| 		&ParamsChangePermission{}, | ||||
| 		&CommunityPoolLendWithdrawPermission{}, | ||||
| 	) | ||||
| 
 | ||||
| 	// Need to register PubProposal here since we use this as alias for the x/gov Content interface for all the proposal implementations used in this module.
 | ||||
| @ -118,6 +121,8 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { | ||||
| 		&proposaltypes.ParameterChangeProposal{}, | ||||
| 		&upgradetypes.SoftwareUpgradeProposal{}, | ||||
| 		&upgradetypes.CancelSoftwareUpgradeProposal{}, | ||||
| 		&communitytypes.CommunityPoolLendWithdrawProposal{}, | ||||
| 		&kavadisttypes.CommunityPoolMultiSpendProposal{}, | ||||
| 	) | ||||
| 
 | ||||
| 	registry.RegisterImplementations( | ||||
|  | ||||
| @ -12,6 +12,7 @@ import ( | ||||
| 	paramsproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" | ||||
| 	upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||||
| 	proto "github.com/gogo/protobuf/proto" | ||||
| 	communitytypes "github.com/kava-labs/kava/x/community/types" | ||||
| ) | ||||
| 
 | ||||
| // Permission is anything with a method that validates whether a proposal is allowed by it or not.
 | ||||
| @ -53,6 +54,7 @@ var ( | ||||
| 	_ Permission = TextPermission{} | ||||
| 	_ Permission = SoftwareUpgradePermission{} | ||||
| 	_ Permission = ParamsChangePermission{} | ||||
| 	_ Permission = CommunityPoolLendWithdrawPermission{} | ||||
| ) | ||||
| 
 | ||||
| // Allows implement permission interface for GodPermission.
 | ||||
| @ -70,6 +72,12 @@ func (SoftwareUpgradePermission) Allows(_ sdk.Context, _ ParamKeeper, p PubPropo | ||||
| 	return ok | ||||
| } | ||||
| 
 | ||||
| // Allows implement permission interface for CommunityPoolLendWithdrawPermission.
 | ||||
| func (CommunityPoolLendWithdrawPermission) Allows(_ sdk.Context, _ ParamKeeper, p PubProposal) bool { | ||||
| 	_, ok := p.(*communitytypes.CommunityPoolLendWithdrawProposal) | ||||
| 	return ok | ||||
| } | ||||
| 
 | ||||
| // Allows implement permission interface for ParamsChangePermission.
 | ||||
| func (perm ParamsChangePermission) Allows(ctx sdk.Context, pk ParamKeeper, p PubProposal) bool { | ||||
| 	proposal, ok := p.(*paramsproposal.ParameterChangeProposal) | ||||
|  | ||||
| @ -135,6 +135,43 @@ func (m *TextPermission) XXX_DiscardUnknown() { | ||||
| 
 | ||||
| var xxx_messageInfo_TextPermission proto.InternalMessageInfo | ||||
| 
 | ||||
| // CommunityPoolLendWithdrawPermission allows submission of CommunityPoolLendWithdrawProposal
 | ||||
| type CommunityPoolLendWithdrawPermission struct { | ||||
| } | ||||
| 
 | ||||
| func (m *CommunityPoolLendWithdrawPermission) Reset()         { *m = CommunityPoolLendWithdrawPermission{} } | ||||
| func (m *CommunityPoolLendWithdrawPermission) String() string { return proto.CompactTextString(m) } | ||||
| func (*CommunityPoolLendWithdrawPermission) ProtoMessage()    {} | ||||
| func (*CommunityPoolLendWithdrawPermission) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_bdfaf7be16465ae4, []int{3} | ||||
| } | ||||
| func (m *CommunityPoolLendWithdrawPermission) XXX_Unmarshal(b []byte) error { | ||||
| 	return m.Unmarshal(b) | ||||
| } | ||||
| func (m *CommunityPoolLendWithdrawPermission) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	if deterministic { | ||||
| 		return xxx_messageInfo_CommunityPoolLendWithdrawPermission.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 *CommunityPoolLendWithdrawPermission) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_CommunityPoolLendWithdrawPermission.Merge(m, src) | ||||
| } | ||||
| func (m *CommunityPoolLendWithdrawPermission) XXX_Size() int { | ||||
| 	return m.Size() | ||||
| } | ||||
| func (m *CommunityPoolLendWithdrawPermission) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_CommunityPoolLendWithdrawPermission.DiscardUnknown(m) | ||||
| } | ||||
| 
 | ||||
| var xxx_messageInfo_CommunityPoolLendWithdrawPermission proto.InternalMessageInfo | ||||
| 
 | ||||
| // ParamsChangePermission allows any parameter or sub parameter change proposal.
 | ||||
| type ParamsChangePermission struct { | ||||
| 	AllowedParamsChanges AllowedParamsChanges `protobuf:"bytes,1,rep,name=allowed_params_changes,json=allowedParamsChanges,proto3,castrepeated=AllowedParamsChanges" json:"allowed_params_changes"` | ||||
| @ -144,7 +181,7 @@ func (m *ParamsChangePermission) Reset()         { *m = ParamsChangePermission{} | ||||
| func (m *ParamsChangePermission) String() string { return proto.CompactTextString(m) } | ||||
| func (*ParamsChangePermission) ProtoMessage()    {} | ||||
| func (*ParamsChangePermission) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_bdfaf7be16465ae4, []int{3} | ||||
| 	return fileDescriptor_bdfaf7be16465ae4, []int{4} | ||||
| } | ||||
| func (m *ParamsChangePermission) XXX_Unmarshal(b []byte) error { | ||||
| 	return m.Unmarshal(b) | ||||
| @ -196,7 +233,7 @@ func (m *AllowedParamsChange) Reset()         { *m = AllowedParamsChange{} } | ||||
| func (m *AllowedParamsChange) String() string { return proto.CompactTextString(m) } | ||||
| func (*AllowedParamsChange) ProtoMessage()    {} | ||||
| func (*AllowedParamsChange) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_bdfaf7be16465ae4, []int{4} | ||||
| 	return fileDescriptor_bdfaf7be16465ae4, []int{5} | ||||
| } | ||||
| func (m *AllowedParamsChange) XXX_Unmarshal(b []byte) error { | ||||
| 	return m.Unmarshal(b) | ||||
| @ -267,7 +304,7 @@ func (m *SubparamRequirement) Reset()         { *m = SubparamRequirement{} } | ||||
| func (m *SubparamRequirement) String() string { return proto.CompactTextString(m) } | ||||
| func (*SubparamRequirement) ProtoMessage()    {} | ||||
| func (*SubparamRequirement) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_bdfaf7be16465ae4, []int{5} | ||||
| 	return fileDescriptor_bdfaf7be16465ae4, []int{6} | ||||
| } | ||||
| func (m *SubparamRequirement) XXX_Unmarshal(b []byte) error { | ||||
| 	return m.Unmarshal(b) | ||||
| @ -321,6 +358,7 @@ func init() { | ||||
| 	proto.RegisterType((*GodPermission)(nil), "kava.committee.v1beta1.GodPermission") | ||||
| 	proto.RegisterType((*SoftwareUpgradePermission)(nil), "kava.committee.v1beta1.SoftwareUpgradePermission") | ||||
| 	proto.RegisterType((*TextPermission)(nil), "kava.committee.v1beta1.TextPermission") | ||||
| 	proto.RegisterType((*CommunityPoolLendWithdrawPermission)(nil), "kava.committee.v1beta1.CommunityPoolLendWithdrawPermission") | ||||
| 	proto.RegisterType((*ParamsChangePermission)(nil), "kava.committee.v1beta1.ParamsChangePermission") | ||||
| 	proto.RegisterType((*AllowedParamsChange)(nil), "kava.committee.v1beta1.AllowedParamsChange") | ||||
| 	proto.RegisterType((*SubparamRequirement)(nil), "kava.committee.v1beta1.SubparamRequirement") | ||||
| @ -331,36 +369,37 @@ func init() { | ||||
| } | ||||
| 
 | ||||
| var fileDescriptor_bdfaf7be16465ae4 = []byte{ | ||||
| 	// 451 bytes of a gzipped FileDescriptorProto
 | ||||
| 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x93, 0xcd, 0x6e, 0xd3, 0x40, | ||||
| 	0x10, 0x80, 0xb3, 0xb8, 0x42, 0x74, 0x11, 0x55, 0xe5, 0x46, 0x91, 0x6b, 0x15, 0x27, 0xca, 0x29, | ||||
| 	0x52, 0x54, 0x5b, 0x85, 0x1b, 0xb7, 0x04, 0x21, 0xae, 0x95, 0x0b, 0x17, 0x2e, 0xd6, 0x3a, 0x59, | ||||
| 	0x5c, 0xab, 0x76, 0xd6, 0xec, 0x8c, 0xd3, 0x56, 0x42, 0xe2, 0x15, 0x78, 0x0d, 0x38, 0xf3, 0x10, | ||||
| 	0x15, 0xa7, 0x1e, 0x39, 0x01, 0x4a, 0x1e, 0x83, 0x0b, 0xda, 0xf5, 0xaf, 0x54, 0x2b, 0xb7, 0x99, | ||||
| 	0xd9, 0x6f, 0x66, 0xfd, 0xed, 0x7a, 0xe9, 0xe4, 0x8a, 0xad, 0x99, 0xb7, 0x10, 0x69, 0x1a, 0x23, | ||||
| 	0x72, 0xee, 0xad, 0xcf, 0x42, 0x8e, 0xec, 0xcc, 0xcb, 0xb8, 0x4c, 0x63, 0x80, 0x58, 0xac, 0xc0, | ||||
| 	0xcd, 0xa4, 0x40, 0x61, 0x0e, 0x14, 0xe9, 0xd6, 0xa4, 0x5b, 0x92, 0xf6, 0xf1, 0x42, 0x40, 0x2a, | ||||
| 	0x20, 0xd0, 0x94, 0x57, 0x24, 0x45, 0x8b, 0xdd, 0x8f, 0x44, 0x24, 0x8a, 0xba, 0x8a, 0x8a, 0xea, | ||||
| 	0x78, 0x48, 0x9f, 0xbd, 0x15, 0xcb, 0xf3, 0x7a, 0x83, 0x57, 0x07, 0x3f, 0x7f, 0x9c, 0xd2, 0x26, | ||||
| 	0x1f, 0x4f, 0xe9, 0xf1, 0x85, 0xf8, 0x88, 0xd7, 0x4c, 0xf2, 0xf7, 0x59, 0x24, 0xd9, 0x92, 0xef, | ||||
| 	0x80, 0x47, 0xf4, 0xe0, 0x1d, 0xbf, 0xc1, 0x1d, 0xc4, 0x37, 0x42, 0x07, 0xe7, 0x4c, 0xb2, 0x14, | ||||
| 	0x5e, 0x5f, 0xb2, 0x55, 0xd4, 0x1a, 0x66, 0x7e, 0xa1, 0x03, 0x96, 0x24, 0xe2, 0x9a, 0x2f, 0x83, | ||||
| 	0x4c, 0x13, 0xc1, 0x42, 0x23, 0x60, 0x91, 0x91, 0x31, 0x79, 0xfa, 0x62, 0xea, 0x76, 0x4b, 0xbb, | ||||
| 	0xb3, 0xa2, 0xab, 0x3d, 0x76, 0x7e, 0x72, 0xf7, 0x7b, 0xd8, 0xfb, 0xfe, 0x67, 0xd8, 0xef, 0x58, | ||||
| 	0x04, 0xbf, 0xcf, 0x3a, 0xaa, 0x0f, 0xbe, 0xf5, 0x1f, 0xa1, 0x47, 0x1d, 0xed, 0xa6, 0x4d, 0x9f, | ||||
| 	0x40, 0x1e, 0x42, 0xc6, 0x16, 0xdc, 0x22, 0x23, 0x32, 0xd9, 0xf7, 0xeb, 0xdc, 0x3c, 0xa4, 0xc6, | ||||
| 	0x15, 0xbf, 0xb5, 0x1e, 0xe9, 0xb2, 0x0a, 0xcd, 0x19, 0x7d, 0x0e, 0xf1, 0x2a, 0x4a, 0x78, 0x00, | ||||
| 	0x79, 0xa8, 0xc5, 0x82, 0x4a, 0x93, 0x21, 0x4a, 0xb0, 0x8c, 0x91, 0x31, 0xd9, 0xf7, 0xed, 0x02, | ||||
| 	0xba, 0x28, 0x99, 0x72, 0xdf, 0x99, 0x22, 0x4c, 0xa0, 0x27, 0x69, 0x9e, 0x60, 0x5c, 0x4f, 0x80, | ||||
| 	0x40, 0xf2, 0x4f, 0x79, 0x2c, 0x79, 0xca, 0x57, 0x08, 0xd6, 0xde, 0xee, 0xf3, 0xa9, 0x66, 0xfa, | ||||
| 	0x4d, 0xcf, 0x7c, 0x4f, 0x9d, 0x8f, 0x6f, 0xeb, 0xb1, 0xd5, 0x3a, 0xb4, 0x00, 0x18, 0x7f, 0xa6, | ||||
| 	0x47, 0x1d, 0x8d, 0x95, 0x20, 0x69, 0x04, 0x0f, 0xa9, 0xb1, 0x66, 0x49, 0xa5, 0xbc, 0x66, 0x89, | ||||
| 	0x52, 0xae, 0x14, 0x1b, 0x67, 0x44, 0x59, 0x5f, 0x68, 0xa9, 0x5c, 0x42, 0xb5, 0x33, 0xa2, 0x2c, | ||||
| 	0xef, 0x62, 0xfe, 0xe6, 0x6e, 0xe3, 0x90, 0xfb, 0x8d, 0x43, 0xfe, 0x6e, 0x1c, 0xf2, 0x75, 0xeb, | ||||
| 	0xf4, 0xee, 0xb7, 0x4e, 0xef, 0xd7, 0xd6, 0xe9, 0x7d, 0x98, 0x46, 0x31, 0x5e, 0xe6, 0xa1, 0xf2, | ||||
| 	0xf4, 0x94, 0xf0, 0x69, 0xc2, 0x42, 0xd0, 0x91, 0x77, 0xd3, 0x7a, 0x3b, 0x78, 0x9b, 0x71, 0x08, | ||||
| 	0x1f, 0xeb, 0xbf, 0xfc, 0xe5, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x78, 0x09, 0x36, 0x56, 0x5a, | ||||
| 	0x03, 0x00, 0x00, | ||||
| 	// 478 bytes of a gzipped FileDescriptorProto
 | ||||
| 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x93, 0x4f, 0x8b, 0xd3, 0x40, | ||||
| 	0x18, 0x87, 0x1b, 0xbb, 0x88, 0x3b, 0xe2, 0xb2, 0x64, 0x4b, 0xc9, 0x86, 0x35, 0x2d, 0xf5, 0x52, | ||||
| 	0x28, 0x9b, 0xb0, 0x8a, 0x17, 0x6f, 0xed, 0x22, 0x5e, 0x3c, 0x94, 0xac, 0x22, 0x78, 0x09, 0x93, | ||||
| 	0x66, 0x4c, 0x87, 0xcd, 0x64, 0xe2, 0xbc, 0x6f, 0xda, 0x2d, 0x08, 0x7e, 0x05, 0xbf, 0x86, 0x9e, | ||||
| 	0xfd, 0x10, 0x8b, 0xa7, 0x3d, 0x7a, 0x52, 0x69, 0x3f, 0x86, 0x17, 0xc9, 0xdf, 0x16, 0x0c, 0xbd, | ||||
| 	0xcd, 0xbc, 0xf3, 0xfc, 0xde, 0x99, 0x67, 0x86, 0x21, 0xc3, 0x6b, 0xba, 0xa0, 0xce, 0x4c, 0x0a, | ||||
| 	0xc1, 0x11, 0x19, 0x73, 0x16, 0x17, 0x3e, 0x43, 0x7a, 0xe1, 0x24, 0x4c, 0x09, 0x0e, 0xc0, 0x65, | ||||
| 	0x0c, 0x76, 0xa2, 0x24, 0x4a, 0xbd, 0x9b, 0x91, 0x76, 0x4d, 0xda, 0x25, 0x69, 0x9e, 0xce, 0x24, | ||||
| 	0x08, 0x09, 0x5e, 0x4e, 0x39, 0xc5, 0xa4, 0x88, 0x98, 0x9d, 0x50, 0x86, 0xb2, 0xa8, 0x67, 0xa3, | ||||
| 	0xa2, 0x3a, 0xe8, 0x91, 0x47, 0xaf, 0x64, 0x30, 0xad, 0x37, 0x78, 0x71, 0xf4, 0xe3, 0xfb, 0x39, | ||||
| 	0xd9, 0xce, 0x07, 0x23, 0x72, 0x7a, 0x25, 0x3f, 0xe0, 0x92, 0x2a, 0xf6, 0x36, 0x09, 0x15, 0x0d, | ||||
| 	0xd8, 0x1e, 0xb8, 0x4f, 0x8e, 0xde, 0xb0, 0x1b, 0xdc, 0x43, 0x3c, 0x27, 0x4f, 0x2e, 0xa5, 0x10, | ||||
| 	0x69, 0xcc, 0x71, 0x35, 0x95, 0x32, 0x7a, 0xcd, 0xe2, 0xe0, 0x1d, 0xc7, 0x79, 0xa0, 0xe8, 0x72, | ||||
| 	0x4f, 0xec, 0xab, 0x46, 0xba, 0x53, 0xaa, 0xa8, 0x80, 0xcb, 0x39, 0x8d, 0xc3, 0x9d, 0x33, 0xe8, | ||||
| 	0x9f, 0x49, 0x97, 0x46, 0x91, 0x5c, 0xb2, 0xc0, 0x4b, 0x72, 0xc2, 0x9b, 0xe5, 0x08, 0x18, 0x5a, | ||||
| 	0xbf, 0x3d, 0x7c, 0xf8, 0x74, 0x64, 0x37, 0xdf, 0x95, 0x3d, 0x2e, 0x52, 0xbb, 0x6d, 0x27, 0x67, | ||||
| 	0xb7, 0xbf, 0x7a, 0xad, 0x6f, 0xbf, 0x7b, 0x9d, 0x86, 0x45, 0x70, 0x3b, 0xb4, 0xa1, 0xfa, 0xdf, | ||||
| 	0x59, 0xff, 0x6a, 0xe4, 0xa4, 0x21, 0xae, 0x9b, 0xe4, 0x01, 0xa4, 0x3e, 0x24, 0x74, 0xc6, 0x0c, | ||||
| 	0xad, 0xaf, 0x0d, 0x0f, 0xdd, 0x7a, 0xae, 0x1f, 0x93, 0xf6, 0x35, 0x5b, 0x19, 0xf7, 0xf2, 0x72, | ||||
| 	0x36, 0xd4, 0xc7, 0xe4, 0x31, 0xf0, 0x38, 0x8c, 0x98, 0x07, 0xa9, 0x9f, 0x8b, 0x79, 0x95, 0x26, | ||||
| 	0x45, 0x54, 0x60, 0xb4, 0xfb, 0xed, 0xe1, 0xa1, 0x6b, 0x16, 0xd0, 0x55, 0xc9, 0x94, 0xfb, 0x8e, | ||||
| 	0x33, 0x42, 0x07, 0x72, 0x26, 0xd2, 0x08, 0x79, 0xdd, 0x01, 0x3c, 0xc5, 0x3e, 0xa6, 0x5c, 0x31, | ||||
| 	0xc1, 0x62, 0x04, 0xe3, 0x60, 0xff, 0xfd, 0x54, 0x3d, 0xdd, 0x6d, 0x66, 0x72, 0x90, 0xdd, 0x8f, | ||||
| 	0x6b, 0xe6, 0x6d, 0xab, 0x75, 0xd8, 0x01, 0x60, 0xf0, 0x89, 0x9c, 0x34, 0x04, 0x2b, 0x41, 0x6d, | ||||
| 	0x2b, 0x78, 0x4c, 0xda, 0x0b, 0x1a, 0x55, 0xca, 0x0b, 0x1a, 0x65, 0xca, 0x95, 0xe2, 0xd6, 0x19, | ||||
| 	0x51, 0xd5, 0x0f, 0x5a, 0x2a, 0x97, 0x50, 0xed, 0x8c, 0xa8, 0xca, 0xb7, 0x98, 0xbc, 0xbc, 0x5d, | ||||
| 	0x5b, 0xda, 0xdd, 0xda, 0xd2, 0xfe, 0xac, 0x2d, 0xed, 0xcb, 0xc6, 0x6a, 0xdd, 0x6d, 0xac, 0xd6, | ||||
| 	0xcf, 0x8d, 0xd5, 0x7a, 0x3f, 0x0a, 0x39, 0xce, 0x53, 0x3f, 0xf3, 0x74, 0x32, 0xe1, 0xf3, 0x88, | ||||
| 	0xfa, 0x90, 0x8f, 0x9c, 0x9b, 0x9d, 0x2f, 0x87, 0xab, 0x84, 0x81, 0x7f, 0x3f, 0xff, 0x1c, 0xcf, | ||||
| 	0xfe, 0x05, 0x00, 0x00, 0xff, 0xff, 0xc3, 0xcd, 0x1f, 0x08, 0x91, 0x03, 0x00, 0x00, | ||||
| } | ||||
| 
 | ||||
| func (m *GodPermission) Marshal() (dAtA []byte, err error) { | ||||
| @ -432,6 +471,29 @@ func (m *TextPermission) MarshalToSizedBuffer(dAtA []byte) (int, error) { | ||||
| 	return len(dAtA) - i, nil | ||||
| } | ||||
| 
 | ||||
| func (m *CommunityPoolLendWithdrawPermission) 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 *CommunityPoolLendWithdrawPermission) MarshalTo(dAtA []byte) (int, error) { | ||||
| 	size := m.Size() | ||||
| 	return m.MarshalToSizedBuffer(dAtA[:size]) | ||||
| } | ||||
| 
 | ||||
| func (m *CommunityPoolLendWithdrawPermission) MarshalToSizedBuffer(dAtA []byte) (int, error) { | ||||
| 	i := len(dAtA) | ||||
| 	_ = i | ||||
| 	var l int | ||||
| 	_ = l | ||||
| 	return len(dAtA) - i, nil | ||||
| } | ||||
| 
 | ||||
| func (m *ParamsChangePermission) Marshal() (dAtA []byte, err error) { | ||||
| 	size := m.Size() | ||||
| 	dAtA = make([]byte, size) | ||||
| @ -613,6 +675,15 @@ func (m *TextPermission) Size() (n int) { | ||||
| 	return n | ||||
| } | ||||
| 
 | ||||
| func (m *CommunityPoolLendWithdrawPermission) Size() (n int) { | ||||
| 	if m == nil { | ||||
| 		return 0 | ||||
| 	} | ||||
| 	var l int | ||||
| 	_ = l | ||||
| 	return n | ||||
| } | ||||
| 
 | ||||
| func (m *ParamsChangePermission) Size() (n int) { | ||||
| 	if m == nil { | ||||
| 		return 0 | ||||
| @ -836,6 +907,56 @@ func (m *TextPermission) Unmarshal(dAtA []byte) error { | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| func (m *CommunityPoolLendWithdrawPermission) 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 ErrIntOverflowPermissions | ||||
| 			} | ||||
| 			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: CommunityPoolLendWithdrawPermission: wiretype end group for non-group") | ||||
| 		} | ||||
| 		if fieldNum <= 0 { | ||||
| 			return fmt.Errorf("proto: CommunityPoolLendWithdrawPermission: illegal tag %d (wire type %d)", fieldNum, wire) | ||||
| 		} | ||||
| 		switch fieldNum { | ||||
| 		default: | ||||
| 			iNdEx = preIndex | ||||
| 			skippy, err := skipPermissions(dAtA[iNdEx:]) | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 			if (skippy < 0) || (iNdEx+skippy) < 0 { | ||||
| 				return ErrInvalidLengthPermissions | ||||
| 			} | ||||
| 			if (iNdEx + skippy) > l { | ||||
| 				return io.ErrUnexpectedEOF | ||||
| 			} | ||||
| 			iNdEx += skippy | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if iNdEx > l { | ||||
| 		return io.ErrUnexpectedEOF | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| func (m *ParamsChangePermission) Unmarshal(dAtA []byte) error { | ||||
| 	l := len(dAtA) | ||||
| 	iNdEx := 0 | ||||
|  | ||||
| @ -11,6 +11,7 @@ import ( | ||||
| 	paramsproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" | ||||
| 
 | ||||
| 	"github.com/kava-labs/kava/x/committee/types" | ||||
| 	communitytypes "github.com/kava-labs/kava/x/community/types" | ||||
| ) | ||||
| 
 | ||||
| func TestPackPermissions_Success(t *testing.T) { | ||||
| @ -40,6 +41,43 @@ func TestUnpackPermissions_Failure(t *testing.T) { | ||||
| 	require.Error(t, err) | ||||
| } | ||||
| 
 | ||||
| func TestCommunityPoolLendWithdrawPermission_Allows(t *testing.T) { | ||||
| 	permission := types.CommunityPoolLendWithdrawPermission{} | ||||
| 	testcases := []struct { | ||||
| 		name     string | ||||
| 		proposal types.PubProposal | ||||
| 		allowed  bool | ||||
| 	}{ | ||||
| 		{ | ||||
| 			name: "allowed for correct proposal", | ||||
| 			proposal: communitytypes.NewCommunityPoolLendWithdrawProposal( | ||||
| 				"withdraw lend position", | ||||
| 				"this fake proposal withdraws a lend position for the community pool", | ||||
| 				sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e10))), | ||||
| 			), | ||||
| 			allowed: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			name:     "fails for nil proposal", | ||||
| 			proposal: nil, | ||||
| 			allowed:  false, | ||||
| 		}, | ||||
| 		{ | ||||
| 			name: "fails for wrong proposal", | ||||
| 			proposal: newTestParamsChangeProposalWithChanges([]paramsproposal.ParamChange{ | ||||
| 				{Subspace: "cdp", Key: "DebtThreshold", Value: `test`}, | ||||
| 			}), | ||||
| 			allowed: false, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	for _, tc := range testcases { | ||||
| 		t.Run(tc.name, func(t *testing.T) { | ||||
| 			require.Equal(t, tc.allowed, permission.Allows(sdk.Context{}, nil, tc.proposal)) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func TestParamsChangePermission_SimpleParamsChange_Allows(t *testing.T) { | ||||
| 	testPermission := types.ParamsChangePermission{ | ||||
| 		AllowedParamsChanges: types.AllowedParamsChanges{ | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Robert Pirtle
						Robert Pirtle