From 27c62e727bf67d96ae1273c643ab5e5faa319cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Wed, 6 Nov 2024 12:14:46 +0700 Subject: [PATCH 1/2] fix query gov proposals --- cmd/onomyd/cmd/cmd.go | 3 + go.mod | 8 +- proto/onomyprotocol copy/dao/v1/dao.proto | 65 + proto/onomyprotocol copy/dao/v1/genesis.proto | 19 + proto/onomyprotocol copy/dao/v1/params.proto | 30 + proto/onomyprotocol copy/dao/v1/query.proto | 44 + x/dao/types/codec.go | 33 + x/dao/types/dao.pb.go | 1337 +++++++++++++++++ x/dao/types/errors.go | 12 + x/dao/types/genesis.pb.go | 395 +++++ x/dao/types/keys.go | 18 + x/dao/types/params.pb.go | 454 ++++++ x/dao/types/proposal.go | 221 +++ x/dao/types/query.pb.go | 872 +++++++++++ x/dao/types/query.pb.gw.go | 218 +++ 15 files changed, 3725 insertions(+), 4 deletions(-) create mode 100644 proto/onomyprotocol copy/dao/v1/dao.proto create mode 100644 proto/onomyprotocol copy/dao/v1/genesis.proto create mode 100644 proto/onomyprotocol copy/dao/v1/params.proto create mode 100644 proto/onomyprotocol copy/dao/v1/query.proto create mode 100644 x/dao/types/codec.go create mode 100644 x/dao/types/dao.pb.go create mode 100644 x/dao/types/errors.go create mode 100644 x/dao/types/genesis.pb.go create mode 100644 x/dao/types/keys.go create mode 100644 x/dao/types/params.pb.go create mode 100644 x/dao/types/proposal.go create mode 100644 x/dao/types/query.pb.go create mode 100644 x/dao/types/query.pb.gw.go diff --git a/cmd/onomyd/cmd/cmd.go b/cmd/onomyd/cmd/cmd.go index 96358d24..aae75bca 100644 --- a/cmd/onomyd/cmd/cmd.go +++ b/cmd/onomyd/cmd/cmd.go @@ -28,6 +28,8 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ibcprovidertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + + daotypes "github.com/onomyprotocol/onomy/x/dao/types" ) // NewRootCmd initiates the cli for onomy chain. @@ -172,4 +174,5 @@ func RegisterInterfacesICSProvider(registry cdctypes.InterfaceRegistry) { (*govtypes.Content)(nil), &ibcprovidertypes.ConsumerAdditionProposal{}, ) + daotypes.RegisterInterfaces(registry) } diff --git a/go.mod b/go.mod index 91c36753..fc90b3e1 100644 --- a/go.mod +++ b/go.mod @@ -11,15 +11,15 @@ require ( github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-sdk v0.50.8 github.com/cosmos/ibc-go/v8 v8.3.2 - github.com/golang/protobuf v1.5.4 // indirect + github.com/golang/protobuf v1.5.4 github.com/gorilla/mux v1.8.1 // indirect - github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect + github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/spf13/cast v1.6.0 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect - google.golang.org/grpc v1.64.1 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 + google.golang.org/grpc v1.64.1 gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/proto/onomyprotocol copy/dao/v1/dao.proto b/proto/onomyprotocol copy/dao/v1/dao.proto new file mode 100644 index 00000000..30c1ae0a --- /dev/null +++ b/proto/onomyprotocol copy/dao/v1/dao.proto @@ -0,0 +1,65 @@ +syntax = "proto3"; +package onomyprotocol.dao.v1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/onomyprotocol/onomy/x/dao/types"; +option (gogoproto.equal_all) = true; + +// FundTreasuryProposal details a dao fund treasury proposal. +message FundTreasuryProposal { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string sender = 1; + string title = 2; + string description = 3; + repeated cosmos.base.v1beta1.Coin amount = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +// ExchangeWithTreasuryProposal details a dao exchange with treasury proposal. +message ExchangeWithTreasuryProposal { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string sender = 1; + string title = 2; + string description = 3; + repeated CoinsExchangePair coins_pairs = 4 [ + (gogoproto.moretags) = "yaml:\"coins_pairs\"", + (gogoproto.nullable) = false + ]; +} + +// CoinsExchangePair is an ask/bid coins pair to exchange. +message CoinsExchangePair { + cosmos.base.v1beta1.Coin coin_ask = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + cosmos.base.v1beta1.Coin coin_bid = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +// FundAccountProposal details a dao fund account proposal. +message FundAccountProposal { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string recipient = 1; + string title = 2; + string description = 3; + repeated cosmos.base.v1beta1.Coin amount = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} \ No newline at end of file diff --git a/proto/onomyprotocol copy/dao/v1/genesis.proto b/proto/onomyprotocol copy/dao/v1/genesis.proto new file mode 100644 index 00000000..e5424fe4 --- /dev/null +++ b/proto/onomyprotocol copy/dao/v1/genesis.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; +package onomyprotocol.dao.v1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "onomyprotocol/dao/v1/params.proto"; + +option go_package = "github.com/onomyprotocol/onomy/x/dao/types"; + +// GenesisState defines the dao module's genesis state. +message GenesisState { + // the dao module managed params + Params params = 1 [(gogoproto.nullable) = false]; + // the list of dao module coins + repeated cosmos.base.v1beta1.Coin treasury_balance = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} diff --git a/proto/onomyprotocol copy/dao/v1/params.proto b/proto/onomyprotocol copy/dao/v1/params.proto new file mode 100644 index 00000000..4d902712 --- /dev/null +++ b/proto/onomyprotocol copy/dao/v1/params.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; +package onomyprotocol.dao.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/onomyprotocol/onomy/x/dao/types"; + +// Params defines the parameters for the module. +message Params { + // option (gogoproto.goproto_stringer) = false; + + // the period of blocks to withdraw the dao staking reward + int64 withdraw_reward_period = 1 [(gogoproto.moretags) = "yaml:\"withdraw_reward_period\""]; + // the rate of total dao's staking coins to keep unstaked + bytes pool_rate = 2 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + // the max rage of total dao's staking coins to be allowed in proposals + bytes max_proposal_rate = 3 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + // the max validator's commission to be staked by the dao + bytes max_val_commission = 4 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + +} \ No newline at end of file diff --git a/proto/onomyprotocol copy/dao/v1/query.proto b/proto/onomyprotocol copy/dao/v1/query.proto new file mode 100644 index 00000000..cbd4804d --- /dev/null +++ b/proto/onomyprotocol copy/dao/v1/query.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; +package onomyprotocol.dao.v1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "google/api/annotations.proto"; +import "onomyprotocol/dao/v1/params.proto"; + +option go_package = "github.com/onomyprotocol/onomy/x/dao/types"; +option (gogoproto.goproto_stringer_all) = true; +option (gogoproto.goproto_getters_all) = false; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/onomyprotocol/dao/v1/params"; + } + + // Treasury queries the dao treasury. + rpc Treasury(QueryTreasuryRequest) returns (QueryTreasuryResponse) { + option (google.api.http).get = "/onomyprotocol/dao/v1/treasury"; + } +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryTreasuryRequest is request type for the Query/Treasury RPC method. +message QueryTreasuryRequest {} + +// QueryTreasuryResponse is response type for the Query/Treasury RPC method. +message QueryTreasuryResponse { + repeated cosmos.base.v1beta1.Coin treasury_balance = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} \ No newline at end of file diff --git a/x/dao/types/codec.go b/x/dao/types/codec.go new file mode 100644 index 00000000..15c1f7a7 --- /dev/null +++ b/x/dao/types/codec.go @@ -0,0 +1,33 @@ +package types + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" +) + +// RegisterCodec registers the legacy amino codec. +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&FundTreasuryProposal{}, fmt.Sprintf("%s/%s", ModuleName, ProposalTypeFundTreasuryProposal), nil) + cdc.RegisterConcrete(&ExchangeWithTreasuryProposal{}, fmt.Sprintf("%s/%s", ModuleName, ProposalTypeExchangeWithTreasuryProposal), nil) + cdc.RegisterConcrete(&FundAccountProposal{}, fmt.Sprintf("%s/%s", ModuleName, ProposalTypeFundAccountProposal), nil) +} + +// RegisterInterfaces registers the cdctypes interface. +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*govtypes.Content)(nil), + &FundTreasuryProposal{}, + &ExchangeWithTreasuryProposal{}, + &FundAccountProposal{}, + ) +} + +var ( + // Amino holds the LegacyAmino codec. + Amino = codec.NewLegacyAmino() //nolint:gochecknoglobals // cosmos sdk style + // ModuleCdc holds the default proto codec. + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) //nolint:gochecknoglobals // cosmos sdk style +) diff --git a/x/dao/types/dao.pb.go b/x/dao/types/dao.pb.go new file mode 100644 index 00000000..025ffee8 --- /dev/null +++ b/x/dao/types/dao.pb.go @@ -0,0 +1,1337 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: onomyprotocol/dao/v1/dao.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/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 + +// FundTreasuryProposal details a dao fund treasury proposal. +type FundTreasuryProposal struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *FundTreasuryProposal) Reset() { *m = FundTreasuryProposal{} } +func (*FundTreasuryProposal) ProtoMessage() {} +func (*FundTreasuryProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_763c2cafbce2acfd, []int{0} +} +func (m *FundTreasuryProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FundTreasuryProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FundTreasuryProposal.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 *FundTreasuryProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_FundTreasuryProposal.Merge(m, src) +} +func (m *FundTreasuryProposal) XXX_Size() int { + return m.Size() +} +func (m *FundTreasuryProposal) XXX_DiscardUnknown() { + xxx_messageInfo_FundTreasuryProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_FundTreasuryProposal proto.InternalMessageInfo + +// ExchangeWithTreasuryProposal details a dao exchange with treasury proposal. +type ExchangeWithTreasuryProposal struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + CoinsPairs []CoinsExchangePair `protobuf:"bytes,4,rep,name=coins_pairs,json=coinsPairs,proto3" json:"coins_pairs" yaml:"coins_pairs"` +} + +func (m *ExchangeWithTreasuryProposal) Reset() { *m = ExchangeWithTreasuryProposal{} } +func (*ExchangeWithTreasuryProposal) ProtoMessage() {} +func (*ExchangeWithTreasuryProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_763c2cafbce2acfd, []int{1} +} +func (m *ExchangeWithTreasuryProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExchangeWithTreasuryProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExchangeWithTreasuryProposal.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 *ExchangeWithTreasuryProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExchangeWithTreasuryProposal.Merge(m, src) +} +func (m *ExchangeWithTreasuryProposal) XXX_Size() int { + return m.Size() +} +func (m *ExchangeWithTreasuryProposal) XXX_DiscardUnknown() { + xxx_messageInfo_ExchangeWithTreasuryProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_ExchangeWithTreasuryProposal proto.InternalMessageInfo + +// CoinsExchangePair is an ask/bid coins pair to exchange. +type CoinsExchangePair struct { + CoinAsk types.Coin `protobuf:"bytes,1,opt,name=coin_ask,json=coinAsk,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coin_ask"` + CoinBid types.Coin `protobuf:"bytes,2,opt,name=coin_bid,json=coinBid,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coin_bid"` +} + +func (m *CoinsExchangePair) Reset() { *m = CoinsExchangePair{} } +func (m *CoinsExchangePair) String() string { return proto.CompactTextString(m) } +func (*CoinsExchangePair) ProtoMessage() {} +func (*CoinsExchangePair) Descriptor() ([]byte, []int) { + return fileDescriptor_763c2cafbce2acfd, []int{2} +} +func (m *CoinsExchangePair) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CoinsExchangePair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CoinsExchangePair.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 *CoinsExchangePair) XXX_Merge(src proto.Message) { + xxx_messageInfo_CoinsExchangePair.Merge(m, src) +} +func (m *CoinsExchangePair) XXX_Size() int { + return m.Size() +} +func (m *CoinsExchangePair) XXX_DiscardUnknown() { + xxx_messageInfo_CoinsExchangePair.DiscardUnknown(m) +} + +var xxx_messageInfo_CoinsExchangePair proto.InternalMessageInfo + +func (m *CoinsExchangePair) GetCoinAsk() types.Coin { + if m != nil { + return m.CoinAsk + } + return types.Coin{} +} + +func (m *CoinsExchangePair) GetCoinBid() types.Coin { + if m != nil { + return m.CoinBid + } + return types.Coin{} +} + +// FundAccountProposal details a dao fund account proposal. +type FundAccountProposal struct { + Recipient string `protobuf:"bytes,1,opt,name=recipient,proto3" json:"recipient,omitempty"` + Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *FundAccountProposal) Reset() { *m = FundAccountProposal{} } +func (*FundAccountProposal) ProtoMessage() {} +func (*FundAccountProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_763c2cafbce2acfd, []int{3} +} +func (m *FundAccountProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FundAccountProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FundAccountProposal.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 *FundAccountProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_FundAccountProposal.Merge(m, src) +} +func (m *FundAccountProposal) XXX_Size() int { + return m.Size() +} +func (m *FundAccountProposal) XXX_DiscardUnknown() { + xxx_messageInfo_FundAccountProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_FundAccountProposal proto.InternalMessageInfo + +func init() { + proto.RegisterType((*FundTreasuryProposal)(nil), "onomyprotocol.dao.v1.FundTreasuryProposal") + proto.RegisterType((*ExchangeWithTreasuryProposal)(nil), "onomyprotocol.dao.v1.ExchangeWithTreasuryProposal") + proto.RegisterType((*CoinsExchangePair)(nil), "onomyprotocol.dao.v1.CoinsExchangePair") + proto.RegisterType((*FundAccountProposal)(nil), "onomyprotocol.dao.v1.FundAccountProposal") +} + +func init() { proto.RegisterFile("onomyprotocol/dao/v1/dao.proto", fileDescriptor_763c2cafbce2acfd) } + +var fileDescriptor_763c2cafbce2acfd = []byte{ + // 459 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x54, 0x31, 0x6f, 0x13, 0x31, + 0x14, 0x3e, 0x53, 0x08, 0xd4, 0x61, 0xe1, 0x88, 0x50, 0x88, 0x2a, 0x5f, 0x74, 0x0b, 0x19, 0xe0, + 0x4c, 0x60, 0xeb, 0xd6, 0x20, 0x18, 0x98, 0xaa, 0x08, 0x09, 0x89, 0xa5, 0xf2, 0xf9, 0x4c, 0x62, + 0x25, 0xe7, 0x77, 0xb2, 0x9d, 0xa8, 0xf9, 0x07, 0x8c, 0x8c, 0x8c, 0x19, 0x11, 0xbf, 0xa4, 0x63, + 0x47, 0x58, 0x02, 0xba, 0x5b, 0x98, 0xf9, 0x05, 0xc8, 0xbe, 0xa3, 0xa4, 0xc0, 0x48, 0x86, 0x4e, + 0xf6, 0x7b, 0x9f, 0xfd, 0xbd, 0xef, 0x7b, 0xcf, 0x32, 0x26, 0xa0, 0x20, 0x5f, 0x15, 0x1a, 0x2c, + 0x70, 0x98, 0xd3, 0x8c, 0x01, 0x5d, 0x0e, 0xdd, 0x92, 0xf8, 0x5c, 0xd8, 0xb9, 0x84, 0x27, 0x0e, + 0x58, 0x0e, 0x7b, 0x9d, 0x09, 0x4c, 0xc0, 0x27, 0xa9, 0xdb, 0xd5, 0x67, 0x7b, 0x84, 0x83, 0xc9, + 0xc1, 0xd0, 0x94, 0x19, 0x41, 0x97, 0xc3, 0x54, 0x58, 0x36, 0xa4, 0x1c, 0xa4, 0xaa, 0xf1, 0xf8, + 0x0b, 0xc2, 0x9d, 0x17, 0x0b, 0x95, 0xbd, 0xd2, 0x82, 0x99, 0x85, 0x5e, 0x1d, 0x6b, 0x28, 0xc0, + 0xb0, 0x79, 0x78, 0x0f, 0xb7, 0x8c, 0x50, 0x99, 0xd0, 0x5d, 0xd4, 0x47, 0x83, 0xfd, 0x71, 0x13, + 0x85, 0x1d, 0x7c, 0xc3, 0x4a, 0x3b, 0x17, 0xdd, 0x6b, 0x3e, 0x5d, 0x07, 0x61, 0x1f, 0xb7, 0x33, + 0x61, 0xb8, 0x96, 0x85, 0x95, 0xa0, 0xba, 0x7b, 0x1e, 0xdb, 0x4e, 0x85, 0x1c, 0xb7, 0x58, 0x0e, + 0x0b, 0x65, 0xbb, 0xd7, 0xfb, 0x7b, 0x83, 0xf6, 0x93, 0xfb, 0x49, 0xad, 0x2c, 0x71, 0xca, 0x92, + 0x46, 0x59, 0xf2, 0x0c, 0xa4, 0x1a, 0x3d, 0x3e, 0xdb, 0x44, 0xc1, 0xa7, 0xaf, 0xd1, 0x60, 0x22, + 0xed, 0x74, 0x91, 0x26, 0x1c, 0x72, 0xda, 0xd8, 0xa8, 0x97, 0x47, 0x26, 0x9b, 0x51, 0xbb, 0x2a, + 0x84, 0xf1, 0x17, 0xcc, 0xb8, 0xa1, 0x3e, 0xbc, 0xfd, 0x6e, 0x1d, 0x05, 0x1f, 0xd6, 0x51, 0xf0, + 0x7d, 0x1d, 0x05, 0x71, 0x89, 0xf0, 0xc1, 0xf3, 0x53, 0x3e, 0x65, 0x6a, 0x22, 0x5e, 0x4b, 0x3b, + 0xdd, 0xb9, 0xc7, 0x0c, 0xb7, 0x5d, 0x6b, 0xcd, 0x49, 0xc1, 0xa4, 0x36, 0x8d, 0xd1, 0x07, 0xc9, + 0xbf, 0xc6, 0x55, 0x0b, 0xff, 0xa5, 0xee, 0x98, 0x49, 0x3d, 0xea, 0x39, 0xdb, 0x3f, 0x36, 0x51, + 0xb8, 0x62, 0xf9, 0xfc, 0x30, 0xde, 0x62, 0x8a, 0xc7, 0xd8, 0x47, 0xee, 0x98, 0xf9, 0xc3, 0x64, + 0x85, 0xf0, 0x9d, 0xbf, 0xb8, 0xc2, 0xb7, 0xf8, 0x96, 0xbb, 0x71, 0xc2, 0xcc, 0xcc, 0x7b, 0xfb, + 0xcf, 0xfd, 0xbe, 0xe9, 0xc8, 0x8f, 0xcc, 0xec, 0xa2, 0x4e, 0x2a, 0x33, 0xdf, 0xac, 0x5d, 0xd4, + 0x19, 0xc9, 0x2c, 0xde, 0x20, 0x7c, 0xd7, 0x3d, 0xd3, 0x23, 0xce, 0xdd, 0xa0, 0x2f, 0x26, 0x78, + 0x80, 0xf7, 0xb5, 0xe0, 0xb2, 0x90, 0x42, 0xd9, 0x66, 0x88, 0xbf, 0x13, 0x57, 0xe8, 0xad, 0x8e, + 0x5e, 0x7e, 0x2c, 0x09, 0x3a, 0x2b, 0x09, 0x3a, 0x2f, 0x09, 0xfa, 0x56, 0x12, 0xf4, 0xbe, 0x22, + 0xc1, 0x79, 0x45, 0x82, 0xcf, 0x15, 0x09, 0xde, 0x3c, 0xdc, 0x62, 0xbf, 0xfc, 0x39, 0x68, 0x61, + 0x84, 0x5e, 0x0a, 0x7a, 0xea, 0xbf, 0x09, 0x5f, 0x27, 0x6d, 0x79, 0xf4, 0xe9, 0xcf, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xe9, 0x42, 0xe6, 0xca, 0x48, 0x04, 0x00, 0x00, +} + +func (this *CoinsExchangePair) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*CoinsExchangePair) + if !ok { + that2, ok := that.(CoinsExchangePair) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.CoinAsk.Equal(&that1.CoinAsk) { + return false + } + if !this.CoinBid.Equal(&that1.CoinBid) { + return false + } + return true +} +func (m *FundTreasuryProposal) 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 *FundTreasuryProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FundTreasuryProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDao(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintDao(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x1a + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintDao(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintDao(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ExchangeWithTreasuryProposal) 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 *ExchangeWithTreasuryProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExchangeWithTreasuryProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CoinsPairs) > 0 { + for iNdEx := len(m.CoinsPairs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CoinsPairs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDao(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintDao(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x1a + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintDao(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintDao(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CoinsExchangePair) 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 *CoinsExchangePair) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CoinsExchangePair) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.CoinBid.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDao(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.CoinAsk.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDao(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *FundAccountProposal) 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 *FundAccountProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FundAccountProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDao(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintDao(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x1a + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintDao(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0x12 + } + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintDao(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintDao(dAtA []byte, offset int, v uint64) int { + offset -= sovDao(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *FundTreasuryProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovDao(uint64(l)) + } + l = len(m.Title) + if l > 0 { + n += 1 + l + sovDao(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovDao(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovDao(uint64(l)) + } + } + return n +} + +func (m *ExchangeWithTreasuryProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovDao(uint64(l)) + } + l = len(m.Title) + if l > 0 { + n += 1 + l + sovDao(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovDao(uint64(l)) + } + if len(m.CoinsPairs) > 0 { + for _, e := range m.CoinsPairs { + l = e.Size() + n += 1 + l + sovDao(uint64(l)) + } + } + return n +} + +func (m *CoinsExchangePair) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.CoinAsk.Size() + n += 1 + l + sovDao(uint64(l)) + l = m.CoinBid.Size() + n += 1 + l + sovDao(uint64(l)) + return n +} + +func (m *FundAccountProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovDao(uint64(l)) + } + l = len(m.Title) + if l > 0 { + n += 1 + l + sovDao(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovDao(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovDao(uint64(l)) + } + } + return n +} + +func sovDao(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDao(x uint64) (n int) { + return sovDao(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *FundTreasuryProposal) 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 ErrIntOverflowDao + } + 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: FundTreasuryProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FundTreasuryProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDao + } + 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 ErrInvalidLengthDao + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDao + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDao + } + 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 ErrInvalidLengthDao + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDao + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDao + } + 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 ErrInvalidLengthDao + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDao + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDao + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDao + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDao + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDao(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDao + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ExchangeWithTreasuryProposal) 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 ErrIntOverflowDao + } + 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: ExchangeWithTreasuryProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExchangeWithTreasuryProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDao + } + 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 ErrInvalidLengthDao + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDao + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDao + } + 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 ErrInvalidLengthDao + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDao + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDao + } + 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 ErrInvalidLengthDao + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDao + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CoinsPairs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDao + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDao + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDao + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CoinsPairs = append(m.CoinsPairs, CoinsExchangePair{}) + if err := m.CoinsPairs[len(m.CoinsPairs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDao(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDao + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CoinsExchangePair) 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 ErrIntOverflowDao + } + 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: CoinsExchangePair: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CoinsExchangePair: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CoinAsk", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDao + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDao + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDao + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CoinAsk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CoinBid", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDao + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDao + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDao + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CoinBid.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDao(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDao + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FundAccountProposal) 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 ErrIntOverflowDao + } + 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: FundAccountProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FundAccountProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recipient", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDao + } + 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 ErrInvalidLengthDao + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDao + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Recipient = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDao + } + 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 ErrInvalidLengthDao + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDao + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDao + } + 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 ErrInvalidLengthDao + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDao + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDao + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDao + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDao + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDao(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDao + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDao(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, ErrIntOverflowDao + } + 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, ErrIntOverflowDao + } + 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, ErrIntOverflowDao + } + 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, ErrInvalidLengthDao + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDao + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDao + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDao = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDao = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDao = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/dao/types/errors.go b/x/dao/types/errors.go new file mode 100644 index 00000000..e250da9d --- /dev/null +++ b/x/dao/types/errors.go @@ -0,0 +1,12 @@ +package types + +import sdkerrors "cosmossdk.io/errors" + +var ( + // ErrInsufficientBalance - the balance is insufficient for the operation. + ErrInsufficientBalance = sdkerrors.Register(ModuleName, 1, "insufficient balance") + // ErrInvalidCoinsPair - the coins pair is invalid. + ErrInvalidCoinsPair = sdkerrors.Register(ModuleName, 2, "invalid coins pair") //nolint:gomnd // error number + // ErrProhibitedCoinsAmount - the requested amount is prohibited. + ErrProhibitedCoinsAmount = sdkerrors.Register(ModuleName, 3, "prohibited coins amount") //nolint:gomnd // error number +) diff --git a/x/dao/types/genesis.pb.go b/x/dao/types/genesis.pb.go new file mode 100644 index 00000000..d19aec38 --- /dev/null +++ b/x/dao/types/genesis.pb.go @@ -0,0 +1,395 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: onomyprotocol/dao/v1/genesis.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/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 + +// GenesisState defines the dao module's genesis state. +type GenesisState struct { + // the dao module managed params + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // the list of dao module coins + TreasuryBalance github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=treasury_balance,json=treasuryBalance,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"treasury_balance"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_de36a61e75260a5e, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetTreasuryBalance() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TreasuryBalance + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "onomyprotocol.dao.v1.GenesisState") +} + +func init() { + proto.RegisterFile("onomyprotocol/dao/v1/genesis.proto", fileDescriptor_de36a61e75260a5e) +} + +var fileDescriptor_de36a61e75260a5e = []byte{ + // 298 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xb1, 0x4e, 0xc3, 0x30, + 0x10, 0x86, 0x63, 0x40, 0x1d, 0x52, 0x24, 0x50, 0xd5, 0xa1, 0x54, 0xc8, 0x2d, 0x9d, 0x32, 0x80, + 0x4d, 0xca, 0xc6, 0x18, 0x24, 0x58, 0x51, 0xd9, 0x58, 0x90, 0x93, 0x9c, 0x42, 0x44, 0x93, 0x8b, + 0x6c, 0x37, 0x22, 0x6f, 0xc1, 0x73, 0xf0, 0x18, 0x4c, 0x1d, 0x3b, 0x32, 0x01, 0x4a, 0x5e, 0x04, + 0xc5, 0x0e, 0x12, 0x95, 0x3a, 0xd9, 0xba, 0xfb, 0xef, 0xff, 0xbf, 0x3b, 0x77, 0x86, 0x39, 0x66, + 0x55, 0x21, 0x51, 0x63, 0x84, 0x4b, 0x1e, 0x0b, 0xe4, 0xa5, 0xcf, 0x13, 0xc8, 0x41, 0xa5, 0x8a, + 0x99, 0xfa, 0x60, 0xb8, 0xa5, 0x61, 0xb1, 0x40, 0x56, 0xfa, 0xe3, 0x61, 0x82, 0x09, 0x9a, 0x22, + 0x6f, 0x7f, 0x56, 0x3b, 0xa6, 0x11, 0xaa, 0x0c, 0x15, 0x0f, 0x85, 0x02, 0x5e, 0xfa, 0x21, 0x68, + 0xe1, 0xf3, 0x08, 0xd3, 0xbc, 0xeb, 0x9f, 0xed, 0xcc, 0x2b, 0x84, 0x14, 0x59, 0x17, 0x37, 0xfb, + 0x20, 0xee, 0xe1, 0x9d, 0x05, 0x78, 0xd0, 0x42, 0xc3, 0xe0, 0xda, 0xed, 0x59, 0xc1, 0x88, 0x4c, + 0x89, 0xd7, 0x9f, 0x9f, 0xb2, 0x5d, 0x40, 0xec, 0xde, 0x68, 0x82, 0x83, 0xf5, 0xd7, 0xc4, 0x59, + 0x74, 0x13, 0x83, 0xd2, 0x3d, 0xd6, 0x12, 0x84, 0x5a, 0xc9, 0xea, 0x29, 0x14, 0x4b, 0x91, 0x47, + 0x30, 0xda, 0x9b, 0xee, 0x7b, 0xfd, 0xf9, 0x09, 0xb3, 0xa8, 0xac, 0x45, 0x65, 0x1d, 0x2a, 0xbb, + 0xc1, 0x34, 0x0f, 0x2e, 0x5b, 0x8b, 0xf7, 0xef, 0x89, 0x97, 0xa4, 0xfa, 0x79, 0x15, 0xb2, 0x08, + 0x33, 0xde, 0xed, 0x65, 0x9f, 0x0b, 0x15, 0xbf, 0x70, 0x5d, 0x15, 0xa0, 0xcc, 0x80, 0x5a, 0x1c, + 0xfd, 0x85, 0x04, 0x36, 0x23, 0xb8, 0x5d, 0xd7, 0x94, 0x6c, 0x6a, 0x4a, 0x7e, 0x6a, 0x4a, 0xde, + 0x1a, 0xea, 0x6c, 0x1a, 0xea, 0x7c, 0x36, 0xd4, 0x79, 0x3c, 0xff, 0x67, 0xba, 0x7d, 0x0c, 0x09, + 0x0a, 0x64, 0x09, 0xfc, 0xd5, 0x9c, 0xc5, 0xd8, 0x87, 0x3d, 0xd3, 0xbd, 0xfa, 0x0d, 0x00, 0x00, + 0xff, 0xff, 0x26, 0x6a, 0xb6, 0x43, 0xa8, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TreasuryBalance) > 0 { + for iNdEx := len(m.TreasuryBalance) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TreasuryBalance[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.TreasuryBalance) > 0 { + for _, e := range m.TreasuryBalance { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TreasuryBalance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TreasuryBalance = append(m.TreasuryBalance, types.Coin{}) + if err := m.TreasuryBalance[len(m.TreasuryBalance)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/dao/types/keys.go b/x/dao/types/keys.go new file mode 100644 index 00000000..8300d61b --- /dev/null +++ b/x/dao/types/keys.go @@ -0,0 +1,18 @@ +package types + +const ( + // ModuleName defines the module name. + ModuleName = "dao" + + // StoreKey defines the primary module store key. + StoreKey = ModuleName + + // RouterKey is the message route for slashing. + RouterKey = ModuleName + + // QuerierRoute defines the module's query routing key. + QuerierRoute = ModuleName + + // MemStoreKey defines the in-memory store key. + MemStoreKey = "mem_dao" +) diff --git a/x/dao/types/params.pb.go b/x/dao/types/params.pb.go new file mode 100644 index 00000000..e97573b3 --- /dev/null +++ b/x/dao/types/params.pb.go @@ -0,0 +1,454 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: onomyprotocol/dao/v1/params.proto + +package types + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "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 + +// Params defines the parameters for the module. +type Params struct { + // the period of blocks to withdraw the dao staking reward + WithdrawRewardPeriod int64 `protobuf:"varint,1,opt,name=withdraw_reward_period,json=withdrawRewardPeriod,proto3" json:"withdraw_reward_period,omitempty" yaml:"withdraw_reward_period"` + // the rate of total dao's staking coins to keep unstaked + PoolRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=pool_rate,json=poolRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"pool_rate"` + // the max rage of total dao's staking coins to be allowed in proposals + MaxProposalRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=max_proposal_rate,json=maxProposalRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"max_proposal_rate"` + // the max validator's commission to be staked by the dao + MaxValCommission cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=max_val_commission,json=maxValCommission,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"max_val_commission"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_1367893a600edc4a, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetWithdrawRewardPeriod() int64 { + if m != nil { + return m.WithdrawRewardPeriod + } + return 0 +} + +func init() { + proto.RegisterType((*Params)(nil), "onomyprotocol.dao.v1.Params") +} + +func init() { proto.RegisterFile("onomyprotocol/dao/v1/params.proto", fileDescriptor_1367893a600edc4a) } + +var fileDescriptor_1367893a600edc4a = []byte{ + // 326 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xcd, 0x4a, 0xc3, 0x40, + 0x14, 0x85, 0x93, 0x56, 0x8a, 0x06, 0x41, 0x0d, 0x45, 0x8a, 0x62, 0xfa, 0xe3, 0xa6, 0x0b, 0xc9, + 0x50, 0xdc, 0xb9, 0x92, 0x2a, 0xae, 0x04, 0x6b, 0x16, 0x0a, 0x6e, 0xc2, 0x6d, 0x32, 0xa4, 0x83, + 0x99, 0xde, 0x61, 0x66, 0x4c, 0x93, 0xb7, 0xf0, 0xad, 0xec, 0xb2, 0x4b, 0x71, 0x51, 0xa4, 0x7d, + 0x03, 0x9f, 0x40, 0x32, 0x56, 0xa1, 0xe0, 0xa2, 0xbb, 0xcb, 0xb9, 0xe7, 0xfb, 0x36, 0xc7, 0x69, + 0xe3, 0x18, 0x79, 0x21, 0x24, 0x6a, 0x8c, 0x30, 0x25, 0x31, 0x20, 0xc9, 0x7a, 0x44, 0x80, 0x04, + 0xae, 0x7c, 0x13, 0xbb, 0xf5, 0xb5, 0x8a, 0x1f, 0x03, 0xfa, 0x59, 0xef, 0xa8, 0x9e, 0x60, 0x82, + 0x26, 0x24, 0xe5, 0xf5, 0xd3, 0xed, 0xbc, 0x55, 0x9c, 0xda, 0xc0, 0xc0, 0xee, 0xa3, 0x73, 0x38, + 0x61, 0x7a, 0x14, 0x4b, 0x98, 0x84, 0x92, 0x4e, 0x40, 0xc6, 0xa1, 0xa0, 0x92, 0x61, 0xdc, 0xb0, + 0x5b, 0x76, 0xb7, 0xda, 0x6f, 0x7f, 0xcd, 0x9b, 0x27, 0x05, 0xf0, 0xf4, 0xa2, 0xf3, 0x7f, 0xaf, + 0x13, 0xd4, 0x7f, 0x1f, 0x81, 0xc9, 0x07, 0x26, 0x76, 0x2f, 0x9d, 0x1d, 0x81, 0x98, 0x86, 0x12, + 0x34, 0x6d, 0x54, 0x5a, 0x76, 0x77, 0xb7, 0x7f, 0x3a, 0x9d, 0x37, 0xad, 0x8f, 0x79, 0xf3, 0x38, + 0x42, 0xc5, 0x51, 0xa9, 0xf8, 0xd9, 0x67, 0x48, 0x38, 0xe8, 0x91, 0x7f, 0x4b, 0x13, 0x88, 0x8a, + 0x6b, 0x1a, 0x05, 0xdb, 0x25, 0x15, 0x80, 0xa6, 0xee, 0x9d, 0x73, 0xc0, 0x21, 0x0f, 0x85, 0x44, + 0x81, 0x0a, 0x56, 0xa6, 0xea, 0xe6, 0xa6, 0x3d, 0x0e, 0xf9, 0x60, 0x05, 0x1b, 0xe1, 0xbd, 0xe3, + 0x96, 0xc2, 0x0c, 0xd2, 0x30, 0x42, 0xce, 0x99, 0x52, 0x0c, 0xc7, 0x8d, 0xad, 0xcd, 0x8d, 0xfb, + 0x1c, 0xf2, 0x07, 0x48, 0xaf, 0xfe, 0xe0, 0xfe, 0xcd, 0x74, 0xe1, 0xd9, 0xb3, 0x85, 0x67, 0x7f, + 0x2e, 0x3c, 0xfb, 0x75, 0xe9, 0x59, 0xb3, 0xa5, 0x67, 0xbd, 0x2f, 0x3d, 0xeb, 0xe9, 0x2c, 0x61, + 0x7a, 0xf4, 0x32, 0xf4, 0x23, 0xe4, 0x64, 0x7d, 0x3d, 0x49, 0x15, 0x95, 0x19, 0x25, 0xb9, 0xd9, + 0x51, 0x17, 0x82, 0xaa, 0x61, 0xcd, 0x7c, 0xcf, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x85, 0xa3, + 0x5d, 0x65, 0xe9, 0x01, 0x00, 0x00, +} + +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.MaxValCommission.Size() + i -= size + if _, err := m.MaxValCommission.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.MaxProposalRate.Size() + i -= size + if _, err := m.MaxProposalRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.PoolRate.Size() + i -= size + if _, err := m.PoolRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.WithdrawRewardPeriod != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.WithdrawRewardPeriod)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.WithdrawRewardPeriod != 0 { + n += 1 + sovParams(uint64(m.WithdrawRewardPeriod)) + } + l = m.PoolRate.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.MaxProposalRate.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.MaxValCommission.Size() + n += 1 + l + sovParams(uint64(l)) + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowParams + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field WithdrawRewardPeriod", wireType) + } + m.WithdrawRewardPeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.WithdrawRewardPeriod |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolRate", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PoolRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxProposalRate", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MaxProposalRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxValCommission", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MaxValCommission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/dao/types/proposal.go b/x/dao/types/proposal.go new file mode 100644 index 00000000..e388b09c --- /dev/null +++ b/x/dao/types/proposal.go @@ -0,0 +1,221 @@ +package types + +import ( + "fmt" + "strings" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" +) + +const ( + // ProposalTypeFundTreasuryProposal defines the type for a FundTreasuryProposal. + ProposalTypeFundTreasuryProposal = "FundTreasuryProposal" + // ProposalTypeExchangeWithTreasuryProposal defines the type for a ExchangeWithTreasuryProposal. + ProposalTypeExchangeWithTreasuryProposal = "ExchangeWithTreasuryProposal" + // ProposalTypeFundAccountProposal defines the type for a FundAccountProposal. + ProposalTypeFundAccountProposal = "FundAccountProposal" +) + +var ( + _ govtypes.Content = &FundTreasuryProposal{} + _ govtypes.Content = &ExchangeWithTreasuryProposal{} + _ govtypes.Content = &FundAccountProposal{} +) + +func init() { //nolint:gochecknoinits // cosmos sdk style + govtypes.RegisterProposalType(ProposalTypeFundTreasuryProposal) + govtypes.RegisterProposalType(ProposalTypeExchangeWithTreasuryProposal) + govtypes.RegisterProposalType(ProposalTypeFundAccountProposal) +} + +// NewFundTreasuryProposal creates a new fund treasury proposal. +func NewFundTreasuryProposal(sender sdk.AccAddress, title, description string, amount sdk.Coins) *FundTreasuryProposal { + return &FundTreasuryProposal{sender.String(), title, description, amount} +} + +// GetTitle returns the title of a fund treasury proposal. +func (m *FundTreasuryProposal) GetTitle() string { return m.Title } + +// GetDescription returns the description of a fund treasury proposal. +func (m *FundTreasuryProposal) GetDescription() string { return m.Description } + +// ProposalRoute returns the routing key of a fund treasury proposal. +func (m *FundTreasuryProposal) ProposalRoute() string { return RouterKey } + +// ProposalType returns the type of the fund treasury proposal. +func (m *FundTreasuryProposal) ProposalType() string { return ProposalTypeFundTreasuryProposal } + +// ValidateBasic runs basic stateless validity checks. +func (m *FundTreasuryProposal) ValidateBasic() error { + err := govtypes.ValidateAbstract(m) + if err != nil { + return err + } + sender, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + if err := sdk.VerifyAddressFormat(sender); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address: %s", err) + } + + if !m.Amount.IsValid() { + return errors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) + } + + if !m.Amount.IsAllPositive() { + return errors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) + } + + return nil +} + +// GetProposer returns the proposer from the proposal struct. +func (m *FundTreasuryProposal) GetProposer() string { return m.Sender } + +// String implements the Stringer interface. +func (m FundTreasuryProposal) String() string { + var b strings.Builder + b.WriteString(fmt.Sprintf(`Fund treasury proposal: + Sender: %s + Title: %s + Description: %s + Amount: %s +`, m.Sender, m.Title, m.Description, m.Amount)) + return b.String() +} + +// NewExchangeWithTreasuryProposal creates a new fund treasury proposal. +func NewExchangeWithTreasuryProposal(sender sdk.AccAddress, title, description string, coinsPairs []CoinsExchangePair) *ExchangeWithTreasuryProposal { + return &ExchangeWithTreasuryProposal{sender.String(), title, description, coinsPairs} +} + +// GetTitle returns the title of a fund treasury proposal. +func (m *ExchangeWithTreasuryProposal) GetTitle() string { return m.Title } + +// GetDescription returns the description of a fund treasury proposal. +func (m *ExchangeWithTreasuryProposal) GetDescription() string { return m.Description } + +// ProposalRoute returns the routing key of a fund treasury proposal. +func (m *ExchangeWithTreasuryProposal) ProposalRoute() string { return RouterKey } + +// ProposalType returns the type of the fund treasury proposal. +func (m *ExchangeWithTreasuryProposal) ProposalType() string { + return ProposalTypeExchangeWithTreasuryProposal +} + +// ValidateBasic runs basic stateless validity checks. +func (m *ExchangeWithTreasuryProposal) ValidateBasic() error { + err := govtypes.ValidateAbstract(m) + if err != nil { + return err + } + sender, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + if err := sdk.VerifyAddressFormat(sender); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address: %s", err) + } + + if len(m.CoinsPairs) == 0 { + return errors.Wrapf(ErrInvalidCoinsPair, "coins pairs can't be empty") + } + + for i := range m.CoinsPairs { + if err := m.CoinsPairs[i].ValidateBasic(); err != nil { + return err + } + } + + return nil +} + +// GetProposer returns the proposer from the proposal struct. +func (m *ExchangeWithTreasuryProposal) GetProposer() string { return m.Sender } + +// String implements the Stringer interface. +func (m ExchangeWithTreasuryProposal) String() string { + var b strings.Builder + b.WriteString(fmt.Sprintf(`Exchange with treasury proposal: + Sender: %s + Title: %s + Description: %s + Coin Pairs: %s +`, m.Sender, m.Title, m.Description, m.CoinsPairs)) + return b.String() +} + +// ValidateBasic validates CoinsExchangePair basic options. +func (m *CoinsExchangePair) ValidateBasic() error { + if m == nil { + return errors.Wrapf(ErrInvalidCoinsPair, "coins pairs can't be nil") + } + + if !m.CoinAsk.IsValid() || m.CoinAsk.IsZero() { + return errors.Wrapf(ErrInvalidCoinsPair, "invalid coin ask") + } + + if !m.CoinBid.IsValid() || m.CoinBid.IsZero() { + return errors.Wrapf(ErrInvalidCoinsPair, "invalid coin bid") + } + + return nil +} + +// NewFundAccountProposal creates a new fund account proposal. +func NewFundAccountProposal(recipient sdk.AccAddress, title, description string, amount sdk.Coins) *FundAccountProposal { + return &FundAccountProposal{recipient.String(), title, description, amount} +} + +// GetTitle returns the title of a fund account proposal. +func (m *FundAccountProposal) GetTitle() string { return m.Title } + +// GetDescription returns the description of a fund account proposal. +func (m *FundAccountProposal) GetDescription() string { return m.Description } + +// ProposalRoute returns the routing key of a fund account proposal. +func (m *FundAccountProposal) ProposalRoute() string { return RouterKey } + +// ProposalType returns the type of the fund account proposal. +func (m *FundAccountProposal) ProposalType() string { return ProposalTypeFundAccountProposal } + +// ValidateBasic runs basic stateless validity checks. +func (m *FundAccountProposal) ValidateBasic() error { + err := govtypes.ValidateAbstract(m) + if err != nil { + return err + } + sender, err := sdk.AccAddressFromBech32(m.Recipient) + if err != nil { + return err + } + if err := sdk.VerifyAddressFormat(sender); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address: %s", err) + } + + if !m.Amount.IsValid() { + return errors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) + } + + if !m.Amount.IsAllPositive() { + return errors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) + } + + return nil +} + +// String implements the Stringer interface. +func (m FundAccountProposal) String() string { + var b strings.Builder + b.WriteString(fmt.Sprintf(`Fund account proposal: + Recipient: %s + Title: %s + Description: %s + Amount: %s +`, m.Recipient, m.Title, m.Description, m.Amount)) + return b.String() +} diff --git a/x/dao/types/query.pb.go b/x/dao/types/query.pb.go new file mode 100644 index 00000000..f780a6bf --- /dev/null +++ b/x/dao/types/query.pb.go @@ -0,0 +1,872 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: onomyprotocol/dao/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1d6940140b83f0f7, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1d6940140b83f0f7, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +// QueryTreasuryRequest is request type for the Query/Treasury RPC method. +type QueryTreasuryRequest struct { +} + +func (m *QueryTreasuryRequest) Reset() { *m = QueryTreasuryRequest{} } +func (m *QueryTreasuryRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTreasuryRequest) ProtoMessage() {} +func (*QueryTreasuryRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1d6940140b83f0f7, []int{2} +} +func (m *QueryTreasuryRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTreasuryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTreasuryRequest.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 *QueryTreasuryRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTreasuryRequest.Merge(m, src) +} +func (m *QueryTreasuryRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTreasuryRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTreasuryRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTreasuryRequest proto.InternalMessageInfo + +// QueryTreasuryResponse is response type for the Query/Treasury RPC method. +type QueryTreasuryResponse struct { + TreasuryBalance github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=treasury_balance,json=treasuryBalance,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"treasury_balance"` +} + +func (m *QueryTreasuryResponse) Reset() { *m = QueryTreasuryResponse{} } +func (m *QueryTreasuryResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTreasuryResponse) ProtoMessage() {} +func (*QueryTreasuryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1d6940140b83f0f7, []int{3} +} +func (m *QueryTreasuryResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTreasuryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTreasuryResponse.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 *QueryTreasuryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTreasuryResponse.Merge(m, src) +} +func (m *QueryTreasuryResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTreasuryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTreasuryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTreasuryResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "onomyprotocol.dao.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "onomyprotocol.dao.v1.QueryParamsResponse") + proto.RegisterType((*QueryTreasuryRequest)(nil), "onomyprotocol.dao.v1.QueryTreasuryRequest") + proto.RegisterType((*QueryTreasuryResponse)(nil), "onomyprotocol.dao.v1.QueryTreasuryResponse") +} + +func init() { proto.RegisterFile("onomyprotocol/dao/v1/query.proto", fileDescriptor_1d6940140b83f0f7) } + +var fileDescriptor_1d6940140b83f0f7 = []byte{ + // 428 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xcf, 0x8e, 0xd3, 0x30, + 0x10, 0xc6, 0xe3, 0x05, 0x2a, 0xe4, 0x3d, 0x80, 0x4c, 0x41, 0x4b, 0x55, 0x79, 0x4b, 0x85, 0x50, + 0xf8, 0x67, 0x93, 0x72, 0xe3, 0x58, 0xee, 0x88, 0xad, 0x38, 0x71, 0x41, 0x4e, 0x6a, 0x85, 0x88, + 0xc6, 0x93, 0x8d, 0x9d, 0x88, 0x5c, 0xe1, 0xc8, 0x01, 0x24, 0x8e, 0xbc, 0x01, 0x4f, 0xd2, 0xe3, + 0x4a, 0x5c, 0xf6, 0x04, 0x6c, 0xcb, 0x83, 0xa0, 0xd8, 0x2e, 0xa2, 0xbb, 0xd1, 0x6a, 0x4f, 0x89, + 0x66, 0xbe, 0x99, 0xef, 0x9b, 0x9f, 0xf1, 0x08, 0x14, 0xe4, 0x4d, 0x51, 0x82, 0x81, 0x04, 0x16, + 0x7c, 0x2e, 0x80, 0xd7, 0x11, 0x3f, 0xac, 0x64, 0xd9, 0x30, 0x5b, 0x25, 0xfd, 0x2d, 0x05, 0x9b, + 0x0b, 0x60, 0x75, 0x34, 0xe8, 0xa7, 0x90, 0x82, 0x2d, 0xf2, 0xf6, 0xcf, 0x69, 0x07, 0x34, 0x01, + 0x9d, 0x83, 0xe6, 0xb1, 0xd0, 0x92, 0xd7, 0x51, 0x2c, 0x8d, 0x88, 0x78, 0x02, 0x99, 0xf2, 0xfd, + 0x61, 0x0a, 0x90, 0x2e, 0x24, 0x17, 0x45, 0xc6, 0x85, 0x52, 0x60, 0x84, 0xc9, 0x40, 0x69, 0xdf, + 0xbd, 0xd3, 0x99, 0xa5, 0x10, 0xa5, 0xc8, 0xbd, 0x64, 0xdc, 0xc7, 0xe4, 0xa0, 0xcd, 0xf6, 0xd2, + 0x16, 0x67, 0xf2, 0xb0, 0x92, 0xda, 0x8c, 0x0f, 0xf0, 0x8d, 0xad, 0xaa, 0x2e, 0x40, 0x69, 0x49, + 0x9e, 0xe1, 0x9e, 0x1b, 0xde, 0x43, 0x23, 0x14, 0xee, 0x4e, 0x86, 0xac, 0xeb, 0x14, 0xe6, 0xa6, + 0xa6, 0x97, 0x97, 0x3f, 0xf7, 0x83, 0x99, 0x9f, 0x18, 0xdf, 0xc2, 0x7d, 0xbb, 0xf2, 0x55, 0x29, + 0x85, 0xae, 0xca, 0x66, 0x63, 0xf5, 0x19, 0xe1, 0x9b, 0xa7, 0x1a, 0xde, 0xad, 0xc6, 0xd7, 0x8d, + 0xaf, 0xbd, 0x89, 0xc5, 0x42, 0xa8, 0x44, 0xee, 0xa1, 0xd1, 0xa5, 0x70, 0x77, 0x72, 0x9b, 0x39, + 0x2c, 0xac, 0xc5, 0xc2, 0x3c, 0x16, 0xf6, 0x1c, 0x32, 0x35, 0x7d, 0xd2, 0x9a, 0x7e, 0xff, 0xb5, + 0x1f, 0xa6, 0x99, 0x79, 0x5b, 0xc5, 0x2c, 0x81, 0x9c, 0x7b, 0x86, 0xee, 0xf3, 0x58, 0xcf, 0xdf, + 0x71, 0xd3, 0x14, 0x52, 0xdb, 0x01, 0x3d, 0xbb, 0xb6, 0x31, 0x99, 0x3a, 0x8f, 0xc9, 0xb7, 0x1d, + 0x7c, 0xc5, 0x26, 0x22, 0x1f, 0x11, 0xee, 0xb9, 0x63, 0x48, 0xd8, 0x7d, 0xea, 0x59, 0x76, 0x83, + 0xfb, 0x17, 0x50, 0xba, 0x0b, 0xc7, 0x77, 0x3f, 0xfc, 0xf8, 0xf3, 0x75, 0x87, 0x92, 0x21, 0x3f, + 0xe7, 0xa1, 0xc8, 0x27, 0x84, 0xaf, 0x6e, 0xe0, 0x90, 0x07, 0xe7, 0x6c, 0x3f, 0x85, 0x76, 0xf0, + 0xf0, 0x42, 0x5a, 0x9f, 0xe5, 0x9e, 0xcd, 0x32, 0x22, 0xb4, 0x3b, 0xcb, 0x3f, 0x48, 0x2f, 0x96, + 0x27, 0x34, 0x38, 0x3e, 0xa1, 0x68, 0xb9, 0xa2, 0xe8, 0x68, 0x45, 0xd1, 0xef, 0x15, 0x45, 0x5f, + 0xd6, 0x34, 0x38, 0x5a, 0xd3, 0xe0, 0x78, 0x4d, 0x83, 0xd7, 0x8f, 0xfe, 0x43, 0xbf, 0xbd, 0xab, + 0x94, 0x5a, 0x96, 0xb5, 0xe4, 0xef, 0xed, 0x56, 0xfb, 0x08, 0x71, 0xcf, 0x76, 0x9f, 0xfe, 0x0d, + 0x00, 0x00, 0xff, 0xff, 0x49, 0xc9, 0xc9, 0xc0, 0x38, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Treasury queries the dao treasury. + Treasury(ctx context.Context, in *QueryTreasuryRequest, opts ...grpc.CallOption) (*QueryTreasuryResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/onomyprotocol.dao.v1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Treasury(ctx context.Context, in *QueryTreasuryRequest, opts ...grpc.CallOption) (*QueryTreasuryResponse, error) { + out := new(QueryTreasuryResponse) + err := c.cc.Invoke(ctx, "/onomyprotocol.dao.v1.Query/Treasury", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Treasury queries the dao treasury. + Treasury(context.Context, *QueryTreasuryRequest) (*QueryTreasuryResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) Treasury(ctx context.Context, req *QueryTreasuryRequest) (*QueryTreasuryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Treasury not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/onomyprotocol.dao.v1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Treasury_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTreasuryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Treasury(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/onomyprotocol.dao.v1.Query/Treasury", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Treasury(ctx, req.(*QueryTreasuryRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "onomyprotocol.dao.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Treasury", + Handler: _Query_Treasury_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "onomyprotocol/dao/v1/query.proto", +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryTreasuryRequest) 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 *QueryTreasuryRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTreasuryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryTreasuryResponse) 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 *QueryTreasuryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTreasuryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TreasuryBalance) > 0 { + for iNdEx := len(m.TreasuryBalance) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TreasuryBalance[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryTreasuryRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryTreasuryResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.TreasuryBalance) > 0 { + for _, e := range m.TreasuryBalance { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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 ErrIntOverflowQuery + } + 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) 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 ErrIntOverflowQuery + } + 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTreasuryRequest) 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 ErrIntOverflowQuery + } + 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: QueryTreasuryRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTreasuryRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTreasuryResponse) 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 ErrIntOverflowQuery + } + 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: QueryTreasuryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTreasuryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TreasuryBalance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TreasuryBalance = append(m.TreasuryBalance, types.Coin{}) + if err := m.TreasuryBalance[len(m.TreasuryBalance)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/dao/types/query.pb.gw.go b/x/dao/types/query.pb.gw.go new file mode 100644 index 00000000..6ea58e06 --- /dev/null +++ b/x/dao/types/query.pb.gw.go @@ -0,0 +1,218 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: onomyprotocol/dao/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Treasury_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTreasuryRequest + var metadata runtime.ServerMetadata + + msg, err := client.Treasury(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Treasury_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTreasuryRequest + var metadata runtime.ServerMetadata + + msg, err := server.Treasury(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Treasury_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Treasury_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Treasury_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Treasury_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Treasury_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Treasury_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"onomyprotocol", "dao", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Treasury_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"onomyprotocol", "dao", "v1", "treasury"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Treasury_0 = runtime.ForwardResponseMessage +) From 901988e0ce41c92f60ff95ab218221880c93d7d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Wed, 6 Nov 2024 12:16:46 +0700 Subject: [PATCH 2/2] rename --- cmd/onomyd/cmd/cmd.go | 4 ++-- cmd/onomyd/cmd/command.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/onomyd/cmd/cmd.go b/cmd/onomyd/cmd/cmd.go index aae75bca..e95cc8f7 100644 --- a/cmd/onomyd/cmd/cmd.go +++ b/cmd/onomyd/cmd/cmd.go @@ -53,7 +53,7 @@ func NewRootCmd() *cobra.Command { }() // pull request #171 refactor: Remove ics. So we need re-register proto can read state - RegisterInterfacesICSProvider(tempApplication.InterfaceRegistry()) + RegisterInterfacesUsed(tempApplication.InterfaceRegistry()) initClientCtx := client.Context{}. WithCodec(tempApplication.AppCodec()). @@ -169,7 +169,7 @@ var tempDir = func() string { } // // pull request #171 refactor: Remove ics. So we need re-register proto can read state -func RegisterInterfacesICSProvider(registry cdctypes.InterfaceRegistry) { +func RegisterInterfacesUsed(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations( (*govtypes.Content)(nil), &ibcprovidertypes.ConsumerAdditionProposal{}, diff --git a/cmd/onomyd/cmd/command.go b/cmd/onomyd/cmd/command.go index b908b591..d47d25a8 100644 --- a/cmd/onomyd/cmd/command.go +++ b/cmd/onomyd/cmd/command.go @@ -147,7 +147,7 @@ func newApp( baseappOptions..., ) - RegisterInterfacesICSProvider(app.InterfaceRegistry()) + RegisterInterfacesUsed(app.InterfaceRegistry()) return app }