From 8fee6226af2f6807b613d0e643f036e99c6c4efd Mon Sep 17 00:00:00 2001 From: kitty Date: Wed, 14 Jul 2021 15:54:13 +0100 Subject: [PATCH 01/34] bls signature for basic account --- crypto/codec/amino.go | 5 + crypto/codec/proto.go | 2 + crypto/hd/algo.go | 45 +++ crypto/keyring/keyring.go | 2 +- crypto/keys/bls12381/bls12381.go | 233 +++++++++++ crypto/keys/bls12381/bls12381_test.go | 22 ++ crypto/keys/bls12381/keys.pb.go | 496 ++++++++++++++++++++++++ go.mod | 1 + go.sum | 2 + proto/cosmos/crypto/bls12381/keys.proto | 22 ++ x/auth/ante/sigverify.go | 15 + 11 files changed, 844 insertions(+), 1 deletion(-) create mode 100644 crypto/keys/bls12381/bls12381.go create mode 100644 crypto/keys/bls12381/bls12381_test.go create mode 100644 crypto/keys/bls12381/keys.pb.go create mode 100644 proto/cosmos/crypto/bls12381/keys.proto diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go index d50a08864c..0043c6855c 100644 --- a/crypto/codec/amino.go +++ b/crypto/codec/amino.go @@ -1,6 +1,7 @@ package codec import ( + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" "github.com/tendermint/tendermint/crypto/sr25519" "github.com/cosmos/cosmos-sdk/codec" @@ -22,6 +23,8 @@ func RegisterCrypto(cdc *codec.LegacyAmino) { secp256k1.PubKeyName, nil) cdc.RegisterConcrete(&kmultisig.LegacyAminoPubKey{}, kmultisig.PubKeyAminoRoute, nil) + cdc.RegisterConcrete(&bls12381.PubKey{}, + bls12381.PubKeyName, nil) cdc.RegisterInterface((*cryptotypes.PrivKey)(nil), nil) cdc.RegisterConcrete(sr25519.PrivKey{}, @@ -30,4 +33,6 @@ func RegisterCrypto(cdc *codec.LegacyAmino) { ed25519.PrivKeyName, nil) cdc.RegisterConcrete(&secp256k1.PrivKey{}, secp256k1.PrivKeyName, nil) + cdc.RegisterConcrete(&bls12381.PrivKey{}, + bls12381.PrivKeyName, nil) } diff --git a/crypto/codec/proto.go b/crypto/codec/proto.go index 9c07ca1105..6bdac15ab6 100644 --- a/crypto/codec/proto.go +++ b/crypto/codec/proto.go @@ -2,6 +2,7 @@ package codec import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -14,4 +15,5 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &ed25519.PubKey{}) registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &secp256k1.PubKey{}) registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &multisig.LegacyAminoPubKey{}) + registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &bls12381.PubKey{}) } diff --git a/crypto/hd/algo.go b/crypto/hd/algo.go index f934ad08ae..3606a8bce1 100644 --- a/crypto/hd/algo.go +++ b/crypto/hd/algo.go @@ -1,6 +1,7 @@ package hd import ( + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" bip39 "github.com/cosmos/go-bip39" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -20,11 +21,15 @@ const ( Ed25519Type = PubKeyType("ed25519") // Sr25519Type represents the Sr25519Type signature system. Sr25519Type = PubKeyType("sr25519") + // Bls12381Type represents the Bls12381Type signature system. + Bls12381Type = PubKeyType("bls12381") ) var ( // Secp256k1 uses the Bitcoin secp256k1 ECDSA parameters. Secp256k1 = secp256k1Algo{} + // Bls12381 uses blst implememtation of bls signatures + Bls12381 = bls12381Algo{} ) type DeriveFn func(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error) @@ -69,3 +74,43 @@ func (s secp256k1Algo) Generate() GenerateFn { return &secp256k1.PrivKey{Key: bzArr} } } + + + + +type bls12381Algo struct { +} + +func (s bls12381Algo) Name() PubKeyType { + return Bls12381Type +} + +// todo: replace bitcoin private key generation +// Derive derives and returns the bls12381 private key for the given seed and HD path. +func (s bls12381Algo) Derive() DeriveFn { + return func(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error) { + seed, err := bip39.NewSeedWithErrorChecking(mnemonic, bip39Passphrase) + if err != nil { + return nil, err + } + + masterPriv, ch := ComputeMastersFromSeed(seed) + if len(hdPath) == 0 { + return masterPriv[:], nil + } + derivedKey, err := DerivePrivateKeyForPath(masterPriv, ch, hdPath) + + return derivedKey, err + } +} + +// Generate generates a bls12381 private key from the given bytes. +func (s bls12381Algo) Generate() GenerateFn { + return func(bz []byte) types.PrivKey { + var bzArr = make([]byte, bls12381.SeedSize) + copy(bzArr, bz) + sk := bls12381.GenPrivKeyFromSecret(bzArr) + + return sk + } +} \ No newline at end of file diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go index febad555df..25a0a7dcb2 100644 --- a/crypto/keyring/keyring.go +++ b/crypto/keyring/keyring.go @@ -200,7 +200,7 @@ type keystore struct { func newKeystore(kr keyring.Keyring, opts ...Option) keystore { // Default options for keybase options := Options{ - SupportedAlgos: SigningAlgoList{hd.Secp256k1}, + SupportedAlgos: SigningAlgoList{hd.Secp256k1, hd.Bls12381}, SupportedAlgosLedger: SigningAlgoList{hd.Secp256k1}, } diff --git a/crypto/keys/bls12381/bls12381.go b/crypto/keys/bls12381/bls12381.go new file mode 100644 index 0000000000..c9df90bab8 --- /dev/null +++ b/crypto/keys/bls12381/bls12381.go @@ -0,0 +1,233 @@ +package bls12381 + +import ( + "crypto/subtle" + "fmt" + "github.com/cosmos/cosmos-sdk/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/types/errors" + blst "github.com/supranational/blst/bindings/go" + "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/tmhash" + "io" + +) + +const ( + PrivKeyName = "tendermint/PrivKeyBls12381" + PubKeyName = "tendermint/PubKeyBls12381" + // PubKeySize is is the size, in bytes, of public keys as used in this package. + PubKeySize = 96 + // PrivKeySize is the size, in bytes, of private keys as used in this package. + // Uncompressed public key + PrivKeySize = 32 + // Compressed signature + SignatureSize = 96 + keyType = "bls12381" + SeedSize = 32 +) + +var _ cryptotypes.PrivKey = &PrivKey{} +var _ codec.AminoMarshaler = &PrivKey{} + + +// Bytes returns the byte representation of the Private Key. +func (privKey *PrivKey) Bytes() []byte { + return privKey.Key +} + + +// PubKey performs the point-scalar multiplication from the privKey on the +// generator point to get the pubkey. +func (privKey *PrivKey) PubKey() cryptotypes.PubKey { + sk := new(blst.SecretKey).Deserialize(privKey.Key) + if sk == nil { + panic("Failed to deserialize secret key!") + } + pk := new(blst.P1Affine).From(sk) + pk_bytes := pk.Serialize() + + return &PubKey{Key: pk_bytes} +} + + +// Sign produces a signature on the provided message. +// This assumes the privkey is wellformed in the golang format. + +func (privKey *PrivKey) Sign(msg []byte) ([]byte, error) { + dst := []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_") + sk := new(blst.SecretKey).Deserialize(privKey.Key) + if sk == nil { + panic("Failed to deserialize secret key!") + } + + sig := new(blst.P2Affine).Sign(sk, msg, dst) + if sig == nil { + panic("Failed to sign message!") + } + + sig_bytes := sig.Compress() + + return sig_bytes, nil +} + +// Equals - you probably don't need to use this. +// Runs in constant time based on length of the +func (privKey *PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool { + return privKey.Type() == other.Type() && subtle.ConstantTimeCompare(privKey.Bytes(), other.Bytes()) == 1 +} + +func (privKey *PrivKey) Type() string { + return keyType +} + + +// MarshalAmino overrides Amino binary marshalling. +func (privKey PrivKey) MarshalAmino() ([]byte, error) { + return privKey.Key, nil +} + +// UnmarshalAmino overrides Amino binary marshalling. +func (privKey *PrivKey) UnmarshalAmino(bz []byte) error { + if len(bz) != PrivKeySize { + return fmt.Errorf("invalid privkey size") + } + privKey.Key = bz + + return nil +} + + +// MarshalAminoJSON overrides Amino JSON marshalling. +func (privKey PrivKey) MarshalAminoJSON() ([]byte, error) { + // When we marshal to Amino JSON, we don't marshal the "key" field itself, + // just its contents (i.e. the key bytes). + return privKey.MarshalAmino() +} + +// UnmarshalAminoJSON overrides Amino JSON marshalling. +func (privKey *PrivKey) UnmarshalAminoJSON(bz []byte) error { + return privKey.UnmarshalAmino(bz) +} + + + +// GenPrivKey generates a new BLS private key on curve bls12-381 private key. +// It uses OS randomness to generate the private key. +func GenPrivKey() *PrivKey { + return &PrivKey{Key: genPrivKey(crypto.CReader())} +} + +// genPrivKey generates a new secp256k1 private key using the provided reader. +func genPrivKey(rand io.Reader) []byte { + var ikm [SeedSize]byte + _, err := io.ReadFull(rand, ikm[:]) + if err != nil { + panic(err) + } + + sk := blst.KeyGen(ikm[:]) + if sk == nil { + panic("Failed to generate secret key!") + } + + sk_bytes := sk.Serialize() + + return sk_bytes +} + +// GenPrivKeyFromSecret hashes the secret with SHA2, and uses +// that 32 byte output to create the private key. +// NOTE: secret should be the output of a KDF like bcrypt, +// if it's derived from user input. +func GenPrivKeyFromSecret(secret []byte) *PrivKey { + ikm := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes. + sk_bytes := blst.KeyGen(ikm[:]).Serialize() + + return &PrivKey{Key: sk_bytes} +} + + +var _ cryptotypes.PubKey = &PubKey{} +var _ codec.AminoMarshaler = &PubKey{} + +// Validate public key, infinity and subgroup checking +func (pubKey *PubKey) Validate() bool { + pk := new(blst.P1Affine).Deserialize(pubKey.Key) + return pk.KeyValidate() +} + + +// Address is the SHA256-20 of the raw pubkey bytes. +func (pubKey *PubKey) Address() crypto.Address { + if len(pubKey.Key) != PubKeySize { + panic("pubkey is incorrect size") + } + return crypto.Address(tmhash.SumTruncated(pubKey.Key)) +} + +// Bytes returns the PubKey byte format. +func (pubKey *PubKey) Bytes() []byte { + return pubKey.Key +} + +// Assume public key is validated +func (pubKey *PubKey) VerifySignature(msg []byte, sig []byte) bool { + // make sure we use the same algorithm to sign + pk := new(blst.P1Affine).Deserialize(pubKey.Key) + if pk == nil { + panic("Failed to deserialize public key") + } + + sigma := new(blst.P2Affine).Uncompress(sig) + if sigma == nil { + panic("Failed to deserialize signature") + } + + dst := []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_") + + return sigma.Verify(true, pk, false, msg, dst) +} + +func (pubKey *PubKey) String() string { + return fmt.Sprintf("PubKeyBls12381{%X}", pubKey.Key) +} + +func (pubKey *PubKey) Type() string { + return keyType +} + +func (pubKey *PubKey) Equals(other cryptotypes.PubKey) bool { + if pubKey.Type() != other.Type() { + return false + } + + return subtle.ConstantTimeCompare(pubKey.Bytes(), other.Bytes()) == 1 +} + +// MarshalAmino overrides Amino binary marshalling. +func (pubKey PubKey) MarshalAmino() ([]byte, error) { + return pubKey.Key, nil +} + +// UnmarshalAmino overrides Amino binary marshalling. +func (pubKey *PubKey) UnmarshalAmino(bz []byte) error { + if len(bz) != PubKeySize { + return errors.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size") + } + pubKey.Key = bz + + return nil +} + +// MarshalAminoJSON overrides Amino JSON marshalling. +func (pubKey PubKey) MarshalAminoJSON() ([]byte, error) { + // When we marshal to Amino JSON, we don't marshal the "key" field itself, + // just its contents (i.e. the key bytes). + return pubKey.MarshalAmino() +} + +// UnmarshalAminoJSON overrides Amino JSON marshalling. +func (pubKey *PubKey) UnmarshalAminoJSON(bz []byte) error { + return pubKey.UnmarshalAmino(bz) +} diff --git a/crypto/keys/bls12381/bls12381_test.go b/crypto/keys/bls12381/bls12381_test.go new file mode 100644 index 0000000000..7e6cd13a30 --- /dev/null +++ b/crypto/keys/bls12381/bls12381_test.go @@ -0,0 +1,22 @@ +package bls12381_test + +import ( + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto" + "testing" +) + +func TestSignAndValidateBls12381(t *testing.T) { + privKey := bls12381.GenPrivKey() + pubKey := privKey.PubKey() + + msg := crypto.CRandBytes(1000) + sig, err := privKey.Sign(msg) + require.Nil(t, err) + + // Test the signature + assert.True(t, pubKey.VerifySignature(msg, sig)) + +} \ No newline at end of file diff --git a/crypto/keys/bls12381/keys.pb.go b/crypto/keys/bls12381/keys.pb.go new file mode 100644 index 0000000000..9a7569ca71 --- /dev/null +++ b/crypto/keys/bls12381/keys.pb.go @@ -0,0 +1,496 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/crypto/bls12381/keys.proto + +package bls12381 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/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 + +// PubKey defines a bls public key +// Key is the uncompressed form of the pubkey. The first byte depends is a 0x02 byte +// if the y-coordinate is the lexicographically largest of the two associated with +// the x-coordinate. Otherwise the first byte is a 0x03. +// This prefix is followed with the x-coordinate. +type PubKey struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *PubKey) Reset() { *m = PubKey{} } +func (*PubKey) ProtoMessage() {} +func (*PubKey) Descriptor() ([]byte, []int) { + return fileDescriptor_295d2962e809fcdb, []int{0} +} +func (m *PubKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PubKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PubKey.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 *PubKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PubKey.Merge(m, src) +} +func (m *PubKey) XXX_Size() int { + return m.Size() +} +func (m *PubKey) XXX_DiscardUnknown() { + xxx_messageInfo_PubKey.DiscardUnknown(m) +} + +var xxx_messageInfo_PubKey proto.InternalMessageInfo + +func (m *PubKey) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +// PrivKey defines a bls private key. +type PrivKey struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *PrivKey) Reset() { *m = PrivKey{} } +func (m *PrivKey) String() string { return proto.CompactTextString(m) } +func (*PrivKey) ProtoMessage() {} +func (*PrivKey) Descriptor() ([]byte, []int) { + return fileDescriptor_295d2962e809fcdb, []int{1} +} +func (m *PrivKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PrivKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PrivKey.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 *PrivKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PrivKey.Merge(m, src) +} +func (m *PrivKey) XXX_Size() int { + return m.Size() +} +func (m *PrivKey) XXX_DiscardUnknown() { + xxx_messageInfo_PrivKey.DiscardUnknown(m) +} + +var xxx_messageInfo_PrivKey proto.InternalMessageInfo + +func (m *PrivKey) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func init() { + proto.RegisterType((*PubKey)(nil), "cosmos.crypto.bls12381.PubKey") + proto.RegisterType((*PrivKey)(nil), "cosmos.crypto.bls12381.PrivKey") +} + +func init() { proto.RegisterFile("cosmos/crypto/bls12381/keys.proto", fileDescriptor_295d2962e809fcdb) } + +var fileDescriptor_295d2962e809fcdb = []byte{ + // 184 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0xd7, 0x4f, 0xca, 0x29, 0x36, 0x34, 0x32, + 0xb6, 0x30, 0xd4, 0xcf, 0x4e, 0xad, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x83, + 0x28, 0xd1, 0x83, 0x28, 0xd1, 0x83, 0x29, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd1, + 0x07, 0xb1, 0x20, 0xaa, 0x95, 0x14, 0xb8, 0xd8, 0x02, 0x4a, 0x93, 0xbc, 0x53, 0x2b, 0x85, 0x04, + 0xb8, 0x98, 0xb3, 0x53, 0x2b, 0x25, 0x18, 0x15, 0x18, 0x35, 0x78, 0x82, 0x40, 0x4c, 0x2b, 0x96, + 0x19, 0x0b, 0xe4, 0x19, 0x94, 0xa4, 0xb9, 0xd8, 0x03, 0x8a, 0x32, 0xcb, 0xb0, 0x2a, 0x71, 0xf2, + 0x3e, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, + 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xc3, 0xf4, 0xcc, 0x92, 0x8c, + 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x98, 0xa3, 0xc1, 0x94, 0x6e, 0x71, 0x4a, 0x36, 0xcc, + 0xfd, 0x20, 0x67, 0xc3, 0x3d, 0x91, 0xc4, 0x06, 0x76, 0x92, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, + 0x0e, 0x2e, 0xb6, 0x08, 0xe5, 0x00, 0x00, 0x00, +} + +func (m *PubKey) 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 *PubKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PubKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintKeys(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PrivKey) 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 *PrivKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PrivKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintKeys(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintKeys(dAtA []byte, offset int, v uint64) int { + offset -= sovKeys(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PubKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovKeys(uint64(l)) + } + return n +} + +func (m *PrivKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovKeys(uint64(l)) + } + return n +} + +func sovKeys(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozKeys(x uint64) (n int) { + return sovKeys(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PubKey) 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 ErrIntOverflowKeys + } + 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: PubKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PubKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeys + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthKeys + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthKeys + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipKeys(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthKeys + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PrivKey) 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 ErrIntOverflowKeys + } + 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: PrivKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PrivKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeys + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthKeys + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthKeys + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipKeys(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthKeys + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipKeys(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, ErrIntOverflowKeys + } + 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, ErrIntOverflowKeys + } + 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, ErrIntOverflowKeys + } + 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, ErrInvalidLengthKeys + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupKeys + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthKeys + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthKeys = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowKeys = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupKeys = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go.mod b/go.mod index 4f83be4fc3..ee4bb40e80 100644 --- a/go.mod +++ b/go.mod @@ -45,6 +45,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.7.0 + github.com/supranational/blst v0.3.4 github.com/tendermint/btcd v0.1.1 github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 github.com/tendermint/go-amino v0.16.0 diff --git a/go.sum b/go.sum index 0274c8cf10..b382b59e32 100644 --- a/go.sum +++ b/go.sum @@ -543,6 +543,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/supranational/blst v0.3.4 h1:iZE9lBMoywK2uy2U/5hDOvobQk9FnOQ2wNlu9GmRCoA= +github.com/supranational/blst v0.3.4/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca h1:Ld/zXl5t4+D69SiV4JoN7kkfvJdOWlPpfxrzxpLMoUk= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= diff --git a/proto/cosmos/crypto/bls12381/keys.proto b/proto/cosmos/crypto/bls12381/keys.proto new file mode 100644 index 0000000000..54740c32c9 --- /dev/null +++ b/proto/cosmos/crypto/bls12381/keys.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package cosmos.crypto.bls12381; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381"; + +// PubKey defines a bls public key +// Key is the uncompressed form of the pubkey. The first byte depends is a 0x02 byte +// if the y-coordinate is the lexicographically largest of the two associated with +// the x-coordinate. Otherwise the first byte is a 0x03. +// This prefix is followed with the x-coordinate. +message PubKey { + option (gogoproto.goproto_stringer) = false; + + bytes key = 1; +} + +// PrivKey defines a bls private key. +message PrivKey { + bytes key = 1; +} \ No newline at end of file diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 79fbbcdc67..84ea7a0ae7 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/hex" "fmt" + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" @@ -83,6 +84,15 @@ func (spkd SetPubKeyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate b if acc.GetPubKey() != nil { continue } + + //Validate public key for bls12381 so that the public key only needs to be checked once + switch pubkey := pk.(type) { + case *bls12381.PubKey: + if !pubkey.Validate() { + return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, "Invalid public key: either infinity or not subgroup element") + } + } + err = acc.SetPubKey(pk) if err != nil { return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, err.Error()) @@ -379,6 +389,11 @@ func DefaultSigVerificationGasConsumer( } return nil + // todo: add gas option to params and genesis.json + case *bls12381.PubKey: + meter.ConsumeGas(6213, "ante verify: bls12381") + return nil + default: return sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey) } From e47c7f88b9d23b5c2f493cf3c969991928f9bb25 Mon Sep 17 00:00:00 2001 From: kitty Date: Thu, 15 Jul 2021 11:01:21 +0100 Subject: [PATCH 02/34] benchmark for bls and ed25519 --- crypto/keys/bls12381/bls12381_test.go | 16 ++++++++++++++++ crypto/keys/ed25519/ed25519_test.go | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/crypto/keys/bls12381/bls12381_test.go b/crypto/keys/bls12381/bls12381_test.go index 7e6cd13a30..c7a9c993aa 100644 --- a/crypto/keys/bls12381/bls12381_test.go +++ b/crypto/keys/bls12381/bls12381_test.go @@ -2,6 +2,7 @@ package bls12381_test import ( "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" + bench "github.com/cosmos/cosmos-sdk/crypto/keys/internal/benchmarking" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" @@ -19,4 +20,19 @@ func TestSignAndValidateBls12381(t *testing.T) { // Test the signature assert.True(t, pubKey.VerifySignature(msg, sig)) +} + + +func BenchmarkSignBls(b *testing.B) { + privKey := bls12381.GenPrivKey() + + bench.BenchmarkSigning(b, privKey) + +} + + +func BenchmarkVerifyBls(b *testing.B) { + privKey := bls12381.GenPrivKey() + + bench.BenchmarkVerification(b, privKey) } \ No newline at end of file diff --git a/crypto/keys/ed25519/ed25519_test.go b/crypto/keys/ed25519/ed25519_test.go index 59cce4066a..4e455c47ad 100644 --- a/crypto/keys/ed25519/ed25519_test.go +++ b/crypto/keys/ed25519/ed25519_test.go @@ -3,6 +3,7 @@ package ed25519_test import ( stded25519 "crypto/ed25519" "encoding/base64" + bench "github.com/cosmos/cosmos-sdk/crypto/keys/internal/benchmarking" "testing" "github.com/stretchr/testify/assert" @@ -228,3 +229,19 @@ func TestMarshalAmino_BackwardsCompatibility(t *testing.T) { }) } } + + + +func BenchmarkSignEd25519(b *testing.B) { + privKey := ed25519.GenPrivKey() + + bench.BenchmarkSigning(b, privKey) + +} + + +func BenchmarkVerifyEd25519(b *testing.B) { + privKey := ed25519.GenPrivKey() + + bench.BenchmarkVerification(b, privKey) +} \ No newline at end of file From 082e0710e3dd2f96733e76f8e2f928c2d7e4ab29 Mon Sep 17 00:00:00 2001 From: kitty Date: Thu, 15 Jul 2021 15:16:23 +0100 Subject: [PATCH 03/34] added bls sig verify cost to genesis --- proto/cosmos/auth/v1beta1/auth.proto | 3 + x/auth/ante/sigverify.go | 4 +- x/auth/simulation/genesis.go | 14 ++- x/auth/types/auth.pb.go | 128 ++++++++++++++++++--------- x/auth/types/params.go | 24 ++++- 5 files changed, 124 insertions(+), 49 deletions(-) diff --git a/proto/cosmos/auth/v1beta1/auth.proto b/proto/cosmos/auth/v1beta1/auth.proto index 72e1d9ec28..799568c186 100644 --- a/proto/cosmos/auth/v1beta1/auth.proto +++ b/proto/cosmos/auth/v1beta1/auth.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package cosmos.auth.v1beta1; import "cosmos_proto/cosmos.proto"; +//import "cosmos.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; @@ -47,4 +48,6 @@ message Params { [(gogoproto.customname) = "SigVerifyCostED25519", (gogoproto.moretags) = "yaml:\"sig_verify_cost_ed25519\""]; uint64 sig_verify_cost_secp256k1 = 5 [(gogoproto.customname) = "SigVerifyCostSecp256k1", (gogoproto.moretags) = "yaml:\"sig_verify_cost_secp256k1\""]; + uint64 sig_verify_cost_bls12381 = 6 + [(gogoproto.customname) = "SigVerifyCostBls12381", (gogoproto.moretags) = "yaml:\"sig_verify_cost_bls12381\""]; } diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 84ea7a0ae7..223d81b296 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -5,7 +5,6 @@ import ( "encoding/hex" "fmt" "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -389,9 +388,8 @@ func DefaultSigVerificationGasConsumer( } return nil - // todo: add gas option to params and genesis.json case *bls12381.PubKey: - meter.ConsumeGas(6213, "ante verify: bls12381") + meter.ConsumeGas(params.SigVerifyCostBls12381, "ante verify: bls12381") return nil default: diff --git a/x/auth/simulation/genesis.go b/x/auth/simulation/genesis.go index 2da36b54fa..5bb2297f29 100644 --- a/x/auth/simulation/genesis.go +++ b/x/auth/simulation/genesis.go @@ -19,6 +19,7 @@ const ( TxSizeCostPerByte = "tx_size_cost_per_byte" SigVerifyCostED25519 = "sig_verify_cost_ed25519" SigVerifyCostSECP256K1 = "sig_verify_cost_secp256k1" + SigVerifyCostBLS12381 = "sig_verify_cost_bls12381" ) // RandomGenesisAccounts defines the default RandomGenesisAccountsFn used on the SDK. @@ -87,6 +88,11 @@ func GenSigVerifyCostSECP256K1(r *rand.Rand) uint64 { return uint64(simulation.RandIntBetween(r, 500, 1000)) } +// GenSigVerifyCostBLS12381 randomized SigVerifyCostBLS12381 +func GenSigVerifyCostBLS12381(r *rand.Rand) uint64 { + return uint64(simulation.RandIntBetween(r, 6000, 12000)) +} + // RandomizedGenState generates a random GenesisState for auth func RandomizedGenState(simState *module.SimulationState, randGenAccountsFn types.RandomGenesisAccountsFn) { var maxMemoChars uint64 @@ -119,8 +125,14 @@ func RandomizedGenState(simState *module.SimulationState, randGenAccountsFn type func(r *rand.Rand) { sigVerifyCostSECP256K1 = GenSigVerifyCostSECP256K1(r) }, ) + var sigVerifyCostBLS12381 uint64 + simState.AppParams.GetOrGenerate( + simState.Cdc, SigVerifyCostBLS12381, &sigVerifyCostBLS12381, simState.Rand, + func(r *rand.Rand) { sigVerifyCostBLS12381 = GenSigVerifyCostBLS12381(r) }, + ) + params := types.NewParams(maxMemoChars, txSigLimit, txSizeCostPerByte, - sigVerifyCostED25519, sigVerifyCostSECP256K1) + sigVerifyCostED25519, sigVerifyCostSECP256K1, sigVerifyCostBLS12381) genesisAccs := randGenAccountsFn(simState) authGenesis := types.NewGenesisState(params, genesisAccs) diff --git a/x/auth/types/auth.pb.go b/x/auth/types/auth.pb.go index fa52ac5a8b..ad2283b816 100644 --- a/x/auth/types/auth.pb.go +++ b/x/auth/types/auth.pb.go @@ -113,6 +113,7 @@ type Params struct { TxSizeCostPerByte uint64 `protobuf:"varint,3,opt,name=tx_size_cost_per_byte,json=txSizeCostPerByte,proto3" json:"tx_size_cost_per_byte,omitempty" yaml:"tx_size_cost_per_byte"` SigVerifyCostED25519 uint64 `protobuf:"varint,4,opt,name=sig_verify_cost_ed25519,json=sigVerifyCostEd25519,proto3" json:"sig_verify_cost_ed25519,omitempty" yaml:"sig_verify_cost_ed25519"` SigVerifyCostSecp256k1 uint64 `protobuf:"varint,5,opt,name=sig_verify_cost_secp256k1,json=sigVerifyCostSecp256k1,proto3" json:"sig_verify_cost_secp256k1,omitempty" yaml:"sig_verify_cost_secp256k1"` + SigVerifyCostBls12381 uint64 `protobuf:"varint,6,opt,name=sig_verify_cost_bls12381,json=sigVerifyCostBls12381,proto3" json:"sig_verify_cost_bls12381,omitempty" yaml:"sig_verify_cost_bls12381"` } func (m *Params) Reset() { *m = Params{} } @@ -182,6 +183,13 @@ func (m *Params) GetSigVerifyCostSecp256k1() uint64 { return 0 } +func (m *Params) GetSigVerifyCostBls12381() uint64 { + if m != nil { + return m.SigVerifyCostBls12381 + } + return 0 +} + func init() { proto.RegisterType((*BaseAccount)(nil), "cosmos.auth.v1beta1.BaseAccount") proto.RegisterType((*ModuleAccount)(nil), "cosmos.auth.v1beta1.ModuleAccount") @@ -191,50 +199,52 @@ func init() { func init() { proto.RegisterFile("cosmos/auth/v1beta1/auth.proto", fileDescriptor_7e1f7e915d020d2d) } var fileDescriptor_7e1f7e915d020d2d = []byte{ - // 674 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x4d, 0x4f, 0xdb, 0x4a, - 0x14, 0x8d, 0x5f, 0xf2, 0xf8, 0x98, 0x00, 0x12, 0x26, 0x80, 0x93, 0xf7, 0x64, 0x5b, 0x5e, 0xe5, - 0x49, 0x2f, 0x8e, 0x92, 0x8a, 0x4a, 0x64, 0x51, 0x15, 0xd3, 0x2e, 0x50, 0x0b, 0x42, 0x46, 0xea, - 0xa2, 0xaa, 0xe4, 0x8e, 0x9d, 0xc1, 0x58, 0x64, 0x32, 0xc6, 0x33, 0x46, 0x31, 0xbf, 0xa0, 0xcb, - 0x2e, 0xbb, 0xe4, 0x47, 0xf0, 0x0f, 0xba, 0xe9, 0x12, 0xb1, 0xea, 0xca, 0xad, 0xc2, 0xa6, 0xea, - 0x32, 0xfb, 0x4a, 0x95, 0x67, 0x9c, 0x90, 0xa0, 0x74, 0x95, 0xb9, 0xe7, 0x9c, 0x7b, 0xee, 0x9d, - 0x7b, 0xe3, 0x01, 0xaa, 0x47, 0x28, 0x26, 0xb4, 0x09, 0x63, 0x76, 0xd6, 0xbc, 0x6c, 0xb9, 0x88, - 0xc1, 0x16, 0x0f, 0xcc, 0x30, 0x22, 0x8c, 0xc8, 0x1b, 0x82, 0x37, 0x39, 0x94, 0xf3, 0xb5, 0xaa, - 0x00, 0x1d, 0x2e, 0x69, 0xe6, 0x0a, 0x1e, 0xd4, 0x2a, 0x3e, 0xf1, 0x89, 0xc0, 0xb3, 0x53, 0x8e, - 0x56, 0x7d, 0x42, 0xfc, 0x1e, 0x6a, 0xf2, 0xc8, 0x8d, 0x4f, 0x9b, 0xb0, 0x9f, 0x08, 0xca, 0xf8, - 0x25, 0x81, 0xb2, 0x05, 0x29, 0xda, 0xf3, 0x3c, 0x12, 0xf7, 0x99, 0xac, 0x80, 0x45, 0xd8, 0xed, - 0x46, 0x88, 0x52, 0x45, 0xd2, 0xa5, 0xfa, 0xb2, 0x3d, 0x0e, 0xe5, 0x77, 0x60, 0x31, 0x8c, 0x5d, - 0xe7, 0x1c, 0x25, 0xca, 0x5f, 0xba, 0x54, 0x2f, 0xb7, 0x2b, 0xa6, 0xb0, 0x35, 0xc7, 0xb6, 0xe6, - 0x5e, 0x3f, 0xb1, 0x1a, 0x3f, 0x53, 0xad, 0x12, 0xc6, 0x6e, 0x2f, 0xf0, 0x32, 0xed, 0xff, 0x04, - 0x07, 0x0c, 0xe1, 0x90, 0x25, 0xa3, 0x54, 0x5b, 0x4f, 0x20, 0xee, 0x75, 0x8c, 0x07, 0xd6, 0xb0, - 0x17, 0xc2, 0xd8, 0x7d, 0x85, 0x12, 0xf9, 0x39, 0x58, 0x83, 0xa2, 0x05, 0xa7, 0x1f, 0x63, 0x17, - 0x45, 0x4a, 0x51, 0x97, 0xea, 0x25, 0xab, 0x3a, 0x4a, 0xb5, 0x4d, 0x91, 0x36, 0xcb, 0x1b, 0xf6, - 0x6a, 0x0e, 0x1c, 0xf1, 0x58, 0xae, 0x81, 0x25, 0x8a, 0x2e, 0x62, 0xd4, 0xf7, 0x90, 0x52, 0xca, - 0x72, 0xed, 0x49, 0xdc, 0x51, 0x3e, 0x5c, 0x6b, 0x85, 0x4f, 0xd7, 0x5a, 0xe1, 0xc7, 0xb5, 0x56, - 0xb8, 0xbb, 0x69, 0x2c, 0xe5, 0xd7, 0x3d, 0x30, 0x3e, 0x4b, 0x60, 0xf5, 0x90, 0x74, 0xe3, 0xde, - 0x64, 0x02, 0xef, 0xc1, 0x8a, 0x0b, 0x29, 0x72, 0x72, 0x77, 0x3e, 0x86, 0x72, 0x5b, 0x37, 0xe7, - 0x6c, 0xc2, 0x9c, 0x9a, 0x9c, 0xf5, 0xcf, 0x6d, 0xaa, 0x49, 0xa3, 0x54, 0xdb, 0x10, 0xdd, 0x4e, - 0x7b, 0x18, 0x76, 0xd9, 0x9d, 0x9a, 0xb1, 0x0c, 0x4a, 0x7d, 0x88, 0x11, 0x1f, 0xe3, 0xb2, 0xcd, - 0xcf, 0xb2, 0x0e, 0xca, 0x21, 0x8a, 0x70, 0x40, 0x69, 0x40, 0xfa, 0x54, 0x29, 0xea, 0xc5, 0xfa, - 0xb2, 0x3d, 0x0d, 0x75, 0x6a, 0xe3, 0x3b, 0xdc, 0xdd, 0x34, 0xd6, 0x66, 0x5a, 0x3e, 0x30, 0xbe, - 0x15, 0xc1, 0xc2, 0x31, 0x8c, 0x20, 0xa6, 0xf2, 0x11, 0xd8, 0xc0, 0x70, 0xe0, 0x60, 0x84, 0x89, - 0xe3, 0x9d, 0xc1, 0x08, 0x7a, 0x0c, 0x45, 0x62, 0x99, 0x25, 0x4b, 0x1d, 0xa5, 0x5a, 0x4d, 0xf4, - 0x37, 0x47, 0x64, 0xd8, 0xeb, 0x18, 0x0e, 0x0e, 0x11, 0x26, 0xfb, 0x13, 0x4c, 0xde, 0x05, 0x2b, - 0x6c, 0xe0, 0xd0, 0xc0, 0x77, 0x7a, 0x01, 0x0e, 0x18, 0x6f, 0xba, 0x64, 0x6d, 0x3f, 0x5c, 0x74, - 0x9a, 0x35, 0x6c, 0xc0, 0x06, 0x27, 0x81, 0xff, 0x3a, 0x0b, 0x64, 0x1b, 0x6c, 0x72, 0xf2, 0x0a, - 0x39, 0x1e, 0xa1, 0xcc, 0x09, 0x51, 0xe4, 0xb8, 0x09, 0x43, 0xf9, 0x6a, 0xf5, 0x51, 0xaa, 0xfd, - 0x3b, 0xe5, 0xf1, 0x58, 0x66, 0xd8, 0xeb, 0x99, 0xd9, 0x15, 0xda, 0x27, 0x94, 0x1d, 0xa3, 0xc8, - 0x4a, 0x18, 0x92, 0x2f, 0xc0, 0x76, 0x56, 0xed, 0x12, 0x45, 0xc1, 0x69, 0x22, 0xf4, 0xa8, 0xdb, - 0xde, 0xd9, 0x69, 0xed, 0x8a, 0xa5, 0x5b, 0x9d, 0x61, 0xaa, 0x55, 0x4e, 0x02, 0xff, 0x0d, 0x57, - 0x64, 0xa9, 0x2f, 0x5f, 0x70, 0x7e, 0x94, 0x6a, 0xaa, 0xa8, 0xf6, 0x07, 0x03, 0xc3, 0xae, 0xd0, - 0x99, 0x3c, 0x01, 0xcb, 0x09, 0xa8, 0x3e, 0xce, 0xa0, 0xc8, 0x0b, 0xdb, 0x3b, 0x4f, 0xcf, 0x5b, - 0xca, 0xdf, 0xbc, 0xe8, 0xb3, 0x61, 0xaa, 0x6d, 0xcd, 0x14, 0x3d, 0x19, 0x2b, 0x46, 0xa9, 0xa6, - 0xcf, 0x2f, 0x3b, 0x31, 0x31, 0xec, 0x2d, 0x3a, 0x37, 0xb7, 0xb3, 0x94, 0xff, 0x67, 0x25, 0x6b, - 0xff, 0xcb, 0x50, 0x95, 0x6e, 0x87, 0xaa, 0xf4, 0x7d, 0xa8, 0x4a, 0x1f, 0xef, 0xd5, 0xc2, 0xed, - 0xbd, 0x5a, 0xf8, 0x7a, 0xaf, 0x16, 0xde, 0xfe, 0xe7, 0x07, 0xec, 0x2c, 0x76, 0x4d, 0x8f, 0xe0, - 0xfc, 0x2d, 0xc8, 0x7f, 0x1a, 0xb4, 0x7b, 0xde, 0x1c, 0x88, 0xa7, 0x85, 0x25, 0x21, 0xa2, 0xee, - 0x02, 0xff, 0x52, 0x9f, 0xfc, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x49, 0x90, 0x16, 0xd9, 0x76, 0x04, - 0x00, 0x00, + // 707 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x4f, 0x4f, 0xdb, 0x48, + 0x14, 0x8f, 0x97, 0x6c, 0x80, 0x09, 0x20, 0x61, 0x12, 0x30, 0xd9, 0x95, 0xc7, 0xf2, 0x29, 0x2b, + 0x6d, 0x1c, 0x25, 0x88, 0xd5, 0x12, 0xad, 0x56, 0x8b, 0xd9, 0x1e, 0x50, 0x0b, 0x42, 0x46, 0xea, + 0xa1, 0xaa, 0xe4, 0x8e, 0x9d, 0xc1, 0x58, 0x64, 0x32, 0xc6, 0x33, 0x46, 0x31, 0x9f, 0xa0, 0xc7, + 0x1e, 0x7b, 0xe4, 0x43, 0xf0, 0x0d, 0x7a, 0xe9, 0x11, 0x71, 0xa8, 0x7a, 0xb2, 0xaa, 0x70, 0xa9, + 0x7a, 0xf4, 0xbd, 0x52, 0x95, 0xb1, 0x13, 0x12, 0x94, 0x9e, 0xe2, 0xf7, 0x7e, 0xff, 0xde, 0xbc, + 0x51, 0x06, 0xa8, 0x2e, 0x65, 0x84, 0xb2, 0x26, 0x8a, 0xf8, 0x79, 0xf3, 0xaa, 0xe5, 0x60, 0x8e, + 0x5a, 0xa2, 0x30, 0x82, 0x90, 0x72, 0x2a, 0x6f, 0x64, 0xb8, 0x21, 0x5a, 0x39, 0x5e, 0x5b, 0xc9, + 0x9b, 0x82, 0x52, 0xab, 0x78, 0xd4, 0xa3, 0xe2, 0xb3, 0x39, 0xfa, 0xca, 0xbb, 0xdb, 0x1e, 0xa5, + 0x5e, 0x0f, 0x37, 0x45, 0xe5, 0x44, 0x67, 0x4d, 0xd4, 0x8f, 0x33, 0x48, 0xff, 0x2e, 0x81, 0xb2, + 0x89, 0x18, 0xde, 0x77, 0x5d, 0x1a, 0xf5, 0xb9, 0xac, 0x80, 0x45, 0xd4, 0xed, 0x86, 0x98, 0x31, + 0x45, 0xd2, 0xa4, 0xfa, 0xb2, 0x35, 0x2e, 0xe5, 0xd7, 0x60, 0x31, 0x88, 0x1c, 0xfb, 0x02, 0xc7, + 0xca, 0x2f, 0x9a, 0x54, 0x2f, 0xb7, 0x2b, 0x46, 0x66, 0x6b, 0x8c, 0x6d, 0x8d, 0xfd, 0x7e, 0x6c, + 0x36, 0xbe, 0x25, 0xb0, 0x12, 0x44, 0x4e, 0xcf, 0x77, 0x47, 0xdc, 0x3f, 0x29, 0xf1, 0x39, 0x26, + 0x01, 0x8f, 0xd3, 0x04, 0xae, 0xc7, 0x88, 0xf4, 0x3a, 0xfa, 0x23, 0xaa, 0x5b, 0xa5, 0x20, 0x72, + 0x9e, 0xe3, 0x58, 0xfe, 0x0f, 0xac, 0xa1, 0x6c, 0x04, 0xbb, 0x1f, 0x11, 0x07, 0x87, 0xca, 0x82, + 0x26, 0xd5, 0x8b, 0xe6, 0x76, 0x9a, 0xc0, 0x6a, 0x26, 0x9b, 0xc5, 0x75, 0x6b, 0x35, 0x6f, 0x1c, + 0x8b, 0x5a, 0xae, 0x81, 0x25, 0x86, 0x2f, 0x23, 0xdc, 0x77, 0xb1, 0x52, 0x1c, 0x69, 0xad, 0x49, + 0xdd, 0x51, 0xde, 0xde, 0xc0, 0xc2, 0xfb, 0x1b, 0x58, 0xf8, 0x7a, 0x03, 0x0b, 0xf7, 0xb7, 0x8d, + 0xa5, 0xfc, 0xb8, 0x87, 0xfa, 0x07, 0x09, 0xac, 0x1e, 0xd1, 0x6e, 0xd4, 0x9b, 0x6c, 0xe0, 0x0d, + 0x58, 0x71, 0x10, 0xc3, 0x76, 0xee, 0x2e, 0xd6, 0x50, 0x6e, 0x6b, 0xc6, 0x9c, 0xe5, 0x1b, 0x53, + 0x9b, 0x33, 0x7f, 0xbb, 0x4b, 0xa0, 0x94, 0x26, 0x70, 0x23, 0x9b, 0x76, 0xda, 0x43, 0xb7, 0xca, + 0xce, 0xd4, 0x8e, 0x65, 0x50, 0xec, 0x23, 0x82, 0xc5, 0x1a, 0x97, 0x2d, 0xf1, 0x2d, 0x6b, 0xa0, + 0x1c, 0xe0, 0x90, 0xf8, 0x8c, 0xf9, 0xb4, 0xcf, 0x94, 0x05, 0x6d, 0xa1, 0xbe, 0x6c, 0x4d, 0xb7, + 0x3a, 0xb5, 0xf1, 0x19, 0xee, 0x6f, 0x1b, 0x6b, 0x33, 0x23, 0x1f, 0xea, 0x9f, 0x8a, 0xa0, 0x74, + 0x82, 0x42, 0x44, 0x98, 0x7c, 0x0c, 0x36, 0x08, 0x1a, 0xd8, 0x04, 0x13, 0x6a, 0xbb, 0xe7, 0x28, + 0x44, 0x2e, 0xc7, 0x61, 0x76, 0x99, 0x45, 0x53, 0x4d, 0x13, 0x58, 0xcb, 0xe6, 0x9b, 0x43, 0xd2, + 0xad, 0x75, 0x82, 0x06, 0x47, 0x98, 0xd0, 0x83, 0x49, 0x4f, 0xde, 0x03, 0x2b, 0x7c, 0x60, 0x33, + 0xdf, 0xb3, 0x7b, 0x3e, 0xf1, 0xb9, 0x18, 0xba, 0x68, 0x6e, 0x3d, 0x1e, 0x74, 0x1a, 0xd5, 0x2d, + 0xc0, 0x07, 0xa7, 0xbe, 0xf7, 0x62, 0x54, 0xc8, 0x16, 0xa8, 0x0a, 0xf0, 0x1a, 0xdb, 0x2e, 0x65, + 0xdc, 0x0e, 0x70, 0x68, 0x3b, 0x31, 0xc7, 0xf9, 0xd5, 0x6a, 0x69, 0x02, 0x7f, 0x9f, 0xf2, 0x78, + 0x4a, 0xd3, 0xad, 0xf5, 0x91, 0xd9, 0x35, 0x3e, 0xa0, 0x8c, 0x9f, 0xe0, 0xd0, 0x8c, 0x39, 0x96, + 0x2f, 0xc1, 0xd6, 0x28, 0xed, 0x0a, 0x87, 0xfe, 0x59, 0x9c, 0xf1, 0x71, 0xb7, 0xbd, 0xbb, 0xdb, + 0xda, 0xcb, 0x2e, 0xdd, 0xec, 0x0c, 0x13, 0x58, 0x39, 0xf5, 0xbd, 0x97, 0x82, 0x31, 0x92, 0x3e, + 0xfb, 0x5f, 0xe0, 0x69, 0x02, 0xd5, 0x2c, 0xed, 0x27, 0x06, 0xba, 0x55, 0x61, 0x33, 0xba, 0xac, + 0x2d, 0xc7, 0x60, 0xfb, 0xa9, 0x82, 0x61, 0x37, 0x68, 0xef, 0xfe, 0x75, 0xd1, 0x52, 0x7e, 0x15, + 0xa1, 0xff, 0x0e, 0x13, 0xb8, 0x39, 0x13, 0x7a, 0x3a, 0x66, 0xa4, 0x09, 0xd4, 0xe6, 0xc7, 0x4e, + 0x4c, 0x74, 0x6b, 0x93, 0xcd, 0xd5, 0xca, 0x11, 0x50, 0x9e, 0xaa, 0x9c, 0x1e, 0x6b, 0xb5, 0x77, + 0xfe, 0x6e, 0x29, 0x25, 0x91, 0xfc, 0xcf, 0x30, 0x81, 0xd5, 0x99, 0x64, 0x33, 0x27, 0xa4, 0x09, + 0x84, 0xf3, 0x83, 0xc7, 0x16, 0xba, 0x55, 0x65, 0xf3, 0x94, 0x9d, 0xa5, 0xfc, 0xaf, 0x22, 0x99, + 0x07, 0x1f, 0x87, 0xaa, 0x74, 0x37, 0x54, 0xa5, 0x2f, 0x43, 0x55, 0x7a, 0xf7, 0xa0, 0x16, 0xee, + 0x1e, 0xd4, 0xc2, 0xe7, 0x07, 0xb5, 0xf0, 0xea, 0x0f, 0xcf, 0xe7, 0xe7, 0x91, 0x63, 0xb8, 0x94, + 0x34, 0xf3, 0x77, 0x2b, 0xfb, 0x69, 0xb0, 0xee, 0x45, 0x73, 0x90, 0x3d, 0x62, 0x3c, 0x0e, 0x30, + 0x73, 0x4a, 0xe2, 0x81, 0xd8, 0xf9, 0x11, 0x00, 0x00, 0xff, 0xff, 0xd3, 0xe6, 0x37, 0xa1, 0xe0, + 0x04, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -271,6 +281,9 @@ func (this *Params) Equal(that interface{}) bool { if this.SigVerifyCostSecp256k1 != that1.SigVerifyCostSecp256k1 { return false } + if this.SigVerifyCostBls12381 != that1.SigVerifyCostBls12381 { + return false + } return true } func (m *BaseAccount) Marshal() (dAtA []byte, err error) { @@ -396,6 +409,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.SigVerifyCostBls12381 != 0 { + i = encodeVarintAuth(dAtA, i, uint64(m.SigVerifyCostBls12381)) + i-- + dAtA[i] = 0x30 + } if m.SigVerifyCostSecp256k1 != 0 { i = encodeVarintAuth(dAtA, i, uint64(m.SigVerifyCostSecp256k1)) i-- @@ -502,6 +520,9 @@ func (m *Params) Size() (n int) { if m.SigVerifyCostSecp256k1 != 0 { n += 1 + sovAuth(uint64(m.SigVerifyCostSecp256k1)) } + if m.SigVerifyCostBls12381 != 0 { + n += 1 + sovAuth(uint64(m.SigVerifyCostBls12381)) + } return n } @@ -941,6 +962,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SigVerifyCostBls12381", wireType) + } + m.SigVerifyCostBls12381 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuth + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SigVerifyCostBls12381 |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipAuth(dAtA[iNdEx:]) diff --git a/x/auth/types/params.go b/x/auth/types/params.go index 13db369d23..fb2a47ec50 100644 --- a/x/auth/types/params.go +++ b/x/auth/types/params.go @@ -15,6 +15,7 @@ const ( DefaultTxSizeCostPerByte uint64 = 10 DefaultSigVerifyCostED25519 uint64 = 590 DefaultSigVerifyCostSecp256k1 uint64 = 1000 + DefaultSigVerifyCostBls12381 uint64 = 6300 ) // Parameter keys @@ -24,13 +25,14 @@ var ( KeyTxSizeCostPerByte = []byte("TxSizeCostPerByte") KeySigVerifyCostED25519 = []byte("SigVerifyCostED25519") KeySigVerifyCostSecp256k1 = []byte("SigVerifyCostSecp256k1") + KeySigVerifyCostBls12381 = []byte("SigVerifyCostBls12381") ) var _ paramtypes.ParamSet = &Params{} // NewParams creates a new Params object func NewParams( - maxMemoCharacters, txSigLimit, txSizeCostPerByte, sigVerifyCostED25519, sigVerifyCostSecp256k1 uint64, + maxMemoCharacters, txSigLimit, txSizeCostPerByte, sigVerifyCostED25519, sigVerifyCostSecp256k1 uint64, sigVerifyCostBls12381 uint64, ) Params { return Params{ MaxMemoCharacters: maxMemoCharacters, @@ -38,6 +40,7 @@ func NewParams( TxSizeCostPerByte: txSizeCostPerByte, SigVerifyCostED25519: sigVerifyCostED25519, SigVerifyCostSecp256k1: sigVerifyCostSecp256k1, + SigVerifyCostBls12381: sigVerifyCostBls12381, } } @@ -55,6 +58,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyTxSizeCostPerByte, &p.TxSizeCostPerByte, validateTxSizeCostPerByte), paramtypes.NewParamSetPair(KeySigVerifyCostED25519, &p.SigVerifyCostED25519, validateSigVerifyCostED25519), paramtypes.NewParamSetPair(KeySigVerifyCostSecp256k1, &p.SigVerifyCostSecp256k1, validateSigVerifyCostSecp256k1), + paramtypes.NewParamSetPair(KeySigVerifyCostBls12381, &p.SigVerifyCostBls12381, validateSigVerifyCostBls12381), } } @@ -66,6 +70,7 @@ func DefaultParams() Params { TxSizeCostPerByte: DefaultTxSizeCostPerByte, SigVerifyCostED25519: DefaultSigVerifyCostED25519, SigVerifyCostSecp256k1: DefaultSigVerifyCostSecp256k1, + SigVerifyCostBls12381: DefaultSigVerifyCostBls12381, } } @@ -114,6 +119,20 @@ func validateSigVerifyCostSecp256k1(i interface{}) error { return nil } + +func validateSigVerifyCostBls12381(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("invalid BLS12381 signature verification cost: %d", v) + } + + return nil +} + func validateMaxMemoCharacters(i interface{}) error { v, ok := i.(uint64) if !ok { @@ -151,6 +170,9 @@ func (p Params) Validate() error { if err := validateSigVerifyCostSecp256k1(p.SigVerifyCostSecp256k1); err != nil { return err } + if err := validateSigVerifyCostBls12381(p.SigVerifyCostBls12381); err != nil { + return err + } if err := validateMaxMemoCharacters(p.MaxMemoCharacters); err != nil { return err } From 78a09e55d29c6a0c0b28fc6b54bce22fe35fd6ea Mon Sep 17 00:00:00 2001 From: kitty Date: Thu, 15 Jul 2021 15:43:27 +0100 Subject: [PATCH 04/34] Revert "Merge branch 'fetchai:master' into bls" This reverts commit a5dd8ea9c1597c285e9375f168dd7af51e76f6b3, reversing changes made to 082e0710e3dd2f96733e76f8e2f928c2d7e4ab29. --- x/airdrop/keeper/keeper_test.go | 84 +-------------------------------- x/airdrop/keeper/params.go | 2 +- x/airdrop/types/genesis_test.go | 63 ------------------------- 3 files changed, 2 insertions(+), 147 deletions(-) delete mode 100644 x/airdrop/types/genesis_test.go diff --git a/x/airdrop/keeper/keeper_test.go b/x/airdrop/keeper/keeper_test.go index 37e9f51a5c..94aa2b7d79 100644 --- a/x/airdrop/keeper/keeper_test.go +++ b/x/airdrop/keeper/keeper_test.go @@ -17,8 +17,6 @@ var ( feeCollectorAddress = authtypes.NewModuleAddress(authtypes.FeeCollectorName) addr1 = sdk.AccAddress([]byte("addr1_______________")) addr2 = sdk.AccAddress([]byte("addr2_______________")) - addr3 = sdk.AccAddress([]byte("addr3_______________")) - addr4 = sdk.AccAddress([]byte("addr4_______________")) ) type KeeperTestSuite struct { @@ -36,10 +34,9 @@ func (s *KeeperTestSuite) SetupTest() { Height: 10, }) - s.app.AirdropKeeper.SetParams(s.ctx, types.NewParams(addr1.String(), addr2.String(), addr3.String(), addr4.String())) + s.app.AirdropKeeper.SetParams(s.ctx, types.NewParams(addr1.String(), addr2.String())) } - func (s *KeeperTestSuite) TestAddNewFund() { amount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 4000) s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr1, amount)) // ensure the account is funded @@ -167,85 +164,6 @@ func (s *KeeperTestSuite) TestFeeDrip() { s.Require().Equal(feeCollectorBalance, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(4040))) } -func (s *KeeperTestSuite) TestAddNewFundWithDiffDenom() { - amount := sdk.NewInt64Coin("denom", 4000) - s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr1, amount)) // ensure the account is funded - - addrBalance := s.app.BankKeeper.GetBalance(s.ctx, addr1, "denom") - moduleBalance := s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, "denom") - - // sanity check - s.Require().Equal(addrBalance, sdk.NewCoin("denom", sdk.NewInt(4000))) - s.Require().Equal(moduleBalance, sdk.NewCoin("denom", sdk.NewInt(0))) - - fund := types.Fund{ - Amount: &amount, - DripAmount: sdk.NewInt(40), - } - s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr1, fund)) - - addrBalance = s.app.BankKeeper.GetBalance(s.ctx, addr1, "denom") - moduleBalance = s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, "denom") - - s.Require().Equal(addrBalance, sdk.NewCoin("denom", sdk.NewInt(0))) - s.Require().Equal(moduleBalance, sdk.NewCoin("denom", sdk.NewInt(4000))) -} - -func (s *KeeperTestSuite) TestMultiDenomFeeDrip() { - amountStake := sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000) - amountDenom := sdk.NewInt64Coin("denom", 1000) - fund1 := types.Fund{ - Amount: &amountStake, - DripAmount: sdk.NewInt(500)} - - fund2 := types.Fund{ - Amount: &amountStake, - DripAmount: sdk.NewInt(800), - } - - fund3 := types.Fund{ - Amount: &amountDenom, - DripAmount: sdk.NewInt(100)} - - fund4 := types.Fund{ - Amount: &amountDenom, - DripAmount: sdk.NewInt(300), - } - s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr1, amountStake)) - s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr2, amountStake)) - s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr3, amountDenom)) - s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr4, amountDenom)) - - s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr1, fund1)) - s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr2, fund2)) - s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr3, fund3)) - s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr4, fund4)) // check the balances - - moduleBalanceStake := s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, sdk.DefaultBondDenom) - moduleBalanceDenom := s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, "denom") - feeCollectorBalanceStake := s.app.BankKeeper.GetBalance(s.ctx, feeCollectorAddress, sdk.DefaultBondDenom) - feeCollectorBalanceDenom := s.app.BankKeeper.GetBalance(s.ctx, feeCollectorAddress, "denom") - - s.Require().Equal(moduleBalanceStake, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(2000))) - s.Require().Equal(moduleBalanceDenom, sdk.NewCoin("denom", sdk.NewInt(2000))) - s.Require().Equal(feeCollectorBalanceStake, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0))) - s.Require().Equal(feeCollectorBalanceDenom, sdk.NewCoin("denom", sdk.NewInt(0))) - - _, err := s.app.AirdropKeeper.DripAllFunds(s.ctx) // test case - drip the funds - s.Require().NoError(err) // check that the fees have been transferred - - moduleBalanceStake = s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, sdk.DefaultBondDenom) - moduleBalanceDenom = s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, "denom") - feeCollectorBalanceStake = s.app.BankKeeper.GetBalance(s.ctx, feeCollectorAddress, sdk.DefaultBondDenom) - feeCollectorBalanceDenom = s.app.BankKeeper.GetBalance(s.ctx, feeCollectorAddress, "denom") - - s.Require().Equal(feeCollectorBalanceStake, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1300))) // 800 drip fund 1, 500 drip fund 2 - s.Require().Equal(feeCollectorBalanceDenom, sdk.NewCoin("denom", sdk.NewInt(400))) // 100 drip fund 3, 300 drip fund 4 - s.Require().Equal(moduleBalanceStake, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(700))) // remainder 500 from fund 1, remainder 200 from fund 2 - s.Require().Equal(moduleBalanceDenom, sdk.NewCoin("denom", sdk.NewInt(1600))) // remainder 900 from fund 3, remainder 700 from fund 4 - -} - func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(KeeperTestSuite)) } diff --git a/x/airdrop/keeper/params.go b/x/airdrop/keeper/params.go index 0ccf156afd..c748d41074 100644 --- a/x/airdrop/keeper/params.go +++ b/x/airdrop/keeper/params.go @@ -7,7 +7,7 @@ import ( func (k Keeper) GetWhiteListClients(ctx sdk.Context) []string { var res []string - k.paramSpace.GetIfExists(ctx, types.KeyWhiteList, &res) + k.paramSpace.Get(ctx, types.KeyWhiteList, &res) return res } diff --git a/x/airdrop/types/genesis_test.go b/x/airdrop/types/genesis_test.go deleted file mode 100644 index 901770b719..0000000000 --- a/x/airdrop/types/genesis_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/x/airdrop/types" - "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var ( - addr = sdk.AccAddress([]byte("addr________________")) - invalidAddr = sdk.AccAddress([]byte("\n\n\n\n\taddr________________\t\n\n\n\n\n")) -) - -func TestNewGenesisState(t *testing.T) { - p := types.NewParams() - expectedFunds := []types.ActiveFund{ - { - Sender: addr.String(), - Fund: &types.Fund{ - Amount: &sdk.Coin{Denom: "test", Amount: sdk.NewInt(10)}, - DripAmount: sdk.NewInt(1), - }, - }, - } - expectedState := &types.GenesisState{ - Params: p, - Funds: expectedFunds, - } - require.Equal(t, expectedState.GetFunds(), expectedFunds) - require.Equal(t, expectedState.Params, p) -} - -func TestValidateGenesisState(t *testing.T) { - p1 := types.Params{ - AllowList: []string{ - addr.String(), // valid address - }, - } - p2 := types.Params{ - AllowList: []string{ - invalidAddr.String(), // invalid address - }, - } - funds := []types.ActiveFund{ - { - Sender: addr.String(), - Fund: &types.Fund{ - Amount: &sdk.Coin{ - Denom: "test", - Amount: sdk.NewInt(10), - }, - DripAmount: sdk.NewInt(1), - }, - }, - } - gen1 := types.NewGenesisState(p1, funds) - gen2 := types.NewGenesisState(p2, funds) - require.NoError(t, gen1.Validate()) - require.Error(t, gen2.Validate()) -} \ No newline at end of file From 535777db1176899025fcc5c02633ace5208168c1 Mon Sep 17 00:00:00 2001 From: kitty Date: Tue, 20 Jul 2021 11:05:35 +0100 Subject: [PATCH 05/34] format using go tools --- crypto/hd/algo.go | 5 +---- crypto/keys/bls12381/bls12381.go | 16 +++------------- crypto/keys/bls12381/bls12381_test.go | 4 +--- crypto/keys/ed25519/ed25519_test.go | 5 +---- x/auth/simulation/genesis.go | 2 +- x/auth/types/params.go | 7 +++---- 6 files changed, 10 insertions(+), 29 deletions(-) diff --git a/crypto/hd/algo.go b/crypto/hd/algo.go index 3606a8bce1..fcd4851996 100644 --- a/crypto/hd/algo.go +++ b/crypto/hd/algo.go @@ -75,9 +75,6 @@ func (s secp256k1Algo) Generate() GenerateFn { } } - - - type bls12381Algo struct { } @@ -113,4 +110,4 @@ func (s bls12381Algo) Generate() GenerateFn { return sk } -} \ No newline at end of file +} diff --git a/crypto/keys/bls12381/bls12381.go b/crypto/keys/bls12381/bls12381.go index c9df90bab8..ea13409782 100644 --- a/crypto/keys/bls12381/bls12381.go +++ b/crypto/keys/bls12381/bls12381.go @@ -10,7 +10,6 @@ import ( "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/tmhash" "io" - ) const ( @@ -23,24 +22,22 @@ const ( PrivKeySize = 32 // Compressed signature SignatureSize = 96 - keyType = "bls12381" - SeedSize = 32 + keyType = "bls12381" + SeedSize = 32 ) var _ cryptotypes.PrivKey = &PrivKey{} var _ codec.AminoMarshaler = &PrivKey{} - // Bytes returns the byte representation of the Private Key. func (privKey *PrivKey) Bytes() []byte { return privKey.Key } - // PubKey performs the point-scalar multiplication from the privKey on the // generator point to get the pubkey. func (privKey *PrivKey) PubKey() cryptotypes.PubKey { - sk := new(blst.SecretKey).Deserialize(privKey.Key) + sk := new(blst.SecretKey).Deserialize(privKey.Key) if sk == nil { panic("Failed to deserialize secret key!") } @@ -50,7 +47,6 @@ func (privKey *PrivKey) PubKey() cryptotypes.PubKey { return &PubKey{Key: pk_bytes} } - // Sign produces a signature on the provided message. // This assumes the privkey is wellformed in the golang format. @@ -81,7 +77,6 @@ func (privKey *PrivKey) Type() string { return keyType } - // MarshalAmino overrides Amino binary marshalling. func (privKey PrivKey) MarshalAmino() ([]byte, error) { return privKey.Key, nil @@ -97,7 +92,6 @@ func (privKey *PrivKey) UnmarshalAmino(bz []byte) error { return nil } - // MarshalAminoJSON overrides Amino JSON marshalling. func (privKey PrivKey) MarshalAminoJSON() ([]byte, error) { // When we marshal to Amino JSON, we don't marshal the "key" field itself, @@ -110,8 +104,6 @@ func (privKey *PrivKey) UnmarshalAminoJSON(bz []byte) error { return privKey.UnmarshalAmino(bz) } - - // GenPrivKey generates a new BLS private key on curve bls12-381 private key. // It uses OS randomness to generate the private key. func GenPrivKey() *PrivKey { @@ -147,7 +139,6 @@ func GenPrivKeyFromSecret(secret []byte) *PrivKey { return &PrivKey{Key: sk_bytes} } - var _ cryptotypes.PubKey = &PubKey{} var _ codec.AminoMarshaler = &PubKey{} @@ -157,7 +148,6 @@ func (pubKey *PubKey) Validate() bool { return pk.KeyValidate() } - // Address is the SHA256-20 of the raw pubkey bytes. func (pubKey *PubKey) Address() crypto.Address { if len(pubKey.Key) != PubKeySize { diff --git a/crypto/keys/bls12381/bls12381_test.go b/crypto/keys/bls12381/bls12381_test.go index c7a9c993aa..48fbd02faf 100644 --- a/crypto/keys/bls12381/bls12381_test.go +++ b/crypto/keys/bls12381/bls12381_test.go @@ -22,7 +22,6 @@ func TestSignAndValidateBls12381(t *testing.T) { } - func BenchmarkSignBls(b *testing.B) { privKey := bls12381.GenPrivKey() @@ -30,9 +29,8 @@ func BenchmarkSignBls(b *testing.B) { } - func BenchmarkVerifyBls(b *testing.B) { privKey := bls12381.GenPrivKey() bench.BenchmarkVerification(b, privKey) -} \ No newline at end of file +} diff --git a/crypto/keys/ed25519/ed25519_test.go b/crypto/keys/ed25519/ed25519_test.go index 4e455c47ad..2291a01de8 100644 --- a/crypto/keys/ed25519/ed25519_test.go +++ b/crypto/keys/ed25519/ed25519_test.go @@ -230,8 +230,6 @@ func TestMarshalAmino_BackwardsCompatibility(t *testing.T) { } } - - func BenchmarkSignEd25519(b *testing.B) { privKey := ed25519.GenPrivKey() @@ -239,9 +237,8 @@ func BenchmarkSignEd25519(b *testing.B) { } - func BenchmarkVerifyEd25519(b *testing.B) { privKey := ed25519.GenPrivKey() bench.BenchmarkVerification(b, privKey) -} \ No newline at end of file +} diff --git a/x/auth/simulation/genesis.go b/x/auth/simulation/genesis.go index 5bb2297f29..c0311e66a2 100644 --- a/x/auth/simulation/genesis.go +++ b/x/auth/simulation/genesis.go @@ -19,7 +19,7 @@ const ( TxSizeCostPerByte = "tx_size_cost_per_byte" SigVerifyCostED25519 = "sig_verify_cost_ed25519" SigVerifyCostSECP256K1 = "sig_verify_cost_secp256k1" - SigVerifyCostBLS12381 = "sig_verify_cost_bls12381" + SigVerifyCostBLS12381 = "sig_verify_cost_bls12381" ) // RandomGenesisAccounts defines the default RandomGenesisAccountsFn used on the SDK. diff --git a/x/auth/types/params.go b/x/auth/types/params.go index fb2a47ec50..632de20cae 100644 --- a/x/auth/types/params.go +++ b/x/auth/types/params.go @@ -15,7 +15,7 @@ const ( DefaultTxSizeCostPerByte uint64 = 10 DefaultSigVerifyCostED25519 uint64 = 590 DefaultSigVerifyCostSecp256k1 uint64 = 1000 - DefaultSigVerifyCostBls12381 uint64 = 6300 + DefaultSigVerifyCostBls12381 uint64 = 6300 ) // Parameter keys @@ -25,7 +25,7 @@ var ( KeyTxSizeCostPerByte = []byte("TxSizeCostPerByte") KeySigVerifyCostED25519 = []byte("SigVerifyCostED25519") KeySigVerifyCostSecp256k1 = []byte("SigVerifyCostSecp256k1") - KeySigVerifyCostBls12381 = []byte("SigVerifyCostBls12381") + KeySigVerifyCostBls12381 = []byte("SigVerifyCostBls12381") ) var _ paramtypes.ParamSet = &Params{} @@ -70,7 +70,7 @@ func DefaultParams() Params { TxSizeCostPerByte: DefaultTxSizeCostPerByte, SigVerifyCostED25519: DefaultSigVerifyCostED25519, SigVerifyCostSecp256k1: DefaultSigVerifyCostSecp256k1, - SigVerifyCostBls12381: DefaultSigVerifyCostBls12381, + SigVerifyCostBls12381: DefaultSigVerifyCostBls12381, } } @@ -119,7 +119,6 @@ func validateSigVerifyCostSecp256k1(i interface{}) error { return nil } - func validateSigVerifyCostBls12381(i interface{}) error { v, ok := i.(uint64) if !ok { From a785d231ed314fbcb5eda2af1db7604dec784fc2 Mon Sep 17 00:00:00 2001 From: kitty Date: Tue, 20 Jul 2021 12:22:29 +0100 Subject: [PATCH 06/34] nuisance golangci-lint errors --- crypto/keys/bls12381/bls12381.go | 24 +++++++++++++----------- x/auth/ante/sigverify.go | 7 ++++--- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/crypto/keys/bls12381/bls12381.go b/crypto/keys/bls12381/bls12381.go index ea13409782..4806b26685 100644 --- a/crypto/keys/bls12381/bls12381.go +++ b/crypto/keys/bls12381/bls12381.go @@ -3,13 +3,14 @@ package bls12381 import ( "crypto/subtle" "fmt" + "io" + "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types/errors" blst "github.com/supranational/blst/bindings/go" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/tmhash" - "io" ) const ( @@ -20,7 +21,8 @@ const ( // PrivKeySize is the size, in bytes, of private keys as used in this package. // Uncompressed public key PrivKeySize = 32 - // Compressed signature + // SignatureSize is the size of a bls signature. Namely the size of a compressed + // G2 point. SignatureSize = 96 keyType = "bls12381" SeedSize = 32 @@ -42,9 +44,9 @@ func (privKey *PrivKey) PubKey() cryptotypes.PubKey { panic("Failed to deserialize secret key!") } pk := new(blst.P1Affine).From(sk) - pk_bytes := pk.Serialize() + pkBytes := pk.Serialize() - return &PubKey{Key: pk_bytes} + return &PubKey{Key: pkBytes} } // Sign produces a signature on the provided message. @@ -62,9 +64,9 @@ func (privKey *PrivKey) Sign(msg []byte) ([]byte, error) { panic("Failed to sign message!") } - sig_bytes := sig.Compress() + sigBytes := sig.Compress() - return sig_bytes, nil + return sigBytes, nil } // Equals - you probably don't need to use this. @@ -123,9 +125,9 @@ func genPrivKey(rand io.Reader) []byte { panic("Failed to generate secret key!") } - sk_bytes := sk.Serialize() + skBytes := sk.Serialize() - return sk_bytes + return skBytes } // GenPrivKeyFromSecret hashes the secret with SHA2, and uses @@ -134,9 +136,9 @@ func genPrivKey(rand io.Reader) []byte { // if it's derived from user input. func GenPrivKeyFromSecret(secret []byte) *PrivKey { ikm := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes. - sk_bytes := blst.KeyGen(ikm[:]).Serialize() + skBytes := blst.KeyGen(ikm).Serialize() - return &PrivKey{Key: sk_bytes} + return &PrivKey{Key: skBytes} } var _ cryptotypes.PubKey = &PubKey{} @@ -161,7 +163,7 @@ func (pubKey *PubKey) Bytes() []byte { return pubKey.Key } -// Assume public key is validated +// VerifySignature assumes public key is already validated func (pubKey *PubKey) VerifySignature(msg []byte, sig []byte) bool { // make sure we use the same algorithm to sign pk := new(blst.P1Affine).Deserialize(pubKey.Key) diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 223d81b296..428b9f97bb 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/hex" "fmt" + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" @@ -84,9 +85,9 @@ func (spkd SetPubKeyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate b continue } - //Validate public key for bls12381 so that the public key only needs to be checked once - switch pubkey := pk.(type) { - case *bls12381.PubKey: + // Validate public key for bls12381 so that the public key only needs to be checked once + pubkey, ok := pk.(*bls12381.PubKey) + if ok { if !pubkey.Validate() { return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, "Invalid public key: either infinity or not subgroup element") } From d0d67e5274466f050692f9603eba9b51c42da679 Mon Sep 17 00:00:00 2001 From: kitounliu <58184672+kitounliu@users.noreply.github.com> Date: Tue, 20 Jul 2021 17:14:58 +0100 Subject: [PATCH 07/34] Bls (#104) * bls signature for basic account * benchmark for bls and ed25519 * added bls sig verify cost to genesis * Revert "Merge branch 'fetchai:master' into bls" This reverts commit a5dd8ea9c1597c285e9375f168dd7af51e76f6b3, reversing changes made to 082e0710e3dd2f96733e76f8e2f928c2d7e4ab29. * format using go tools * nuisance golangci-lint errors --- crypto/codec/amino.go | 5 + crypto/codec/proto.go | 2 + crypto/hd/algo.go | 42 ++ crypto/keyring/keyring.go | 2 +- crypto/keys/bls12381/bls12381.go | 225 +++++++++++ crypto/keys/bls12381/bls12381_test.go | 36 ++ crypto/keys/bls12381/keys.pb.go | 496 ++++++++++++++++++++++++ crypto/keys/ed25519/ed25519_test.go | 14 + go.mod | 1 + go.sum | 2 + proto/cosmos/auth/v1beta1/auth.proto | 3 + proto/cosmos/crypto/bls12381/keys.proto | 22 ++ x/airdrop/keeper/keeper_test.go | 84 +--- x/airdrop/types/genesis_test.go | 63 --- x/auth/ante/sigverify.go | 14 + x/auth/simulation/genesis.go | 14 +- x/auth/types/auth.pb.go | 128 +++--- x/auth/types/params.go | 23 +- 18 files changed, 983 insertions(+), 193 deletions(-) create mode 100644 crypto/keys/bls12381/bls12381.go create mode 100644 crypto/keys/bls12381/bls12381_test.go create mode 100644 crypto/keys/bls12381/keys.pb.go create mode 100644 proto/cosmos/crypto/bls12381/keys.proto delete mode 100644 x/airdrop/types/genesis_test.go diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go index d50a08864c..0043c6855c 100644 --- a/crypto/codec/amino.go +++ b/crypto/codec/amino.go @@ -1,6 +1,7 @@ package codec import ( + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" "github.com/tendermint/tendermint/crypto/sr25519" "github.com/cosmos/cosmos-sdk/codec" @@ -22,6 +23,8 @@ func RegisterCrypto(cdc *codec.LegacyAmino) { secp256k1.PubKeyName, nil) cdc.RegisterConcrete(&kmultisig.LegacyAminoPubKey{}, kmultisig.PubKeyAminoRoute, nil) + cdc.RegisterConcrete(&bls12381.PubKey{}, + bls12381.PubKeyName, nil) cdc.RegisterInterface((*cryptotypes.PrivKey)(nil), nil) cdc.RegisterConcrete(sr25519.PrivKey{}, @@ -30,4 +33,6 @@ func RegisterCrypto(cdc *codec.LegacyAmino) { ed25519.PrivKeyName, nil) cdc.RegisterConcrete(&secp256k1.PrivKey{}, secp256k1.PrivKeyName, nil) + cdc.RegisterConcrete(&bls12381.PrivKey{}, + bls12381.PrivKeyName, nil) } diff --git a/crypto/codec/proto.go b/crypto/codec/proto.go index 9c07ca1105..6bdac15ab6 100644 --- a/crypto/codec/proto.go +++ b/crypto/codec/proto.go @@ -2,6 +2,7 @@ package codec import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -14,4 +15,5 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &ed25519.PubKey{}) registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &secp256k1.PubKey{}) registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &multisig.LegacyAminoPubKey{}) + registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &bls12381.PubKey{}) } diff --git a/crypto/hd/algo.go b/crypto/hd/algo.go index f934ad08ae..fcd4851996 100644 --- a/crypto/hd/algo.go +++ b/crypto/hd/algo.go @@ -1,6 +1,7 @@ package hd import ( + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" bip39 "github.com/cosmos/go-bip39" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -20,11 +21,15 @@ const ( Ed25519Type = PubKeyType("ed25519") // Sr25519Type represents the Sr25519Type signature system. Sr25519Type = PubKeyType("sr25519") + // Bls12381Type represents the Bls12381Type signature system. + Bls12381Type = PubKeyType("bls12381") ) var ( // Secp256k1 uses the Bitcoin secp256k1 ECDSA parameters. Secp256k1 = secp256k1Algo{} + // Bls12381 uses blst implememtation of bls signatures + Bls12381 = bls12381Algo{} ) type DeriveFn func(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error) @@ -69,3 +74,40 @@ func (s secp256k1Algo) Generate() GenerateFn { return &secp256k1.PrivKey{Key: bzArr} } } + +type bls12381Algo struct { +} + +func (s bls12381Algo) Name() PubKeyType { + return Bls12381Type +} + +// todo: replace bitcoin private key generation +// Derive derives and returns the bls12381 private key for the given seed and HD path. +func (s bls12381Algo) Derive() DeriveFn { + return func(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error) { + seed, err := bip39.NewSeedWithErrorChecking(mnemonic, bip39Passphrase) + if err != nil { + return nil, err + } + + masterPriv, ch := ComputeMastersFromSeed(seed) + if len(hdPath) == 0 { + return masterPriv[:], nil + } + derivedKey, err := DerivePrivateKeyForPath(masterPriv, ch, hdPath) + + return derivedKey, err + } +} + +// Generate generates a bls12381 private key from the given bytes. +func (s bls12381Algo) Generate() GenerateFn { + return func(bz []byte) types.PrivKey { + var bzArr = make([]byte, bls12381.SeedSize) + copy(bzArr, bz) + sk := bls12381.GenPrivKeyFromSecret(bzArr) + + return sk + } +} diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go index febad555df..25a0a7dcb2 100644 --- a/crypto/keyring/keyring.go +++ b/crypto/keyring/keyring.go @@ -200,7 +200,7 @@ type keystore struct { func newKeystore(kr keyring.Keyring, opts ...Option) keystore { // Default options for keybase options := Options{ - SupportedAlgos: SigningAlgoList{hd.Secp256k1}, + SupportedAlgos: SigningAlgoList{hd.Secp256k1, hd.Bls12381}, SupportedAlgosLedger: SigningAlgoList{hd.Secp256k1}, } diff --git a/crypto/keys/bls12381/bls12381.go b/crypto/keys/bls12381/bls12381.go new file mode 100644 index 0000000000..4806b26685 --- /dev/null +++ b/crypto/keys/bls12381/bls12381.go @@ -0,0 +1,225 @@ +package bls12381 + +import ( + "crypto/subtle" + "fmt" + "io" + + "github.com/cosmos/cosmos-sdk/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/types/errors" + blst "github.com/supranational/blst/bindings/go" + "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/tmhash" +) + +const ( + PrivKeyName = "tendermint/PrivKeyBls12381" + PubKeyName = "tendermint/PubKeyBls12381" + // PubKeySize is is the size, in bytes, of public keys as used in this package. + PubKeySize = 96 + // PrivKeySize is the size, in bytes, of private keys as used in this package. + // Uncompressed public key + PrivKeySize = 32 + // SignatureSize is the size of a bls signature. Namely the size of a compressed + // G2 point. + SignatureSize = 96 + keyType = "bls12381" + SeedSize = 32 +) + +var _ cryptotypes.PrivKey = &PrivKey{} +var _ codec.AminoMarshaler = &PrivKey{} + +// Bytes returns the byte representation of the Private Key. +func (privKey *PrivKey) Bytes() []byte { + return privKey.Key +} + +// PubKey performs the point-scalar multiplication from the privKey on the +// generator point to get the pubkey. +func (privKey *PrivKey) PubKey() cryptotypes.PubKey { + sk := new(blst.SecretKey).Deserialize(privKey.Key) + if sk == nil { + panic("Failed to deserialize secret key!") + } + pk := new(blst.P1Affine).From(sk) + pkBytes := pk.Serialize() + + return &PubKey{Key: pkBytes} +} + +// Sign produces a signature on the provided message. +// This assumes the privkey is wellformed in the golang format. + +func (privKey *PrivKey) Sign(msg []byte) ([]byte, error) { + dst := []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_") + sk := new(blst.SecretKey).Deserialize(privKey.Key) + if sk == nil { + panic("Failed to deserialize secret key!") + } + + sig := new(blst.P2Affine).Sign(sk, msg, dst) + if sig == nil { + panic("Failed to sign message!") + } + + sigBytes := sig.Compress() + + return sigBytes, nil +} + +// Equals - you probably don't need to use this. +// Runs in constant time based on length of the +func (privKey *PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool { + return privKey.Type() == other.Type() && subtle.ConstantTimeCompare(privKey.Bytes(), other.Bytes()) == 1 +} + +func (privKey *PrivKey) Type() string { + return keyType +} + +// MarshalAmino overrides Amino binary marshalling. +func (privKey PrivKey) MarshalAmino() ([]byte, error) { + return privKey.Key, nil +} + +// UnmarshalAmino overrides Amino binary marshalling. +func (privKey *PrivKey) UnmarshalAmino(bz []byte) error { + if len(bz) != PrivKeySize { + return fmt.Errorf("invalid privkey size") + } + privKey.Key = bz + + return nil +} + +// MarshalAminoJSON overrides Amino JSON marshalling. +func (privKey PrivKey) MarshalAminoJSON() ([]byte, error) { + // When we marshal to Amino JSON, we don't marshal the "key" field itself, + // just its contents (i.e. the key bytes). + return privKey.MarshalAmino() +} + +// UnmarshalAminoJSON overrides Amino JSON marshalling. +func (privKey *PrivKey) UnmarshalAminoJSON(bz []byte) error { + return privKey.UnmarshalAmino(bz) +} + +// GenPrivKey generates a new BLS private key on curve bls12-381 private key. +// It uses OS randomness to generate the private key. +func GenPrivKey() *PrivKey { + return &PrivKey{Key: genPrivKey(crypto.CReader())} +} + +// genPrivKey generates a new secp256k1 private key using the provided reader. +func genPrivKey(rand io.Reader) []byte { + var ikm [SeedSize]byte + _, err := io.ReadFull(rand, ikm[:]) + if err != nil { + panic(err) + } + + sk := blst.KeyGen(ikm[:]) + if sk == nil { + panic("Failed to generate secret key!") + } + + skBytes := sk.Serialize() + + return skBytes +} + +// GenPrivKeyFromSecret hashes the secret with SHA2, and uses +// that 32 byte output to create the private key. +// NOTE: secret should be the output of a KDF like bcrypt, +// if it's derived from user input. +func GenPrivKeyFromSecret(secret []byte) *PrivKey { + ikm := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes. + skBytes := blst.KeyGen(ikm).Serialize() + + return &PrivKey{Key: skBytes} +} + +var _ cryptotypes.PubKey = &PubKey{} +var _ codec.AminoMarshaler = &PubKey{} + +// Validate public key, infinity and subgroup checking +func (pubKey *PubKey) Validate() bool { + pk := new(blst.P1Affine).Deserialize(pubKey.Key) + return pk.KeyValidate() +} + +// Address is the SHA256-20 of the raw pubkey bytes. +func (pubKey *PubKey) Address() crypto.Address { + if len(pubKey.Key) != PubKeySize { + panic("pubkey is incorrect size") + } + return crypto.Address(tmhash.SumTruncated(pubKey.Key)) +} + +// Bytes returns the PubKey byte format. +func (pubKey *PubKey) Bytes() []byte { + return pubKey.Key +} + +// VerifySignature assumes public key is already validated +func (pubKey *PubKey) VerifySignature(msg []byte, sig []byte) bool { + // make sure we use the same algorithm to sign + pk := new(blst.P1Affine).Deserialize(pubKey.Key) + if pk == nil { + panic("Failed to deserialize public key") + } + + sigma := new(blst.P2Affine).Uncompress(sig) + if sigma == nil { + panic("Failed to deserialize signature") + } + + dst := []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_") + + return sigma.Verify(true, pk, false, msg, dst) +} + +func (pubKey *PubKey) String() string { + return fmt.Sprintf("PubKeyBls12381{%X}", pubKey.Key) +} + +func (pubKey *PubKey) Type() string { + return keyType +} + +func (pubKey *PubKey) Equals(other cryptotypes.PubKey) bool { + if pubKey.Type() != other.Type() { + return false + } + + return subtle.ConstantTimeCompare(pubKey.Bytes(), other.Bytes()) == 1 +} + +// MarshalAmino overrides Amino binary marshalling. +func (pubKey PubKey) MarshalAmino() ([]byte, error) { + return pubKey.Key, nil +} + +// UnmarshalAmino overrides Amino binary marshalling. +func (pubKey *PubKey) UnmarshalAmino(bz []byte) error { + if len(bz) != PubKeySize { + return errors.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size") + } + pubKey.Key = bz + + return nil +} + +// MarshalAminoJSON overrides Amino JSON marshalling. +func (pubKey PubKey) MarshalAminoJSON() ([]byte, error) { + // When we marshal to Amino JSON, we don't marshal the "key" field itself, + // just its contents (i.e. the key bytes). + return pubKey.MarshalAmino() +} + +// UnmarshalAminoJSON overrides Amino JSON marshalling. +func (pubKey *PubKey) UnmarshalAminoJSON(bz []byte) error { + return pubKey.UnmarshalAmino(bz) +} diff --git a/crypto/keys/bls12381/bls12381_test.go b/crypto/keys/bls12381/bls12381_test.go new file mode 100644 index 0000000000..48fbd02faf --- /dev/null +++ b/crypto/keys/bls12381/bls12381_test.go @@ -0,0 +1,36 @@ +package bls12381_test + +import ( + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" + bench "github.com/cosmos/cosmos-sdk/crypto/keys/internal/benchmarking" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto" + "testing" +) + +func TestSignAndValidateBls12381(t *testing.T) { + privKey := bls12381.GenPrivKey() + pubKey := privKey.PubKey() + + msg := crypto.CRandBytes(1000) + sig, err := privKey.Sign(msg) + require.Nil(t, err) + + // Test the signature + assert.True(t, pubKey.VerifySignature(msg, sig)) + +} + +func BenchmarkSignBls(b *testing.B) { + privKey := bls12381.GenPrivKey() + + bench.BenchmarkSigning(b, privKey) + +} + +func BenchmarkVerifyBls(b *testing.B) { + privKey := bls12381.GenPrivKey() + + bench.BenchmarkVerification(b, privKey) +} diff --git a/crypto/keys/bls12381/keys.pb.go b/crypto/keys/bls12381/keys.pb.go new file mode 100644 index 0000000000..9a7569ca71 --- /dev/null +++ b/crypto/keys/bls12381/keys.pb.go @@ -0,0 +1,496 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/crypto/bls12381/keys.proto + +package bls12381 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/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 + +// PubKey defines a bls public key +// Key is the uncompressed form of the pubkey. The first byte depends is a 0x02 byte +// if the y-coordinate is the lexicographically largest of the two associated with +// the x-coordinate. Otherwise the first byte is a 0x03. +// This prefix is followed with the x-coordinate. +type PubKey struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *PubKey) Reset() { *m = PubKey{} } +func (*PubKey) ProtoMessage() {} +func (*PubKey) Descriptor() ([]byte, []int) { + return fileDescriptor_295d2962e809fcdb, []int{0} +} +func (m *PubKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PubKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PubKey.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 *PubKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PubKey.Merge(m, src) +} +func (m *PubKey) XXX_Size() int { + return m.Size() +} +func (m *PubKey) XXX_DiscardUnknown() { + xxx_messageInfo_PubKey.DiscardUnknown(m) +} + +var xxx_messageInfo_PubKey proto.InternalMessageInfo + +func (m *PubKey) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +// PrivKey defines a bls private key. +type PrivKey struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *PrivKey) Reset() { *m = PrivKey{} } +func (m *PrivKey) String() string { return proto.CompactTextString(m) } +func (*PrivKey) ProtoMessage() {} +func (*PrivKey) Descriptor() ([]byte, []int) { + return fileDescriptor_295d2962e809fcdb, []int{1} +} +func (m *PrivKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PrivKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PrivKey.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 *PrivKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PrivKey.Merge(m, src) +} +func (m *PrivKey) XXX_Size() int { + return m.Size() +} +func (m *PrivKey) XXX_DiscardUnknown() { + xxx_messageInfo_PrivKey.DiscardUnknown(m) +} + +var xxx_messageInfo_PrivKey proto.InternalMessageInfo + +func (m *PrivKey) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func init() { + proto.RegisterType((*PubKey)(nil), "cosmos.crypto.bls12381.PubKey") + proto.RegisterType((*PrivKey)(nil), "cosmos.crypto.bls12381.PrivKey") +} + +func init() { proto.RegisterFile("cosmos/crypto/bls12381/keys.proto", fileDescriptor_295d2962e809fcdb) } + +var fileDescriptor_295d2962e809fcdb = []byte{ + // 184 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0xd7, 0x4f, 0xca, 0x29, 0x36, 0x34, 0x32, + 0xb6, 0x30, 0xd4, 0xcf, 0x4e, 0xad, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x83, + 0x28, 0xd1, 0x83, 0x28, 0xd1, 0x83, 0x29, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd1, + 0x07, 0xb1, 0x20, 0xaa, 0x95, 0x14, 0xb8, 0xd8, 0x02, 0x4a, 0x93, 0xbc, 0x53, 0x2b, 0x85, 0x04, + 0xb8, 0x98, 0xb3, 0x53, 0x2b, 0x25, 0x18, 0x15, 0x18, 0x35, 0x78, 0x82, 0x40, 0x4c, 0x2b, 0x96, + 0x19, 0x0b, 0xe4, 0x19, 0x94, 0xa4, 0xb9, 0xd8, 0x03, 0x8a, 0x32, 0xcb, 0xb0, 0x2a, 0x71, 0xf2, + 0x3e, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, + 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xc3, 0xf4, 0xcc, 0x92, 0x8c, + 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x98, 0xa3, 0xc1, 0x94, 0x6e, 0x71, 0x4a, 0x36, 0xcc, + 0xfd, 0x20, 0x67, 0xc3, 0x3d, 0x91, 0xc4, 0x06, 0x76, 0x92, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, + 0x0e, 0x2e, 0xb6, 0x08, 0xe5, 0x00, 0x00, 0x00, +} + +func (m *PubKey) 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 *PubKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PubKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintKeys(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PrivKey) 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 *PrivKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PrivKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintKeys(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintKeys(dAtA []byte, offset int, v uint64) int { + offset -= sovKeys(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PubKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovKeys(uint64(l)) + } + return n +} + +func (m *PrivKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovKeys(uint64(l)) + } + return n +} + +func sovKeys(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozKeys(x uint64) (n int) { + return sovKeys(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PubKey) 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 ErrIntOverflowKeys + } + 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: PubKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PubKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeys + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthKeys + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthKeys + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipKeys(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthKeys + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PrivKey) 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 ErrIntOverflowKeys + } + 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: PrivKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PrivKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeys + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthKeys + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthKeys + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipKeys(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthKeys + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipKeys(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, ErrIntOverflowKeys + } + 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, ErrIntOverflowKeys + } + 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, ErrIntOverflowKeys + } + 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, ErrInvalidLengthKeys + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupKeys + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthKeys + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthKeys = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowKeys = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupKeys = fmt.Errorf("proto: unexpected end of group") +) diff --git a/crypto/keys/ed25519/ed25519_test.go b/crypto/keys/ed25519/ed25519_test.go index 59cce4066a..2291a01de8 100644 --- a/crypto/keys/ed25519/ed25519_test.go +++ b/crypto/keys/ed25519/ed25519_test.go @@ -3,6 +3,7 @@ package ed25519_test import ( stded25519 "crypto/ed25519" "encoding/base64" + bench "github.com/cosmos/cosmos-sdk/crypto/keys/internal/benchmarking" "testing" "github.com/stretchr/testify/assert" @@ -228,3 +229,16 @@ func TestMarshalAmino_BackwardsCompatibility(t *testing.T) { }) } } + +func BenchmarkSignEd25519(b *testing.B) { + privKey := ed25519.GenPrivKey() + + bench.BenchmarkSigning(b, privKey) + +} + +func BenchmarkVerifyEd25519(b *testing.B) { + privKey := ed25519.GenPrivKey() + + bench.BenchmarkVerification(b, privKey) +} diff --git a/go.mod b/go.mod index 4f83be4fc3..ee4bb40e80 100644 --- a/go.mod +++ b/go.mod @@ -45,6 +45,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.7.0 + github.com/supranational/blst v0.3.4 github.com/tendermint/btcd v0.1.1 github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 github.com/tendermint/go-amino v0.16.0 diff --git a/go.sum b/go.sum index 0274c8cf10..b382b59e32 100644 --- a/go.sum +++ b/go.sum @@ -543,6 +543,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/supranational/blst v0.3.4 h1:iZE9lBMoywK2uy2U/5hDOvobQk9FnOQ2wNlu9GmRCoA= +github.com/supranational/blst v0.3.4/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca h1:Ld/zXl5t4+D69SiV4JoN7kkfvJdOWlPpfxrzxpLMoUk= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= diff --git a/proto/cosmos/auth/v1beta1/auth.proto b/proto/cosmos/auth/v1beta1/auth.proto index 72e1d9ec28..799568c186 100644 --- a/proto/cosmos/auth/v1beta1/auth.proto +++ b/proto/cosmos/auth/v1beta1/auth.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package cosmos.auth.v1beta1; import "cosmos_proto/cosmos.proto"; +//import "cosmos.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; @@ -47,4 +48,6 @@ message Params { [(gogoproto.customname) = "SigVerifyCostED25519", (gogoproto.moretags) = "yaml:\"sig_verify_cost_ed25519\""]; uint64 sig_verify_cost_secp256k1 = 5 [(gogoproto.customname) = "SigVerifyCostSecp256k1", (gogoproto.moretags) = "yaml:\"sig_verify_cost_secp256k1\""]; + uint64 sig_verify_cost_bls12381 = 6 + [(gogoproto.customname) = "SigVerifyCostBls12381", (gogoproto.moretags) = "yaml:\"sig_verify_cost_bls12381\""]; } diff --git a/proto/cosmos/crypto/bls12381/keys.proto b/proto/cosmos/crypto/bls12381/keys.proto new file mode 100644 index 0000000000..54740c32c9 --- /dev/null +++ b/proto/cosmos/crypto/bls12381/keys.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package cosmos.crypto.bls12381; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381"; + +// PubKey defines a bls public key +// Key is the uncompressed form of the pubkey. The first byte depends is a 0x02 byte +// if the y-coordinate is the lexicographically largest of the two associated with +// the x-coordinate. Otherwise the first byte is a 0x03. +// This prefix is followed with the x-coordinate. +message PubKey { + option (gogoproto.goproto_stringer) = false; + + bytes key = 1; +} + +// PrivKey defines a bls private key. +message PrivKey { + bytes key = 1; +} \ No newline at end of file diff --git a/x/airdrop/keeper/keeper_test.go b/x/airdrop/keeper/keeper_test.go index 08c9b82f5a..2a06749817 100644 --- a/x/airdrop/keeper/keeper_test.go +++ b/x/airdrop/keeper/keeper_test.go @@ -18,8 +18,6 @@ var ( feeCollectorAddress = authtypes.NewModuleAddress(authtypes.FeeCollectorName) addr1 = sdk.AccAddress([]byte("addr1_______________")) addr2 = sdk.AccAddress([]byte("addr2_______________")) - addr3 = sdk.AccAddress([]byte("addr3_______________")) - addr4 = sdk.AccAddress([]byte("addr4_______________")) ) type KeeperTestSuite struct { @@ -37,10 +35,9 @@ func (s *KeeperTestSuite) SetupTest() { Height: 10, }) - s.app.AirdropKeeper.SetParams(s.ctx, types.NewParams(addr1.String(), addr2.String(), addr3.String(), addr4.String())) + s.app.AirdropKeeper.SetParams(s.ctx, types.NewParams(addr1.String(), addr2.String())) } - func (s *KeeperTestSuite) TestAddNewFund() { amount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 4000) s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr1, amount)) // ensure the account is funded @@ -168,85 +165,6 @@ func (s *KeeperTestSuite) TestFeeDrip() { s.Require().Equal(feeCollectorBalance, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(4040))) } -func (s *KeeperTestSuite) TestAddNewFundWithDiffDenom() { - amount := sdk.NewInt64Coin("denom", 4000) - s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr1, amount)) // ensure the account is funded - - addrBalance := s.app.BankKeeper.GetBalance(s.ctx, addr1, "denom") - moduleBalance := s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, "denom") - - // sanity check - s.Require().Equal(addrBalance, sdk.NewCoin("denom", sdk.NewInt(4000))) - s.Require().Equal(moduleBalance, sdk.NewCoin("denom", sdk.NewInt(0))) - - fund := types.Fund{ - Amount: &amount, - DripAmount: sdk.NewInt(40), - } - s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr1, fund)) - - addrBalance = s.app.BankKeeper.GetBalance(s.ctx, addr1, "denom") - moduleBalance = s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, "denom") - - s.Require().Equal(addrBalance, sdk.NewCoin("denom", sdk.NewInt(0))) - s.Require().Equal(moduleBalance, sdk.NewCoin("denom", sdk.NewInt(4000))) -} - -func (s *KeeperTestSuite) TestMultiDenomFeeDrip() { - amountStake := sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000) - amountDenom := sdk.NewInt64Coin("denom", 1000) - fund1 := types.Fund{ - Amount: &amountStake, - DripAmount: sdk.NewInt(500)} - - fund2 := types.Fund{ - Amount: &amountStake, - DripAmount: sdk.NewInt(800), - } - - fund3 := types.Fund{ - Amount: &amountDenom, - DripAmount: sdk.NewInt(100)} - - fund4 := types.Fund{ - Amount: &amountDenom, - DripAmount: sdk.NewInt(300), - } - s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr1, amountStake)) - s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr2, amountStake)) - s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr3, amountDenom)) - s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr4, amountDenom)) - - s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr1, fund1)) - s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr2, fund2)) - s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr3, fund3)) - s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr4, fund4)) // check the balances - - moduleBalanceStake := s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, sdk.DefaultBondDenom) - moduleBalanceDenom := s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, "denom") - feeCollectorBalanceStake := s.app.BankKeeper.GetBalance(s.ctx, feeCollectorAddress, sdk.DefaultBondDenom) - feeCollectorBalanceDenom := s.app.BankKeeper.GetBalance(s.ctx, feeCollectorAddress, "denom") - - s.Require().Equal(moduleBalanceStake, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(2000))) - s.Require().Equal(moduleBalanceDenom, sdk.NewCoin("denom", sdk.NewInt(2000))) - s.Require().Equal(feeCollectorBalanceStake, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0))) - s.Require().Equal(feeCollectorBalanceDenom, sdk.NewCoin("denom", sdk.NewInt(0))) - - _, err := s.app.AirdropKeeper.DripAllFunds(s.ctx) // test case - drip the funds - s.Require().NoError(err) // check that the fees have been transferred - - moduleBalanceStake = s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, sdk.DefaultBondDenom) - moduleBalanceDenom = s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, "denom") - feeCollectorBalanceStake = s.app.BankKeeper.GetBalance(s.ctx, feeCollectorAddress, sdk.DefaultBondDenom) - feeCollectorBalanceDenom = s.app.BankKeeper.GetBalance(s.ctx, feeCollectorAddress, "denom") - - s.Require().Equal(feeCollectorBalanceStake, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1300))) // 800 drip fund 1, 500 drip fund 2 - s.Require().Equal(feeCollectorBalanceDenom, sdk.NewCoin("denom", sdk.NewInt(400))) // 100 drip fund 3, 300 drip fund 4 - s.Require().Equal(moduleBalanceStake, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(700))) // remainder 500 from fund 1, remainder 200 from fund 2 - s.Require().Equal(moduleBalanceDenom, sdk.NewCoin("denom", sdk.NewInt(1600))) // remainder 900 from fund 3, remainder 700 from fund 4 - -} - func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(KeeperTestSuite)) } diff --git a/x/airdrop/types/genesis_test.go b/x/airdrop/types/genesis_test.go deleted file mode 100644 index 901770b719..0000000000 --- a/x/airdrop/types/genesis_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/x/airdrop/types" - "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var ( - addr = sdk.AccAddress([]byte("addr________________")) - invalidAddr = sdk.AccAddress([]byte("\n\n\n\n\taddr________________\t\n\n\n\n\n")) -) - -func TestNewGenesisState(t *testing.T) { - p := types.NewParams() - expectedFunds := []types.ActiveFund{ - { - Sender: addr.String(), - Fund: &types.Fund{ - Amount: &sdk.Coin{Denom: "test", Amount: sdk.NewInt(10)}, - DripAmount: sdk.NewInt(1), - }, - }, - } - expectedState := &types.GenesisState{ - Params: p, - Funds: expectedFunds, - } - require.Equal(t, expectedState.GetFunds(), expectedFunds) - require.Equal(t, expectedState.Params, p) -} - -func TestValidateGenesisState(t *testing.T) { - p1 := types.Params{ - AllowList: []string{ - addr.String(), // valid address - }, - } - p2 := types.Params{ - AllowList: []string{ - invalidAddr.String(), // invalid address - }, - } - funds := []types.ActiveFund{ - { - Sender: addr.String(), - Fund: &types.Fund{ - Amount: &sdk.Coin{ - Denom: "test", - Amount: sdk.NewInt(10), - }, - DripAmount: sdk.NewInt(1), - }, - }, - } - gen1 := types.NewGenesisState(p1, funds) - gen2 := types.NewGenesisState(p2, funds) - require.NoError(t, gen1.Validate()) - require.Error(t, gen2.Validate()) -} \ No newline at end of file diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 79fbbcdc67..428b9f97bb 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -5,6 +5,7 @@ import ( "encoding/hex" "fmt" + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -83,6 +84,15 @@ func (spkd SetPubKeyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate b if acc.GetPubKey() != nil { continue } + + // Validate public key for bls12381 so that the public key only needs to be checked once + pubkey, ok := pk.(*bls12381.PubKey) + if ok { + if !pubkey.Validate() { + return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, "Invalid public key: either infinity or not subgroup element") + } + } + err = acc.SetPubKey(pk) if err != nil { return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, err.Error()) @@ -379,6 +389,10 @@ func DefaultSigVerificationGasConsumer( } return nil + case *bls12381.PubKey: + meter.ConsumeGas(params.SigVerifyCostBls12381, "ante verify: bls12381") + return nil + default: return sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey) } diff --git a/x/auth/simulation/genesis.go b/x/auth/simulation/genesis.go index 2da36b54fa..c0311e66a2 100644 --- a/x/auth/simulation/genesis.go +++ b/x/auth/simulation/genesis.go @@ -19,6 +19,7 @@ const ( TxSizeCostPerByte = "tx_size_cost_per_byte" SigVerifyCostED25519 = "sig_verify_cost_ed25519" SigVerifyCostSECP256K1 = "sig_verify_cost_secp256k1" + SigVerifyCostBLS12381 = "sig_verify_cost_bls12381" ) // RandomGenesisAccounts defines the default RandomGenesisAccountsFn used on the SDK. @@ -87,6 +88,11 @@ func GenSigVerifyCostSECP256K1(r *rand.Rand) uint64 { return uint64(simulation.RandIntBetween(r, 500, 1000)) } +// GenSigVerifyCostBLS12381 randomized SigVerifyCostBLS12381 +func GenSigVerifyCostBLS12381(r *rand.Rand) uint64 { + return uint64(simulation.RandIntBetween(r, 6000, 12000)) +} + // RandomizedGenState generates a random GenesisState for auth func RandomizedGenState(simState *module.SimulationState, randGenAccountsFn types.RandomGenesisAccountsFn) { var maxMemoChars uint64 @@ -119,8 +125,14 @@ func RandomizedGenState(simState *module.SimulationState, randGenAccountsFn type func(r *rand.Rand) { sigVerifyCostSECP256K1 = GenSigVerifyCostSECP256K1(r) }, ) + var sigVerifyCostBLS12381 uint64 + simState.AppParams.GetOrGenerate( + simState.Cdc, SigVerifyCostBLS12381, &sigVerifyCostBLS12381, simState.Rand, + func(r *rand.Rand) { sigVerifyCostBLS12381 = GenSigVerifyCostBLS12381(r) }, + ) + params := types.NewParams(maxMemoChars, txSigLimit, txSizeCostPerByte, - sigVerifyCostED25519, sigVerifyCostSECP256K1) + sigVerifyCostED25519, sigVerifyCostSECP256K1, sigVerifyCostBLS12381) genesisAccs := randGenAccountsFn(simState) authGenesis := types.NewGenesisState(params, genesisAccs) diff --git a/x/auth/types/auth.pb.go b/x/auth/types/auth.pb.go index fa52ac5a8b..ad2283b816 100644 --- a/x/auth/types/auth.pb.go +++ b/x/auth/types/auth.pb.go @@ -113,6 +113,7 @@ type Params struct { TxSizeCostPerByte uint64 `protobuf:"varint,3,opt,name=tx_size_cost_per_byte,json=txSizeCostPerByte,proto3" json:"tx_size_cost_per_byte,omitempty" yaml:"tx_size_cost_per_byte"` SigVerifyCostED25519 uint64 `protobuf:"varint,4,opt,name=sig_verify_cost_ed25519,json=sigVerifyCostEd25519,proto3" json:"sig_verify_cost_ed25519,omitempty" yaml:"sig_verify_cost_ed25519"` SigVerifyCostSecp256k1 uint64 `protobuf:"varint,5,opt,name=sig_verify_cost_secp256k1,json=sigVerifyCostSecp256k1,proto3" json:"sig_verify_cost_secp256k1,omitempty" yaml:"sig_verify_cost_secp256k1"` + SigVerifyCostBls12381 uint64 `protobuf:"varint,6,opt,name=sig_verify_cost_bls12381,json=sigVerifyCostBls12381,proto3" json:"sig_verify_cost_bls12381,omitempty" yaml:"sig_verify_cost_bls12381"` } func (m *Params) Reset() { *m = Params{} } @@ -182,6 +183,13 @@ func (m *Params) GetSigVerifyCostSecp256k1() uint64 { return 0 } +func (m *Params) GetSigVerifyCostBls12381() uint64 { + if m != nil { + return m.SigVerifyCostBls12381 + } + return 0 +} + func init() { proto.RegisterType((*BaseAccount)(nil), "cosmos.auth.v1beta1.BaseAccount") proto.RegisterType((*ModuleAccount)(nil), "cosmos.auth.v1beta1.ModuleAccount") @@ -191,50 +199,52 @@ func init() { func init() { proto.RegisterFile("cosmos/auth/v1beta1/auth.proto", fileDescriptor_7e1f7e915d020d2d) } var fileDescriptor_7e1f7e915d020d2d = []byte{ - // 674 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x4d, 0x4f, 0xdb, 0x4a, - 0x14, 0x8d, 0x5f, 0xf2, 0xf8, 0x98, 0x00, 0x12, 0x26, 0x80, 0x93, 0xf7, 0x64, 0x5b, 0x5e, 0xe5, - 0x49, 0x2f, 0x8e, 0x92, 0x8a, 0x4a, 0x64, 0x51, 0x15, 0xd3, 0x2e, 0x50, 0x0b, 0x42, 0x46, 0xea, - 0xa2, 0xaa, 0xe4, 0x8e, 0x9d, 0xc1, 0x58, 0x64, 0x32, 0xc6, 0x33, 0x46, 0x31, 0xbf, 0xa0, 0xcb, - 0x2e, 0xbb, 0xe4, 0x47, 0xf0, 0x0f, 0xba, 0xe9, 0x12, 0xb1, 0xea, 0xca, 0xad, 0xc2, 0xa6, 0xea, - 0x32, 0xfb, 0x4a, 0x95, 0x67, 0x9c, 0x90, 0xa0, 0x74, 0x95, 0xb9, 0xe7, 0x9c, 0x7b, 0xee, 0x9d, - 0x7b, 0xe3, 0x01, 0xaa, 0x47, 0x28, 0x26, 0xb4, 0x09, 0x63, 0x76, 0xd6, 0xbc, 0x6c, 0xb9, 0x88, - 0xc1, 0x16, 0x0f, 0xcc, 0x30, 0x22, 0x8c, 0xc8, 0x1b, 0x82, 0x37, 0x39, 0x94, 0xf3, 0xb5, 0xaa, - 0x00, 0x1d, 0x2e, 0x69, 0xe6, 0x0a, 0x1e, 0xd4, 0x2a, 0x3e, 0xf1, 0x89, 0xc0, 0xb3, 0x53, 0x8e, - 0x56, 0x7d, 0x42, 0xfc, 0x1e, 0x6a, 0xf2, 0xc8, 0x8d, 0x4f, 0x9b, 0xb0, 0x9f, 0x08, 0xca, 0xf8, - 0x25, 0x81, 0xb2, 0x05, 0x29, 0xda, 0xf3, 0x3c, 0x12, 0xf7, 0x99, 0xac, 0x80, 0x45, 0xd8, 0xed, - 0x46, 0x88, 0x52, 0x45, 0xd2, 0xa5, 0xfa, 0xb2, 0x3d, 0x0e, 0xe5, 0x77, 0x60, 0x31, 0x8c, 0x5d, - 0xe7, 0x1c, 0x25, 0xca, 0x5f, 0xba, 0x54, 0x2f, 0xb7, 0x2b, 0xa6, 0xb0, 0x35, 0xc7, 0xb6, 0xe6, - 0x5e, 0x3f, 0xb1, 0x1a, 0x3f, 0x53, 0xad, 0x12, 0xc6, 0x6e, 0x2f, 0xf0, 0x32, 0xed, 0xff, 0x04, - 0x07, 0x0c, 0xe1, 0x90, 0x25, 0xa3, 0x54, 0x5b, 0x4f, 0x20, 0xee, 0x75, 0x8c, 0x07, 0xd6, 0xb0, - 0x17, 0xc2, 0xd8, 0x7d, 0x85, 0x12, 0xf9, 0x39, 0x58, 0x83, 0xa2, 0x05, 0xa7, 0x1f, 0x63, 0x17, - 0x45, 0x4a, 0x51, 0x97, 0xea, 0x25, 0xab, 0x3a, 0x4a, 0xb5, 0x4d, 0x91, 0x36, 0xcb, 0x1b, 0xf6, - 0x6a, 0x0e, 0x1c, 0xf1, 0x58, 0xae, 0x81, 0x25, 0x8a, 0x2e, 0x62, 0xd4, 0xf7, 0x90, 0x52, 0xca, - 0x72, 0xed, 0x49, 0xdc, 0x51, 0x3e, 0x5c, 0x6b, 0x85, 0x4f, 0xd7, 0x5a, 0xe1, 0xc7, 0xb5, 0x56, - 0xb8, 0xbb, 0x69, 0x2c, 0xe5, 0xd7, 0x3d, 0x30, 0x3e, 0x4b, 0x60, 0xf5, 0x90, 0x74, 0xe3, 0xde, - 0x64, 0x02, 0xef, 0xc1, 0x8a, 0x0b, 0x29, 0x72, 0x72, 0x77, 0x3e, 0x86, 0x72, 0x5b, 0x37, 0xe7, - 0x6c, 0xc2, 0x9c, 0x9a, 0x9c, 0xf5, 0xcf, 0x6d, 0xaa, 0x49, 0xa3, 0x54, 0xdb, 0x10, 0xdd, 0x4e, - 0x7b, 0x18, 0x76, 0xd9, 0x9d, 0x9a, 0xb1, 0x0c, 0x4a, 0x7d, 0x88, 0x11, 0x1f, 0xe3, 0xb2, 0xcd, - 0xcf, 0xb2, 0x0e, 0xca, 0x21, 0x8a, 0x70, 0x40, 0x69, 0x40, 0xfa, 0x54, 0x29, 0xea, 0xc5, 0xfa, - 0xb2, 0x3d, 0x0d, 0x75, 0x6a, 0xe3, 0x3b, 0xdc, 0xdd, 0x34, 0xd6, 0x66, 0x5a, 0x3e, 0x30, 0xbe, - 0x15, 0xc1, 0xc2, 0x31, 0x8c, 0x20, 0xa6, 0xf2, 0x11, 0xd8, 0xc0, 0x70, 0xe0, 0x60, 0x84, 0x89, - 0xe3, 0x9d, 0xc1, 0x08, 0x7a, 0x0c, 0x45, 0x62, 0x99, 0x25, 0x4b, 0x1d, 0xa5, 0x5a, 0x4d, 0xf4, - 0x37, 0x47, 0x64, 0xd8, 0xeb, 0x18, 0x0e, 0x0e, 0x11, 0x26, 0xfb, 0x13, 0x4c, 0xde, 0x05, 0x2b, - 0x6c, 0xe0, 0xd0, 0xc0, 0x77, 0x7a, 0x01, 0x0e, 0x18, 0x6f, 0xba, 0x64, 0x6d, 0x3f, 0x5c, 0x74, - 0x9a, 0x35, 0x6c, 0xc0, 0x06, 0x27, 0x81, 0xff, 0x3a, 0x0b, 0x64, 0x1b, 0x6c, 0x72, 0xf2, 0x0a, - 0x39, 0x1e, 0xa1, 0xcc, 0x09, 0x51, 0xe4, 0xb8, 0x09, 0x43, 0xf9, 0x6a, 0xf5, 0x51, 0xaa, 0xfd, - 0x3b, 0xe5, 0xf1, 0x58, 0x66, 0xd8, 0xeb, 0x99, 0xd9, 0x15, 0xda, 0x27, 0x94, 0x1d, 0xa3, 0xc8, - 0x4a, 0x18, 0x92, 0x2f, 0xc0, 0x76, 0x56, 0xed, 0x12, 0x45, 0xc1, 0x69, 0x22, 0xf4, 0xa8, 0xdb, - 0xde, 0xd9, 0x69, 0xed, 0x8a, 0xa5, 0x5b, 0x9d, 0x61, 0xaa, 0x55, 0x4e, 0x02, 0xff, 0x0d, 0x57, - 0x64, 0xa9, 0x2f, 0x5f, 0x70, 0x7e, 0x94, 0x6a, 0xaa, 0xa8, 0xf6, 0x07, 0x03, 0xc3, 0xae, 0xd0, - 0x99, 0x3c, 0x01, 0xcb, 0x09, 0xa8, 0x3e, 0xce, 0xa0, 0xc8, 0x0b, 0xdb, 0x3b, 0x4f, 0xcf, 0x5b, - 0xca, 0xdf, 0xbc, 0xe8, 0xb3, 0x61, 0xaa, 0x6d, 0xcd, 0x14, 0x3d, 0x19, 0x2b, 0x46, 0xa9, 0xa6, - 0xcf, 0x2f, 0x3b, 0x31, 0x31, 0xec, 0x2d, 0x3a, 0x37, 0xb7, 0xb3, 0x94, 0xff, 0x67, 0x25, 0x6b, - 0xff, 0xcb, 0x50, 0x95, 0x6e, 0x87, 0xaa, 0xf4, 0x7d, 0xa8, 0x4a, 0x1f, 0xef, 0xd5, 0xc2, 0xed, - 0xbd, 0x5a, 0xf8, 0x7a, 0xaf, 0x16, 0xde, 0xfe, 0xe7, 0x07, 0xec, 0x2c, 0x76, 0x4d, 0x8f, 0xe0, - 0xfc, 0x2d, 0xc8, 0x7f, 0x1a, 0xb4, 0x7b, 0xde, 0x1c, 0x88, 0xa7, 0x85, 0x25, 0x21, 0xa2, 0xee, - 0x02, 0xff, 0x52, 0x9f, 0xfc, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x49, 0x90, 0x16, 0xd9, 0x76, 0x04, - 0x00, 0x00, + // 707 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x4f, 0x4f, 0xdb, 0x48, + 0x14, 0x8f, 0x97, 0x6c, 0x80, 0x09, 0x20, 0x61, 0x12, 0x30, 0xd9, 0x95, 0xc7, 0xf2, 0x29, 0x2b, + 0x6d, 0x1c, 0x25, 0x88, 0xd5, 0x12, 0xad, 0x56, 0x8b, 0xd9, 0x1e, 0x50, 0x0b, 0x42, 0x46, 0xea, + 0xa1, 0xaa, 0xe4, 0x8e, 0x9d, 0xc1, 0x58, 0x64, 0x32, 0xc6, 0x33, 0x46, 0x31, 0x9f, 0xa0, 0xc7, + 0x1e, 0x7b, 0xe4, 0x43, 0xf0, 0x0d, 0x7a, 0xe9, 0x11, 0x71, 0xa8, 0x7a, 0xb2, 0xaa, 0x70, 0xa9, + 0x7a, 0xf4, 0xbd, 0x52, 0x95, 0xb1, 0x13, 0x12, 0x94, 0x9e, 0xe2, 0xf7, 0x7e, 0xff, 0xde, 0xbc, + 0x51, 0x06, 0xa8, 0x2e, 0x65, 0x84, 0xb2, 0x26, 0x8a, 0xf8, 0x79, 0xf3, 0xaa, 0xe5, 0x60, 0x8e, + 0x5a, 0xa2, 0x30, 0x82, 0x90, 0x72, 0x2a, 0x6f, 0x64, 0xb8, 0x21, 0x5a, 0x39, 0x5e, 0x5b, 0xc9, + 0x9b, 0x82, 0x52, 0xab, 0x78, 0xd4, 0xa3, 0xe2, 0xb3, 0x39, 0xfa, 0xca, 0xbb, 0xdb, 0x1e, 0xa5, + 0x5e, 0x0f, 0x37, 0x45, 0xe5, 0x44, 0x67, 0x4d, 0xd4, 0x8f, 0x33, 0x48, 0xff, 0x2e, 0x81, 0xb2, + 0x89, 0x18, 0xde, 0x77, 0x5d, 0x1a, 0xf5, 0xb9, 0xac, 0x80, 0x45, 0xd4, 0xed, 0x86, 0x98, 0x31, + 0x45, 0xd2, 0xa4, 0xfa, 0xb2, 0x35, 0x2e, 0xe5, 0xd7, 0x60, 0x31, 0x88, 0x1c, 0xfb, 0x02, 0xc7, + 0xca, 0x2f, 0x9a, 0x54, 0x2f, 0xb7, 0x2b, 0x46, 0x66, 0x6b, 0x8c, 0x6d, 0x8d, 0xfd, 0x7e, 0x6c, + 0x36, 0xbe, 0x25, 0xb0, 0x12, 0x44, 0x4e, 0xcf, 0x77, 0x47, 0xdc, 0x3f, 0x29, 0xf1, 0x39, 0x26, + 0x01, 0x8f, 0xd3, 0x04, 0xae, 0xc7, 0x88, 0xf4, 0x3a, 0xfa, 0x23, 0xaa, 0x5b, 0xa5, 0x20, 0x72, + 0x9e, 0xe3, 0x58, 0xfe, 0x0f, 0xac, 0xa1, 0x6c, 0x04, 0xbb, 0x1f, 0x11, 0x07, 0x87, 0xca, 0x82, + 0x26, 0xd5, 0x8b, 0xe6, 0x76, 0x9a, 0xc0, 0x6a, 0x26, 0x9b, 0xc5, 0x75, 0x6b, 0x35, 0x6f, 0x1c, + 0x8b, 0x5a, 0xae, 0x81, 0x25, 0x86, 0x2f, 0x23, 0xdc, 0x77, 0xb1, 0x52, 0x1c, 0x69, 0xad, 0x49, + 0xdd, 0x51, 0xde, 0xde, 0xc0, 0xc2, 0xfb, 0x1b, 0x58, 0xf8, 0x7a, 0x03, 0x0b, 0xf7, 0xb7, 0x8d, + 0xa5, 0xfc, 0xb8, 0x87, 0xfa, 0x07, 0x09, 0xac, 0x1e, 0xd1, 0x6e, 0xd4, 0x9b, 0x6c, 0xe0, 0x0d, + 0x58, 0x71, 0x10, 0xc3, 0x76, 0xee, 0x2e, 0xd6, 0x50, 0x6e, 0x6b, 0xc6, 0x9c, 0xe5, 0x1b, 0x53, + 0x9b, 0x33, 0x7f, 0xbb, 0x4b, 0xa0, 0x94, 0x26, 0x70, 0x23, 0x9b, 0x76, 0xda, 0x43, 0xb7, 0xca, + 0xce, 0xd4, 0x8e, 0x65, 0x50, 0xec, 0x23, 0x82, 0xc5, 0x1a, 0x97, 0x2d, 0xf1, 0x2d, 0x6b, 0xa0, + 0x1c, 0xe0, 0x90, 0xf8, 0x8c, 0xf9, 0xb4, 0xcf, 0x94, 0x05, 0x6d, 0xa1, 0xbe, 0x6c, 0x4d, 0xb7, + 0x3a, 0xb5, 0xf1, 0x19, 0xee, 0x6f, 0x1b, 0x6b, 0x33, 0x23, 0x1f, 0xea, 0x9f, 0x8a, 0xa0, 0x74, + 0x82, 0x42, 0x44, 0x98, 0x7c, 0x0c, 0x36, 0x08, 0x1a, 0xd8, 0x04, 0x13, 0x6a, 0xbb, 0xe7, 0x28, + 0x44, 0x2e, 0xc7, 0x61, 0x76, 0x99, 0x45, 0x53, 0x4d, 0x13, 0x58, 0xcb, 0xe6, 0x9b, 0x43, 0xd2, + 0xad, 0x75, 0x82, 0x06, 0x47, 0x98, 0xd0, 0x83, 0x49, 0x4f, 0xde, 0x03, 0x2b, 0x7c, 0x60, 0x33, + 0xdf, 0xb3, 0x7b, 0x3e, 0xf1, 0xb9, 0x18, 0xba, 0x68, 0x6e, 0x3d, 0x1e, 0x74, 0x1a, 0xd5, 0x2d, + 0xc0, 0x07, 0xa7, 0xbe, 0xf7, 0x62, 0x54, 0xc8, 0x16, 0xa8, 0x0a, 0xf0, 0x1a, 0xdb, 0x2e, 0x65, + 0xdc, 0x0e, 0x70, 0x68, 0x3b, 0x31, 0xc7, 0xf9, 0xd5, 0x6a, 0x69, 0x02, 0x7f, 0x9f, 0xf2, 0x78, + 0x4a, 0xd3, 0xad, 0xf5, 0x91, 0xd9, 0x35, 0x3e, 0xa0, 0x8c, 0x9f, 0xe0, 0xd0, 0x8c, 0x39, 0x96, + 0x2f, 0xc1, 0xd6, 0x28, 0xed, 0x0a, 0x87, 0xfe, 0x59, 0x9c, 0xf1, 0x71, 0xb7, 0xbd, 0xbb, 0xdb, + 0xda, 0xcb, 0x2e, 0xdd, 0xec, 0x0c, 0x13, 0x58, 0x39, 0xf5, 0xbd, 0x97, 0x82, 0x31, 0x92, 0x3e, + 0xfb, 0x5f, 0xe0, 0x69, 0x02, 0xd5, 0x2c, 0xed, 0x27, 0x06, 0xba, 0x55, 0x61, 0x33, 0xba, 0xac, + 0x2d, 0xc7, 0x60, 0xfb, 0xa9, 0x82, 0x61, 0x37, 0x68, 0xef, 0xfe, 0x75, 0xd1, 0x52, 0x7e, 0x15, + 0xa1, 0xff, 0x0e, 0x13, 0xb8, 0x39, 0x13, 0x7a, 0x3a, 0x66, 0xa4, 0x09, 0xd4, 0xe6, 0xc7, 0x4e, + 0x4c, 0x74, 0x6b, 0x93, 0xcd, 0xd5, 0xca, 0x11, 0x50, 0x9e, 0xaa, 0x9c, 0x1e, 0x6b, 0xb5, 0x77, + 0xfe, 0x6e, 0x29, 0x25, 0x91, 0xfc, 0xcf, 0x30, 0x81, 0xd5, 0x99, 0x64, 0x33, 0x27, 0xa4, 0x09, + 0x84, 0xf3, 0x83, 0xc7, 0x16, 0xba, 0x55, 0x65, 0xf3, 0x94, 0x9d, 0xa5, 0xfc, 0xaf, 0x22, 0x99, + 0x07, 0x1f, 0x87, 0xaa, 0x74, 0x37, 0x54, 0xa5, 0x2f, 0x43, 0x55, 0x7a, 0xf7, 0xa0, 0x16, 0xee, + 0x1e, 0xd4, 0xc2, 0xe7, 0x07, 0xb5, 0xf0, 0xea, 0x0f, 0xcf, 0xe7, 0xe7, 0x91, 0x63, 0xb8, 0x94, + 0x34, 0xf3, 0x77, 0x2b, 0xfb, 0x69, 0xb0, 0xee, 0x45, 0x73, 0x90, 0x3d, 0x62, 0x3c, 0x0e, 0x30, + 0x73, 0x4a, 0xe2, 0x81, 0xd8, 0xf9, 0x11, 0x00, 0x00, 0xff, 0xff, 0xd3, 0xe6, 0x37, 0xa1, 0xe0, + 0x04, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -271,6 +281,9 @@ func (this *Params) Equal(that interface{}) bool { if this.SigVerifyCostSecp256k1 != that1.SigVerifyCostSecp256k1 { return false } + if this.SigVerifyCostBls12381 != that1.SigVerifyCostBls12381 { + return false + } return true } func (m *BaseAccount) Marshal() (dAtA []byte, err error) { @@ -396,6 +409,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.SigVerifyCostBls12381 != 0 { + i = encodeVarintAuth(dAtA, i, uint64(m.SigVerifyCostBls12381)) + i-- + dAtA[i] = 0x30 + } if m.SigVerifyCostSecp256k1 != 0 { i = encodeVarintAuth(dAtA, i, uint64(m.SigVerifyCostSecp256k1)) i-- @@ -502,6 +520,9 @@ func (m *Params) Size() (n int) { if m.SigVerifyCostSecp256k1 != 0 { n += 1 + sovAuth(uint64(m.SigVerifyCostSecp256k1)) } + if m.SigVerifyCostBls12381 != 0 { + n += 1 + sovAuth(uint64(m.SigVerifyCostBls12381)) + } return n } @@ -941,6 +962,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SigVerifyCostBls12381", wireType) + } + m.SigVerifyCostBls12381 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuth + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SigVerifyCostBls12381 |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipAuth(dAtA[iNdEx:]) diff --git a/x/auth/types/params.go b/x/auth/types/params.go index 13db369d23..632de20cae 100644 --- a/x/auth/types/params.go +++ b/x/auth/types/params.go @@ -15,6 +15,7 @@ const ( DefaultTxSizeCostPerByte uint64 = 10 DefaultSigVerifyCostED25519 uint64 = 590 DefaultSigVerifyCostSecp256k1 uint64 = 1000 + DefaultSigVerifyCostBls12381 uint64 = 6300 ) // Parameter keys @@ -24,13 +25,14 @@ var ( KeyTxSizeCostPerByte = []byte("TxSizeCostPerByte") KeySigVerifyCostED25519 = []byte("SigVerifyCostED25519") KeySigVerifyCostSecp256k1 = []byte("SigVerifyCostSecp256k1") + KeySigVerifyCostBls12381 = []byte("SigVerifyCostBls12381") ) var _ paramtypes.ParamSet = &Params{} // NewParams creates a new Params object func NewParams( - maxMemoCharacters, txSigLimit, txSizeCostPerByte, sigVerifyCostED25519, sigVerifyCostSecp256k1 uint64, + maxMemoCharacters, txSigLimit, txSizeCostPerByte, sigVerifyCostED25519, sigVerifyCostSecp256k1 uint64, sigVerifyCostBls12381 uint64, ) Params { return Params{ MaxMemoCharacters: maxMemoCharacters, @@ -38,6 +40,7 @@ func NewParams( TxSizeCostPerByte: txSizeCostPerByte, SigVerifyCostED25519: sigVerifyCostED25519, SigVerifyCostSecp256k1: sigVerifyCostSecp256k1, + SigVerifyCostBls12381: sigVerifyCostBls12381, } } @@ -55,6 +58,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyTxSizeCostPerByte, &p.TxSizeCostPerByte, validateTxSizeCostPerByte), paramtypes.NewParamSetPair(KeySigVerifyCostED25519, &p.SigVerifyCostED25519, validateSigVerifyCostED25519), paramtypes.NewParamSetPair(KeySigVerifyCostSecp256k1, &p.SigVerifyCostSecp256k1, validateSigVerifyCostSecp256k1), + paramtypes.NewParamSetPair(KeySigVerifyCostBls12381, &p.SigVerifyCostBls12381, validateSigVerifyCostBls12381), } } @@ -66,6 +70,7 @@ func DefaultParams() Params { TxSizeCostPerByte: DefaultTxSizeCostPerByte, SigVerifyCostED25519: DefaultSigVerifyCostED25519, SigVerifyCostSecp256k1: DefaultSigVerifyCostSecp256k1, + SigVerifyCostBls12381: DefaultSigVerifyCostBls12381, } } @@ -114,6 +119,19 @@ func validateSigVerifyCostSecp256k1(i interface{}) error { return nil } +func validateSigVerifyCostBls12381(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("invalid BLS12381 signature verification cost: %d", v) + } + + return nil +} + func validateMaxMemoCharacters(i interface{}) error { v, ok := i.(uint64) if !ok { @@ -151,6 +169,9 @@ func (p Params) Validate() error { if err := validateSigVerifyCostSecp256k1(p.SigVerifyCostSecp256k1); err != nil { return err } + if err := validateSigVerifyCostBls12381(p.SigVerifyCostBls12381); err != nil { + return err + } if err := validateMaxMemoCharacters(p.MaxMemoCharacters); err != nil { return err } From ea62aa9bddfb1481b676eb08c556c8df5322056f Mon Sep 17 00:00:00 2001 From: kitty Date: Thu, 22 Jul 2021 13:17:13 +0100 Subject: [PATCH 08/34] POP interfaces in accounts and authentication --- proto/cosmos/auth/v1beta1/auth.proto | 1 + x/auth/ante/ante.go | 1 + x/auth/ante/sigverify.go | 34 +++++++ x/auth/types/account.go | 23 +++++ x/auth/types/auth.pb.go | 127 +++++++++++++++++---------- 5 files changed, 140 insertions(+), 46 deletions(-) diff --git a/proto/cosmos/auth/v1beta1/auth.proto b/proto/cosmos/auth/v1beta1/auth.proto index 799568c186..5b98820258 100644 --- a/proto/cosmos/auth/v1beta1/auth.proto +++ b/proto/cosmos/auth/v1beta1/auth.proto @@ -23,6 +23,7 @@ message BaseAccount { [(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""]; uint64 account_number = 3 [(gogoproto.moretags) = "yaml:\"account_number\""]; uint64 sequence = 4; + bool pop_is_valid = 5; } // ModuleAccount defines an account for modules that holds coins on a pool. diff --git a/x/auth/ante/ante.go b/x/auth/ante/ante.go index 8cc025bad2..ee474b8fbc 100644 --- a/x/auth/ante/ante.go +++ b/x/auth/ante/ante.go @@ -28,6 +28,7 @@ func NewAnteHandler( NewDeductFeeDecorator(ak, bankKeeper), NewSigGasConsumeDecorator(ak, sigGasConsumer), NewSigVerificationDecorator(ak, signModeHandler), + NewSetPopValidDecorator(ak), NewIncrementSequenceDecorator(ak), ) } diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 428b9f97bb..c5a0d925dd 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -289,6 +289,40 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul return next(ctx, tx, simulate) } +// SetPopValidDecorator handles the validation status of the proof-of-possession (POP) of an individual public key. +// A valid transaction and signature can be viewed as a POP for the signer's public key. +// POP is required when forming a compact multisig group in order to prevent rogue public key attacks. +type SetPopValidDecorator struct { + ak AccountKeeper +} + +func NewSetPopValidDecorator(ak AccountKeeper) SetPopValidDecorator { + return SetPopValidDecorator{ + ak: ak, + } +} + +func (spvd SetPopValidDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + sigTx, ok := tx.(authsigning.SigVerifiableTx) + if !ok { + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") + } + + for _, addr := range sigTx.GetSigners() { + acc := spvd.ak.GetAccount(ctx, addr) + pk := acc.GetPubKey() + + switch pk.(type) { + case *bls12381.PubKey, *secp256k1.PubKey, *ed25519.PubKey: + if err := acc.SetPopValid(true); err != nil { + panic(err) + } + } + } + + return next(ctx, tx, simulate) +} + // IncrementSequenceDecorator handles incrementing sequences of all signers. // Use the IncrementSequenceDecorator decorator to prevent replay attacks. Note, // there is no need to execute IncrementSequenceDecorator on RecheckTX since diff --git a/x/auth/types/account.go b/x/auth/types/account.go index eb9939ffce..9b1b89ec6c 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -32,6 +32,7 @@ func NewBaseAccount(address sdk.AccAddress, pubKey cryptotypes.PubKey, accountNu Address: address.String(), AccountNumber: accountNumber, Sequence: sequence, + PopIsValid: false, } err := acc.SetPubKey(pubKey) @@ -117,6 +118,20 @@ func (acc *BaseAccount) SetSequence(seq uint64) error { return nil } +// SetPopValid - Implements sdk.AccountI. +func (acc *BaseAccount) SetPopValid(isValid bool) error { + if acc.PubKey == nil { + return errors.New("public key is not set yet") + } + acc.PopIsValid = isValid + return nil +} + +// GetPopValid - Implements sdk.AccountI. +func (acc *BaseAccount) GetPopValid() bool { + return acc.PopIsValid +} + // Validate checks for errors on the account fields func (acc BaseAccount) Validate() error { if acc.Address == "" || acc.PubKey == nil { @@ -222,6 +237,11 @@ func (ma ModuleAccount) SetSequence(seq uint64) error { return fmt.Errorf("not supported for module accounts") } +// SetPopValid - Implements AccountI +func (ma ModuleAccount) SetPopValid(isValid bool) error { + return fmt.Errorf("not supported for module accounts") +} + // Validate checks for errors on the account fields func (ma ModuleAccount) Validate() error { if strings.TrimSpace(ma.Name) == "" { @@ -324,6 +344,9 @@ type AccountI interface { GetSequence() uint64 SetSequence(uint64) error + GetPopValid() bool + SetPopValid(bool) error + // Ensure that account implements stringer String() string } diff --git a/x/auth/types/auth.pb.go b/x/auth/types/auth.pb.go index ad2283b816..dff9c39fc2 100644 --- a/x/auth/types/auth.pb.go +++ b/x/auth/types/auth.pb.go @@ -33,6 +33,7 @@ type BaseAccount struct { PubKey *types.Any `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"public_key,omitempty" yaml:"public_key"` AccountNumber uint64 `protobuf:"varint,3,opt,name=account_number,json=accountNumber,proto3" json:"account_number,omitempty" yaml:"account_number"` Sequence uint64 `protobuf:"varint,4,opt,name=sequence,proto3" json:"sequence,omitempty"` + PopIsValid bool `protobuf:"varint,5,opt,name=pop_is_valid,json=popIsValid,proto3" json:"pop_is_valid,omitempty"` } func (m *BaseAccount) Reset() { *m = BaseAccount{} } @@ -199,52 +200,53 @@ func init() { func init() { proto.RegisterFile("cosmos/auth/v1beta1/auth.proto", fileDescriptor_7e1f7e915d020d2d) } var fileDescriptor_7e1f7e915d020d2d = []byte{ - // 707 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x4f, 0x4f, 0xdb, 0x48, - 0x14, 0x8f, 0x97, 0x6c, 0x80, 0x09, 0x20, 0x61, 0x12, 0x30, 0xd9, 0x95, 0xc7, 0xf2, 0x29, 0x2b, - 0x6d, 0x1c, 0x25, 0x88, 0xd5, 0x12, 0xad, 0x56, 0x8b, 0xd9, 0x1e, 0x50, 0x0b, 0x42, 0x46, 0xea, - 0xa1, 0xaa, 0xe4, 0x8e, 0x9d, 0xc1, 0x58, 0x64, 0x32, 0xc6, 0x33, 0x46, 0x31, 0x9f, 0xa0, 0xc7, - 0x1e, 0x7b, 0xe4, 0x43, 0xf0, 0x0d, 0x7a, 0xe9, 0x11, 0x71, 0xa8, 0x7a, 0xb2, 0xaa, 0x70, 0xa9, - 0x7a, 0xf4, 0xbd, 0x52, 0x95, 0xb1, 0x13, 0x12, 0x94, 0x9e, 0xe2, 0xf7, 0x7e, 0xff, 0xde, 0xbc, - 0x51, 0x06, 0xa8, 0x2e, 0x65, 0x84, 0xb2, 0x26, 0x8a, 0xf8, 0x79, 0xf3, 0xaa, 0xe5, 0x60, 0x8e, - 0x5a, 0xa2, 0x30, 0x82, 0x90, 0x72, 0x2a, 0x6f, 0x64, 0xb8, 0x21, 0x5a, 0x39, 0x5e, 0x5b, 0xc9, - 0x9b, 0x82, 0x52, 0xab, 0x78, 0xd4, 0xa3, 0xe2, 0xb3, 0x39, 0xfa, 0xca, 0xbb, 0xdb, 0x1e, 0xa5, - 0x5e, 0x0f, 0x37, 0x45, 0xe5, 0x44, 0x67, 0x4d, 0xd4, 0x8f, 0x33, 0x48, 0xff, 0x2e, 0x81, 0xb2, - 0x89, 0x18, 0xde, 0x77, 0x5d, 0x1a, 0xf5, 0xb9, 0xac, 0x80, 0x45, 0xd4, 0xed, 0x86, 0x98, 0x31, - 0x45, 0xd2, 0xa4, 0xfa, 0xb2, 0x35, 0x2e, 0xe5, 0xd7, 0x60, 0x31, 0x88, 0x1c, 0xfb, 0x02, 0xc7, - 0xca, 0x2f, 0x9a, 0x54, 0x2f, 0xb7, 0x2b, 0x46, 0x66, 0x6b, 0x8c, 0x6d, 0x8d, 0xfd, 0x7e, 0x6c, - 0x36, 0xbe, 0x25, 0xb0, 0x12, 0x44, 0x4e, 0xcf, 0x77, 0x47, 0xdc, 0x3f, 0x29, 0xf1, 0x39, 0x26, - 0x01, 0x8f, 0xd3, 0x04, 0xae, 0xc7, 0x88, 0xf4, 0x3a, 0xfa, 0x23, 0xaa, 0x5b, 0xa5, 0x20, 0x72, - 0x9e, 0xe3, 0x58, 0xfe, 0x0f, 0xac, 0xa1, 0x6c, 0x04, 0xbb, 0x1f, 0x11, 0x07, 0x87, 0xca, 0x82, - 0x26, 0xd5, 0x8b, 0xe6, 0x76, 0x9a, 0xc0, 0x6a, 0x26, 0x9b, 0xc5, 0x75, 0x6b, 0x35, 0x6f, 0x1c, - 0x8b, 0x5a, 0xae, 0x81, 0x25, 0x86, 0x2f, 0x23, 0xdc, 0x77, 0xb1, 0x52, 0x1c, 0x69, 0xad, 0x49, - 0xdd, 0x51, 0xde, 0xde, 0xc0, 0xc2, 0xfb, 0x1b, 0x58, 0xf8, 0x7a, 0x03, 0x0b, 0xf7, 0xb7, 0x8d, - 0xa5, 0xfc, 0xb8, 0x87, 0xfa, 0x07, 0x09, 0xac, 0x1e, 0xd1, 0x6e, 0xd4, 0x9b, 0x6c, 0xe0, 0x0d, - 0x58, 0x71, 0x10, 0xc3, 0x76, 0xee, 0x2e, 0xd6, 0x50, 0x6e, 0x6b, 0xc6, 0x9c, 0xe5, 0x1b, 0x53, - 0x9b, 0x33, 0x7f, 0xbb, 0x4b, 0xa0, 0x94, 0x26, 0x70, 0x23, 0x9b, 0x76, 0xda, 0x43, 0xb7, 0xca, - 0xce, 0xd4, 0x8e, 0x65, 0x50, 0xec, 0x23, 0x82, 0xc5, 0x1a, 0x97, 0x2d, 0xf1, 0x2d, 0x6b, 0xa0, - 0x1c, 0xe0, 0x90, 0xf8, 0x8c, 0xf9, 0xb4, 0xcf, 0x94, 0x05, 0x6d, 0xa1, 0xbe, 0x6c, 0x4d, 0xb7, - 0x3a, 0xb5, 0xf1, 0x19, 0xee, 0x6f, 0x1b, 0x6b, 0x33, 0x23, 0x1f, 0xea, 0x9f, 0x8a, 0xa0, 0x74, - 0x82, 0x42, 0x44, 0x98, 0x7c, 0x0c, 0x36, 0x08, 0x1a, 0xd8, 0x04, 0x13, 0x6a, 0xbb, 0xe7, 0x28, - 0x44, 0x2e, 0xc7, 0x61, 0x76, 0x99, 0x45, 0x53, 0x4d, 0x13, 0x58, 0xcb, 0xe6, 0x9b, 0x43, 0xd2, - 0xad, 0x75, 0x82, 0x06, 0x47, 0x98, 0xd0, 0x83, 0x49, 0x4f, 0xde, 0x03, 0x2b, 0x7c, 0x60, 0x33, - 0xdf, 0xb3, 0x7b, 0x3e, 0xf1, 0xb9, 0x18, 0xba, 0x68, 0x6e, 0x3d, 0x1e, 0x74, 0x1a, 0xd5, 0x2d, - 0xc0, 0x07, 0xa7, 0xbe, 0xf7, 0x62, 0x54, 0xc8, 0x16, 0xa8, 0x0a, 0xf0, 0x1a, 0xdb, 0x2e, 0x65, - 0xdc, 0x0e, 0x70, 0x68, 0x3b, 0x31, 0xc7, 0xf9, 0xd5, 0x6a, 0x69, 0x02, 0x7f, 0x9f, 0xf2, 0x78, - 0x4a, 0xd3, 0xad, 0xf5, 0x91, 0xd9, 0x35, 0x3e, 0xa0, 0x8c, 0x9f, 0xe0, 0xd0, 0x8c, 0x39, 0x96, - 0x2f, 0xc1, 0xd6, 0x28, 0xed, 0x0a, 0x87, 0xfe, 0x59, 0x9c, 0xf1, 0x71, 0xb7, 0xbd, 0xbb, 0xdb, - 0xda, 0xcb, 0x2e, 0xdd, 0xec, 0x0c, 0x13, 0x58, 0x39, 0xf5, 0xbd, 0x97, 0x82, 0x31, 0x92, 0x3e, - 0xfb, 0x5f, 0xe0, 0x69, 0x02, 0xd5, 0x2c, 0xed, 0x27, 0x06, 0xba, 0x55, 0x61, 0x33, 0xba, 0xac, - 0x2d, 0xc7, 0x60, 0xfb, 0xa9, 0x82, 0x61, 0x37, 0x68, 0xef, 0xfe, 0x75, 0xd1, 0x52, 0x7e, 0x15, - 0xa1, 0xff, 0x0e, 0x13, 0xb8, 0x39, 0x13, 0x7a, 0x3a, 0x66, 0xa4, 0x09, 0xd4, 0xe6, 0xc7, 0x4e, - 0x4c, 0x74, 0x6b, 0x93, 0xcd, 0xd5, 0xca, 0x11, 0x50, 0x9e, 0xaa, 0x9c, 0x1e, 0x6b, 0xb5, 0x77, - 0xfe, 0x6e, 0x29, 0x25, 0x91, 0xfc, 0xcf, 0x30, 0x81, 0xd5, 0x99, 0x64, 0x33, 0x27, 0xa4, 0x09, - 0x84, 0xf3, 0x83, 0xc7, 0x16, 0xba, 0x55, 0x65, 0xf3, 0x94, 0x9d, 0xa5, 0xfc, 0xaf, 0x22, 0x99, - 0x07, 0x1f, 0x87, 0xaa, 0x74, 0x37, 0x54, 0xa5, 0x2f, 0x43, 0x55, 0x7a, 0xf7, 0xa0, 0x16, 0xee, - 0x1e, 0xd4, 0xc2, 0xe7, 0x07, 0xb5, 0xf0, 0xea, 0x0f, 0xcf, 0xe7, 0xe7, 0x91, 0x63, 0xb8, 0x94, - 0x34, 0xf3, 0x77, 0x2b, 0xfb, 0x69, 0xb0, 0xee, 0x45, 0x73, 0x90, 0x3d, 0x62, 0x3c, 0x0e, 0x30, - 0x73, 0x4a, 0xe2, 0x81, 0xd8, 0xf9, 0x11, 0x00, 0x00, 0xff, 0xff, 0xd3, 0xe6, 0x37, 0xa1, 0xe0, - 0x04, 0x00, 0x00, + // 734 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0xcf, 0x4e, 0xe3, 0x46, + 0x18, 0x8f, 0x21, 0x0d, 0x61, 0x12, 0x90, 0x30, 0x09, 0x98, 0xb4, 0xf2, 0x58, 0x3e, 0xa5, 0x52, + 0xe3, 0x28, 0x41, 0x54, 0x25, 0xaa, 0xaa, 0x62, 0xda, 0x03, 0x6a, 0x41, 0xc8, 0x48, 0x1c, 0xaa, + 0x4a, 0xde, 0xb1, 0x33, 0x18, 0x8b, 0x38, 0x63, 0x3c, 0x63, 0x14, 0xf3, 0x04, 0x7b, 0xdc, 0xe3, + 0xde, 0x96, 0x87, 0xe0, 0x0d, 0xf6, 0xb2, 0x47, 0xc4, 0x61, 0xb5, 0x27, 0x6b, 0x15, 0x2e, 0xab, + 0x3d, 0xfa, 0x09, 0x56, 0x1e, 0x3b, 0x21, 0x41, 0xd9, 0x53, 0xe6, 0xfb, 0x7e, 0xff, 0x66, 0xbe, + 0x71, 0x06, 0xc8, 0x36, 0xa1, 0x1e, 0xa1, 0x6d, 0x14, 0xb2, 0xcb, 0xf6, 0x4d, 0xc7, 0xc2, 0x0c, + 0x75, 0x78, 0xa1, 0xf9, 0x01, 0x61, 0x44, 0xdc, 0xcc, 0x70, 0x8d, 0xb7, 0x72, 0xbc, 0x51, 0xcd, + 0x9b, 0x9c, 0xd2, 0xa8, 0x39, 0xc4, 0x21, 0x7c, 0xd9, 0x4e, 0x57, 0x79, 0x77, 0xc7, 0x21, 0xc4, + 0x19, 0xe0, 0x36, 0xaf, 0xac, 0xf0, 0xa2, 0x8d, 0x86, 0x51, 0x06, 0xa9, 0xef, 0x96, 0x40, 0x45, + 0x47, 0x14, 0x1f, 0xd8, 0x36, 0x09, 0x87, 0x4c, 0x94, 0xc0, 0x0a, 0xea, 0xf7, 0x03, 0x4c, 0xa9, + 0x24, 0x28, 0x42, 0x73, 0xd5, 0x98, 0x94, 0xe2, 0xff, 0x60, 0xc5, 0x0f, 0x2d, 0xf3, 0x0a, 0x47, + 0xd2, 0x92, 0x22, 0x34, 0x2b, 0xdd, 0x9a, 0x96, 0xd9, 0x6a, 0x13, 0x5b, 0xed, 0x60, 0x18, 0xe9, + 0xad, 0xaf, 0x31, 0xac, 0xf9, 0xa1, 0x35, 0x70, 0xed, 0x94, 0xfb, 0x0b, 0xf1, 0x5c, 0x86, 0x3d, + 0x9f, 0x45, 0x49, 0x0c, 0x37, 0x22, 0xe4, 0x0d, 0x7a, 0xea, 0x33, 0xaa, 0x1a, 0x25, 0x3f, 0xb4, + 0xfe, 0xc1, 0x91, 0xf8, 0x27, 0x58, 0x47, 0xd9, 0x16, 0xcc, 0x61, 0xe8, 0x59, 0x38, 0x90, 0x96, + 0x15, 0xa1, 0x59, 0xd4, 0x77, 0x92, 0x18, 0xd6, 0x33, 0xd9, 0x3c, 0xae, 0x1a, 0x6b, 0x79, 0xe3, + 0x84, 0xd7, 0x62, 0x03, 0x94, 0x29, 0xbe, 0x0e, 0xf1, 0xd0, 0xc6, 0x52, 0x31, 0xd5, 0x1a, 0xd3, + 0x5a, 0x54, 0x40, 0xd5, 0x27, 0xbe, 0xe9, 0x52, 0xf3, 0x06, 0x0d, 0xdc, 0xbe, 0xf4, 0x83, 0x22, + 0x34, 0xcb, 0x06, 0xf0, 0x89, 0x7f, 0x44, 0xcf, 0xd3, 0x4e, 0x4f, 0x7a, 0x7d, 0x07, 0x0b, 0x6f, + 0xef, 0x60, 0xe1, 0xcb, 0x1d, 0x2c, 0x3c, 0xde, 0xb7, 0xca, 0xf9, 0x40, 0x8e, 0xd4, 0xf7, 0x02, + 0x58, 0x3b, 0x26, 0xfd, 0x70, 0x30, 0x9d, 0xd1, 0x2b, 0x50, 0xb5, 0x10, 0xc5, 0x66, 0x9e, 0xcf, + 0x07, 0x55, 0xe9, 0x2a, 0xda, 0x82, 0xeb, 0xd1, 0x66, 0x66, 0xab, 0xff, 0xf8, 0x10, 0x43, 0x21, + 0x89, 0xe1, 0x66, 0x76, 0x9e, 0x59, 0x0f, 0xd5, 0xa8, 0x58, 0x33, 0xb7, 0x20, 0x82, 0xe2, 0x10, + 0x79, 0x98, 0x0f, 0x7a, 0xd5, 0xe0, 0x6b, 0x51, 0x01, 0x15, 0x1f, 0x07, 0x9e, 0x4b, 0xa9, 0x4b, + 0x86, 0x54, 0x5a, 0x56, 0x96, 0x9b, 0xab, 0xc6, 0x6c, 0xab, 0xd7, 0x98, 0x9c, 0xe1, 0xf1, 0xbe, + 0xb5, 0x3e, 0xb7, 0xe5, 0x23, 0xf5, 0x63, 0x11, 0x94, 0x4e, 0x51, 0x80, 0x3c, 0x2a, 0x9e, 0x80, + 0x4d, 0x0f, 0x8d, 0x4c, 0x0f, 0x7b, 0xc4, 0xb4, 0x2f, 0x51, 0x80, 0x6c, 0x86, 0x83, 0xec, 0xba, + 0x8b, 0xba, 0x9c, 0xc4, 0xb0, 0x91, 0xed, 0x6f, 0x01, 0x49, 0x35, 0x36, 0x3c, 0x34, 0x3a, 0xc6, + 0x1e, 0x39, 0x9c, 0xf6, 0xc4, 0x7d, 0x50, 0x65, 0x23, 0x93, 0xba, 0x8e, 0x39, 0x70, 0x3d, 0x97, + 0xf1, 0x4d, 0x17, 0xf5, 0xed, 0xe7, 0x83, 0xce, 0xa2, 0xaa, 0x01, 0xd8, 0xe8, 0xcc, 0x75, 0xfe, + 0x4d, 0x0b, 0xd1, 0x00, 0x75, 0x0e, 0xde, 0x62, 0xd3, 0x26, 0x94, 0x99, 0x3e, 0x0e, 0x4c, 0x2b, + 0x62, 0x38, 0xbf, 0x7c, 0x25, 0x89, 0xe1, 0x4f, 0x33, 0x1e, 0x2f, 0x69, 0xaa, 0xb1, 0x91, 0x9a, + 0xdd, 0xe2, 0x43, 0x42, 0xd9, 0x29, 0x0e, 0xf4, 0x88, 0x61, 0xf1, 0x1a, 0x6c, 0xa7, 0x69, 0x37, + 0x38, 0x70, 0x2f, 0xa2, 0x8c, 0x8f, 0xfb, 0xdd, 0xbd, 0xbd, 0xce, 0x7e, 0xf6, 0x59, 0xe8, 0xbd, + 0x71, 0x0c, 0x6b, 0x67, 0xae, 0x73, 0xce, 0x19, 0xa9, 0xf4, 0xef, 0xbf, 0x38, 0x9e, 0xc4, 0x50, + 0xce, 0xd2, 0xbe, 0x63, 0xa0, 0x1a, 0x35, 0x3a, 0xa7, 0xcb, 0xda, 0x62, 0x04, 0x76, 0x5e, 0x2a, + 0x28, 0xb6, 0xfd, 0xee, 0xde, 0xaf, 0x57, 0x1d, 0xfe, 0xad, 0x15, 0xf5, 0x3f, 0xc6, 0x31, 0xdc, + 0x9a, 0x0b, 0x3d, 0x9b, 0x30, 0x92, 0x18, 0x2a, 0x8b, 0x63, 0xa7, 0x26, 0xaa, 0xb1, 0x45, 0x17, + 0x6a, 0xc5, 0x10, 0x48, 0x2f, 0x55, 0xd6, 0x80, 0x76, 0xba, 0xbb, 0xbf, 0x75, 0xa4, 0x12, 0x4f, + 0xfe, 0x7d, 0x1c, 0xc3, 0xfa, 0x5c, 0xb2, 0x9e, 0x13, 0x92, 0x18, 0xc2, 0xc5, 0xc1, 0x13, 0x0b, + 0xd5, 0xa8, 0xd3, 0x45, 0xca, 0x5e, 0x39, 0xff, 0xab, 0x08, 0xfa, 0xe1, 0x87, 0xb1, 0x2c, 0x3c, + 0x8c, 0x65, 0xe1, 0xf3, 0x58, 0x16, 0xde, 0x3c, 0xc9, 0x85, 0x87, 0x27, 0xb9, 0xf0, 0xe9, 0x49, + 0x2e, 0xfc, 0xf7, 0xb3, 0xe3, 0xb2, 0xcb, 0xd0, 0xd2, 0x6c, 0xe2, 0xb5, 0xf3, 0x97, 0x2d, 0xfb, + 0x69, 0xd1, 0xfe, 0x55, 0x7b, 0x94, 0x3d, 0x73, 0x2c, 0xf2, 0x31, 0xb5, 0x4a, 0xfc, 0x09, 0xd9, + 0xfd, 0x16, 0x00, 0x00, 0xff, 0xff, 0xf5, 0xb2, 0xe7, 0x03, 0x02, 0x05, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -306,6 +308,16 @@ func (m *BaseAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.PopIsValid { + i-- + if m.PopIsValid { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } if m.Sequence != 0 { i = encodeVarintAuth(dAtA, i, uint64(m.Sequence)) i-- @@ -473,6 +485,9 @@ func (m *BaseAccount) Size() (n int) { if m.Sequence != 0 { n += 1 + sovAuth(uint64(m.Sequence)) } + if m.PopIsValid { + n += 2 + } return n } @@ -667,6 +682,26 @@ func (m *BaseAccount) Unmarshal(dAtA []byte) error { break } } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PopIsValid", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuth + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PopIsValid = bool(v != 0) default: iNdEx = preIndex skippy, err := skipAuth(dAtA[iNdEx:]) From 2854483862583e5d7382de2c7bbe4ddab70da818 Mon Sep 17 00:00:00 2001 From: kitty Date: Fri, 23 Jul 2021 16:26:39 +0100 Subject: [PATCH 09/34] add bls multsig operations --- crypto/keys/bls12381/bls12381.go | 2 +- crypto/keys/bls12381/multisig.go | 88 +++++++++++++++++++ crypto/keys/bls12381/multisig_test.go | 118 ++++++++++++++++++++++++++ 3 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 crypto/keys/bls12381/multisig.go create mode 100644 crypto/keys/bls12381/multisig_test.go diff --git a/crypto/keys/bls12381/bls12381.go b/crypto/keys/bls12381/bls12381.go index 4806b26685..eab266c3d2 100644 --- a/crypto/keys/bls12381/bls12381.go +++ b/crypto/keys/bls12381/bls12381.go @@ -112,7 +112,7 @@ func GenPrivKey() *PrivKey { return &PrivKey{Key: genPrivKey(crypto.CReader())} } -// genPrivKey generates a new secp256k1 private key using the provided reader. +// genPrivKey generates a new bls12381 private key using the provided reader. func genPrivKey(rand io.Reader) []byte { var ikm [SeedSize]byte _, err := io.ReadFull(rand, ikm[:]) diff --git a/crypto/keys/bls12381/multisig.go b/crypto/keys/bls12381/multisig.go new file mode 100644 index 0000000000..0bd84b8e00 --- /dev/null +++ b/crypto/keys/bls12381/multisig.go @@ -0,0 +1,88 @@ +package bls12381 + +import ( + "encoding/base64" + "fmt" + "os" + + blst "github.com/supranational/blst/bindings/go" +) + +func AggregatePublicKey(pks []*PubKey) *blst.P1Affine { + pubkeys := make([]*blst.P1Affine, len(pks)) + for i, pk := range pks { + pubkeys[i] = new(blst.P1Affine).Deserialize(pk.Key) + if pk == nil { + panic("Failed to deserialize public key") + } + } + + aggregator := new(blst.P1Aggregate) + b := aggregator.Aggregate(pubkeys, false) + if !b { + panic("Failed to aggregate public keys") + } + apk := aggregator.ToAffine() + + return apk +} + +// AggregateSignature combines a set of verified signatures into a single bls signature +func AggregateSignature(sigs [][]byte) []byte { + sigmas := make([]*blst.P2Affine, len(sigs)) + for i, sig := range sigs { + sigmas[i] = new(blst.P2Affine).Uncompress(sig) + if sigmas[i] == nil { + panic("Failed to deserialize signature") + } + } + + aggregator := new(blst.P2Aggregate) + b := aggregator.Aggregate(sigmas, false) + if !b { + panic("Failed to aggregate signatures") + } + aggSigBytes := aggregator.ToAffine().Compress() + return aggSigBytes +} + +// VerifyMultiSignature assumes public key is already validated +func VerifyMultiSignature(msg []byte, sig []byte, pks []*PubKey) bool { + return VerifyAggregateSignature([][]byte{msg}, sig, [][]*PubKey{pks}) +} + +func Unique(msgs [][]byte) bool { + if len(msgs) <= 1 { + return true + } + msgMap := make(map[string]bool, len(msgs)) + for _, msg := range msgs { + s := base64.StdEncoding.EncodeToString(msg) + if _, ok := msgMap[s]; ok { + return false + } + msgMap[s] = true + } + return true +} + +func VerifyAggregateSignature(msgs [][]byte, sig []byte, pkss [][]*PubKey) bool { + //messages must be pairwise distinct + if !Unique(msgs) { + fmt.Fprintf(os.Stdout, "messages must be pairwise distinct") + return false + } + + apks := make([]*blst.P1Affine, len(pkss)) + for i, pks := range pkss { + apks[i] = AggregatePublicKey(pks) + } + + sigma := new(blst.P2Affine).Uncompress(sig) + if sigma == nil { + panic("Failed to deserialize signature") + } + + dst := []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_") + return sigma.AggregateVerify(true, apks, false, msgs, dst) +} diff --git a/crypto/keys/bls12381/multisig_test.go b/crypto/keys/bls12381/multisig_test.go new file mode 100644 index 0000000000..eb8eaed2a3 --- /dev/null +++ b/crypto/keys/bls12381/multisig_test.go @@ -0,0 +1,118 @@ +package bls12381_test + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + bls "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" +) + +func TestBlsMultiSig(t *testing.T) { + total := 5 + pks := make([]*bls.PubKey, total) + sigs := make([][]byte, total) + msg := []byte("hello world") + for i := 0; i < total; i++ { + sk := bls.GenPrivKey() + pk, ok := sk.PubKey().(*bls.PubKey) + require.True(t, ok) + + sig, err := sk.Sign(msg) + require.Nil(t, err) + + pks[i] = pk + sigs[i] = sig + } + + aggSig := bls.AggregateSignature(sigs) + assert.True(t, bls.VerifyMultiSignature(msg, aggSig, pks)) + +} + +func TestBlsAggSig(t *testing.T) { + total := 5 + //sks := make([]*bls.PrivKey, total) + pks := make([][]*bls.PubKey, total) + sigs := make([][]byte, total) + msgs := make([][]byte, total) + for i := 0; i < total; i++ { + msgs[i] = []byte(fmt.Sprintf("message %d", i)) + sk := bls.GenPrivKey() + pk, ok := sk.PubKey().(*bls.PubKey) + require.True(t, ok) + + sig, err := sk.Sign(msgs[i]) + require.Nil(t, err) + + pks[i] = []*bls.PubKey{pk} + sigs[i] = sig + } + + aggSig := bls.AggregateSignature(sigs) + assert.True(t, bls.VerifyAggregateSignature(msgs, aggSig, pks)) + +} + +func benchmarkBlsVerifyMulti(total int, b *testing.B) { + pks := make([]*bls.PubKey, total) + sigs := make([][]byte, total) + msg := []byte("hello world") + for i := 0; i < total; i++ { + sk := bls.GenPrivKey() + pk, ok := sk.PubKey().(*bls.PubKey) + require.True(b, ok) + + sig, err := sk.Sign(msg) + require.Nil(b, err) + + pks[i] = pk + sigs[i] = sig + } + + aggSig := bls.AggregateSignature(sigs) + + b.ResetTimer() + for i := 0; i < b.N; i++ { + bls.VerifyMultiSignature(msg, aggSig, pks) + } +} + +func BenchmarkBlsVerifyMulti8(b *testing.B) { benchmarkBlsVerifyMulti(8, b) } +func BenchmarkBlsVerifyMulti16(b *testing.B) { benchmarkBlsVerifyMulti(16, b) } +func BenchmarkBlsVerifyMulti32(b *testing.B) { benchmarkBlsVerifyMulti(32, b) } +func BenchmarkBlsVerifyMulti64(b *testing.B) { benchmarkBlsVerifyMulti(64, b) } +func BenchmarkBlsVerifyMulti128(b *testing.B) { benchmarkBlsVerifyMulti(128, b) } + +func benchmarkBlsVerifyAgg(total int, b *testing.B) { + pks := make([][]*bls.PubKey, total) + sigs := make([][]byte, total) + msgs := make([][]byte, total) + for i := 0; i < total; i++ { + msgs[i] = []byte(fmt.Sprintf("message %d", i)) + sk := bls.GenPrivKey() + pk, ok := sk.PubKey().(*bls.PubKey) + require.True(b, ok) + + sig, err := sk.Sign(msgs[i]) + require.Nil(b, err) + + pks[i] = []*bls.PubKey{pk} + sigs[i] = sig + } + + aggSig := bls.AggregateSignature(sigs) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + bls.VerifyAggregateSignature(msgs, aggSig, pks) + } +} + +func BenchmarkBlsVerifyAgg8(b *testing.B) { benchmarkBlsVerifyAgg(8, b) } +func BenchmarkBlsVerifyAgg16(b *testing.B) { benchmarkBlsVerifyAgg(16, b) } +func BenchmarkBlsVerifyAgg32(b *testing.B) { benchmarkBlsVerifyAgg(32, b) } +func BenchmarkBlsVerifyAgg64(b *testing.B) { benchmarkBlsVerifyAgg(64, b) } +func BenchmarkBlsVerifyAgg128(b *testing.B) { benchmarkBlsVerifyAgg(128, b) } From 9be8b74882cd567be4616ed4863708a9588f4c04 Mon Sep 17 00:00:00 2001 From: kitty Date: Fri, 23 Jul 2021 16:56:12 +0100 Subject: [PATCH 10/34] fixed golangci-lint error --- crypto/keys/bls12381/multisig.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crypto/keys/bls12381/multisig.go b/crypto/keys/bls12381/multisig.go index 0bd84b8e00..8d549ce70a 100644 --- a/crypto/keys/bls12381/multisig.go +++ b/crypto/keys/bls12381/multisig.go @@ -8,11 +8,11 @@ import ( blst "github.com/supranational/blst/bindings/go" ) -func AggregatePublicKey(pks []*PubKey) *blst.P1Affine { +func aggregatePublicKey(pks []*PubKey) *blst.P1Affine { pubkeys := make([]*blst.P1Affine, len(pks)) for i, pk := range pks { pubkeys[i] = new(blst.P1Affine).Deserialize(pk.Key) - if pk == nil { + if pubkeys[i] == nil { panic("Failed to deserialize public key") } } @@ -67,7 +67,7 @@ func Unique(msgs [][]byte) bool { } func VerifyAggregateSignature(msgs [][]byte, sig []byte, pkss [][]*PubKey) bool { - //messages must be pairwise distinct + // messages must be pairwise distinct if !Unique(msgs) { fmt.Fprintf(os.Stdout, "messages must be pairwise distinct") return false @@ -75,7 +75,7 @@ func VerifyAggregateSignature(msgs [][]byte, sig []byte, pkss [][]*PubKey) bool apks := make([]*blst.P1Affine, len(pkss)) for i, pks := range pkss { - apks[i] = AggregatePublicKey(pks) + apks[i] = aggregatePublicKey(pks) } sigma := new(blst.P2Affine).Uncompress(sig) From 200bf491899755e134ca1cf5128bedd8adb2d7bb Mon Sep 17 00:00:00 2001 From: kitty Date: Mon, 26 Jul 2021 15:02:30 +0100 Subject: [PATCH 11/34] changes after comments --- crypto/keys/bls12381/multisig.go | 48 +++++++++++++++++---------- crypto/keys/bls12381/multisig_test.go | 20 +++++++---- proto/cosmos/auth/v1beta1/auth.proto | 2 +- types/errors/errors.go | 3 ++ x/auth/ante/sigverify.go | 2 +- 5 files changed, 49 insertions(+), 26 deletions(-) diff --git a/crypto/keys/bls12381/multisig.go b/crypto/keys/bls12381/multisig.go index 8d549ce70a..18e499e390 100644 --- a/crypto/keys/bls12381/multisig.go +++ b/crypto/keys/bls12381/multisig.go @@ -3,51 +3,50 @@ package bls12381 import ( "encoding/base64" "fmt" - "os" blst "github.com/supranational/blst/bindings/go" ) -func aggregatePublicKey(pks []*PubKey) *blst.P1Affine { +func aggregatePublicKey(pks []*PubKey) (*blst.P1Affine, error) { pubkeys := make([]*blst.P1Affine, len(pks)) for i, pk := range pks { pubkeys[i] = new(blst.P1Affine).Deserialize(pk.Key) if pubkeys[i] == nil { - panic("Failed to deserialize public key") + return nil, fmt.Errorf("failed to deserialize public key") } } aggregator := new(blst.P1Aggregate) b := aggregator.Aggregate(pubkeys, false) if !b { - panic("Failed to aggregate public keys") + return nil, fmt.Errorf("failed to aggregate public keys") } apk := aggregator.ToAffine() - return apk + return apk, nil } // AggregateSignature combines a set of verified signatures into a single bls signature -func AggregateSignature(sigs [][]byte) []byte { +func AggregateSignature(sigs [][]byte) ([]byte, error) { sigmas := make([]*blst.P2Affine, len(sigs)) for i, sig := range sigs { sigmas[i] = new(blst.P2Affine).Uncompress(sig) if sigmas[i] == nil { - panic("Failed to deserialize signature") + return nil, fmt.Errorf("failed to deserialize the %d-th signature", i) } } aggregator := new(blst.P2Aggregate) b := aggregator.Aggregate(sigmas, false) if !b { - panic("Failed to aggregate signatures") + return nil, fmt.Errorf("failed to aggregate signatures") } aggSigBytes := aggregator.ToAffine().Compress() - return aggSigBytes + return aggSigBytes, nil } // VerifyMultiSignature assumes public key is already validated -func VerifyMultiSignature(msg []byte, sig []byte, pks []*PubKey) bool { +func VerifyMultiSignature(msg []byte, sig []byte, pks []*PubKey) error { return VerifyAggregateSignature([][]byte{msg}, sig, [][]*PubKey{pks}) } @@ -66,23 +65,38 @@ func Unique(msgs [][]byte) bool { return true } -func VerifyAggregateSignature(msgs [][]byte, sig []byte, pkss [][]*PubKey) bool { - // messages must be pairwise distinct +func VerifyAggregateSignature(msgs [][]byte, sig []byte, pkss [][]*PubKey) error { + n := len(msgs) + if n == 0 { + return fmt.Errorf("messages cannot be empty") + } + + if len(pkss) != n { + return fmt.Errorf("the number of messages and public key sets must match") + } + if !Unique(msgs) { - fmt.Fprintf(os.Stdout, "messages must be pairwise distinct") - return false + return fmt.Errorf("messages must be pairwise distinct") } apks := make([]*blst.P1Affine, len(pkss)) for i, pks := range pkss { - apks[i] = aggregatePublicKey(pks) + apk, err := aggregatePublicKey(pks) + if err != nil { + return fmt.Errorf("cannot aggregate public keys: %s", err.Error()) + } + apks[i] = apk } sigma := new(blst.P2Affine).Uncompress(sig) if sigma == nil { - panic("Failed to deserialize signature") + return fmt.Errorf("failed to deserialize signature") } dst := []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_") - return sigma.AggregateVerify(true, apks, false, msgs, dst) + if !sigma.AggregateVerify(true, apks, false, msgs, dst) { + return fmt.Errorf("failed to verify signature") + } + + return nil } diff --git a/crypto/keys/bls12381/multisig_test.go b/crypto/keys/bls12381/multisig_test.go index eb8eaed2a3..c0024f859b 100644 --- a/crypto/keys/bls12381/multisig_test.go +++ b/crypto/keys/bls12381/multisig_test.go @@ -27,14 +27,15 @@ func TestBlsMultiSig(t *testing.T) { sigs[i] = sig } - aggSig := bls.AggregateSignature(sigs) - assert.True(t, bls.VerifyMultiSignature(msg, aggSig, pks)) + aggSig, err := bls.AggregateSignature(sigs) + require.Nil(t, err) + + assert.Nil(t, bls.VerifyMultiSignature(msg, aggSig, pks)) } func TestBlsAggSig(t *testing.T) { total := 5 - //sks := make([]*bls.PrivKey, total) pks := make([][]*bls.PubKey, total) sigs := make([][]byte, total) msgs := make([][]byte, total) @@ -51,8 +52,10 @@ func TestBlsAggSig(t *testing.T) { sigs[i] = sig } - aggSig := bls.AggregateSignature(sigs) - assert.True(t, bls.VerifyAggregateSignature(msgs, aggSig, pks)) + aggSig, err := bls.AggregateSignature(sigs) + require.Nil(t, err) + + assert.Nil(t, bls.VerifyAggregateSignature(msgs, aggSig, pks)) } @@ -72,7 +75,8 @@ func benchmarkBlsVerifyMulti(total int, b *testing.B) { sigs[i] = sig } - aggSig := bls.AggregateSignature(sigs) + aggSig, err := bls.AggregateSignature(sigs) + require.Nil(b, err) b.ResetTimer() for i := 0; i < b.N; i++ { @@ -103,7 +107,9 @@ func benchmarkBlsVerifyAgg(total int, b *testing.B) { sigs[i] = sig } - aggSig := bls.AggregateSignature(sigs) + aggSig, err := bls.AggregateSignature(sigs) + require.Nil(b, err) + b.ResetTimer() for i := 0; i < b.N; i++ { diff --git a/proto/cosmos/auth/v1beta1/auth.proto b/proto/cosmos/auth/v1beta1/auth.proto index 5b98820258..9be92bd2ce 100644 --- a/proto/cosmos/auth/v1beta1/auth.proto +++ b/proto/cosmos/auth/v1beta1/auth.proto @@ -23,7 +23,7 @@ message BaseAccount { [(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""]; uint64 account_number = 3 [(gogoproto.moretags) = "yaml:\"account_number\""]; uint64 sequence = 4; - bool pop_is_valid = 5; + bool pop_is_valid = 5; } // ModuleAccount defines an account for modules that holds coins on a pool. diff --git a/types/errors/errors.go b/types/errors/errors.go index 026f5f569b..909b97f691 100644 --- a/types/errors/errors.go +++ b/types/errors/errors.go @@ -134,6 +134,9 @@ var ( // supported. ErrNotSupported = Register(RootCodespace, 37, "feature not supported") + // ErrInvalidPop to doc + ErrInvalidPop = Register(RootCodespace, 38, "invalid pop for public key") + // ErrPanic is only set when we recover from a panic, so we know to // redact potentially sensitive system info ErrPanic = Register(UndefinedCodespace, 111222, "panic") diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index c5a0d925dd..84de7d391c 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -315,7 +315,7 @@ func (spvd SetPopValidDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate switch pk.(type) { case *bls12381.PubKey, *secp256k1.PubKey, *ed25519.PubKey: if err := acc.SetPopValid(true); err != nil { - panic(err) + return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPop, err.Error()) } } } From dbdfb2a783a168e21920d0be521ca68428482bac Mon Sep 17 00:00:00 2001 From: kitty Date: Tue, 27 Jul 2021 10:53:44 +0100 Subject: [PATCH 12/34] initial commit from regen-ledger/x/group v1.0.0 --- x/group/client/query.go | 440 +++ x/group/client/testsuite/query_test.go | 677 ++++ x/group/client/testsuite/tx_test.go | 1571 ++++++++ x/group/client/tx.go | 641 +++ x/group/client/util.go | 28 + x/group/codec.go | 62 + x/group/errors.go | 16 + x/group/events.pb.go | 1296 +++++++ x/group/genesis.go | 29 + x/group/genesis.pb.go | 709 ++++ x/group/keys.go | 14 + x/group/module/module.go | 75 + x/group/msgs.go | 677 ++++ x/group/msgs_test.go | 350 ++ x/group/proposal.go | 115 + x/group/query.pb.go | 4966 ++++++++++++++++++++++++ x/group/query_cosmos.pb.go | 610 +++ x/group/server/expected_keepers.go | 17 + x/group/server/genesis.go | 91 + x/group/server/handler.go | 69 + x/group/server/msg_server.go | 753 ++++ x/group/server/proposal_executor.go | 42 + x/group/server/query_server.go | 254 ++ x/group/server/server.go | 168 + x/group/server/server_test.go | 60 + x/group/server/testsuite/genesis.go | 177 + x/group/server/testsuite/suite.go | 1998 ++++++++++ x/group/spec/01_concepts.md | 70 + x/group/spec/02_state.md | 104 + x/group/spec/03_messages.md | 104 + x/group/spec/04_events.md | 56 + x/group/spec/README.md | 49 + x/group/tx.pb.go | 4734 ++++++++++++++++++++++ x/group/tx_cosmos.pb.go | 610 +++ x/group/types.go | 504 +++ x/group/types.pb.go | 3357 ++++++++++++++++ x/group/types_test.go | 942 +++++ x/group/typesupport.go | 39 + 38 files changed, 26474 insertions(+) create mode 100644 x/group/client/query.go create mode 100644 x/group/client/testsuite/query_test.go create mode 100644 x/group/client/testsuite/tx_test.go create mode 100644 x/group/client/tx.go create mode 100644 x/group/client/util.go create mode 100644 x/group/codec.go create mode 100644 x/group/errors.go create mode 100644 x/group/events.pb.go create mode 100644 x/group/genesis.go create mode 100644 x/group/genesis.pb.go create mode 100644 x/group/keys.go create mode 100644 x/group/module/module.go create mode 100644 x/group/msgs.go create mode 100644 x/group/msgs_test.go create mode 100644 x/group/proposal.go create mode 100644 x/group/query.pb.go create mode 100644 x/group/query_cosmos.pb.go create mode 100644 x/group/server/expected_keepers.go create mode 100644 x/group/server/genesis.go create mode 100644 x/group/server/handler.go create mode 100644 x/group/server/msg_server.go create mode 100644 x/group/server/proposal_executor.go create mode 100644 x/group/server/query_server.go create mode 100644 x/group/server/server.go create mode 100644 x/group/server/server_test.go create mode 100644 x/group/server/testsuite/genesis.go create mode 100644 x/group/server/testsuite/suite.go create mode 100644 x/group/spec/01_concepts.md create mode 100644 x/group/spec/02_state.md create mode 100644 x/group/spec/03_messages.md create mode 100644 x/group/spec/04_events.md create mode 100644 x/group/spec/README.md create mode 100644 x/group/tx.pb.go create mode 100644 x/group/tx_cosmos.pb.go create mode 100644 x/group/types.go create mode 100644 x/group/types.pb.go create mode 100644 x/group/types_test.go create mode 100644 x/group/typesupport.go diff --git a/x/group/client/query.go b/x/group/client/query.go new file mode 100644 index 0000000000..01b2406286 --- /dev/null +++ b/x/group/client/query.go @@ -0,0 +1,440 @@ +package client + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/regen-network/regen-ledger/x/group" + "github.com/spf13/cobra" +) + +// QueryCmd returns the cli query commands for the group module. +func QueryCmd(name string) *cobra.Command { + queryCmd := &cobra.Command{ + Use: name, + Short: "Querying commands for the group module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + queryCmd.AddCommand( + QueryGroupInfoCmd(), + QueryGroupAccountInfoCmd(), + QueryGroupMembersCmd(), + QueryGroupsByAdminCmd(), + QueryGroupAccountsByGroupCmd(), + QueryGroupAccountsByAdminCmd(), + QueryProposalCmd(), + QueryProposalsByGroupAccountCmd(), + QueryVoteByProposalVoterCmd(), + QueryVotesByProposalCmd(), + QueryVotesByVoterCmd(), + ) + + return queryCmd +} + +// QueryGroupInfoCmd creates a CLI command for Query/GroupInfo. +func QueryGroupInfoCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "group-info [id]", + Short: "Query for group info by group id", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + groupID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.GroupInfo(cmd.Context(), &group.QueryGroupInfoRequest{ + GroupId: groupID, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res.Info) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryGroupAccountInfoCmd creates a CLI command for Query/GroupAccountInfo. +func QueryGroupAccountInfoCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "group-account-info [group-account]", + Short: "Query for group account info by group account address", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.GroupAccountInfo(cmd.Context(), &group.QueryGroupAccountInfoRequest{ + Address: args[0], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res.Info) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryGroupMembersCmd creates a CLI command for Query/GroupMembers. +func QueryGroupMembersCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "group-members [id]", + Short: "Query for group members by group id with pagination flags", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + groupID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.GroupMembers(cmd.Context(), &group.QueryGroupMembersRequest{ + GroupId: groupID, + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryGroupsByAdminCmd creates a CLI command for Query/GroupsByAdmin. +func QueryGroupsByAdminCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "groups-by-admin [admin]", + Short: "Query for groups by admin account address with pagination flags", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.GroupsByAdmin(cmd.Context(), &group.QueryGroupsByAdminRequest{ + Admin: args[0], + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryGroupAccountsByGroupCmd creates a CLI command for Query/GroupAccountsByGroup. +func QueryGroupAccountsByGroupCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "group-accounts-by-group [group-id]", + Short: "Query for group accounts by group id with pagination flags", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + groupID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.GroupAccountsByGroup(cmd.Context(), &group.QueryGroupAccountsByGroupRequest{ + GroupId: groupID, + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryGroupAccountsByAdminCmd creates a CLI command for Query/GroupAccountsByAdmin. +func QueryGroupAccountsByAdminCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "group-accounts-by-admin [admin]", + Short: "Query for group accounts by admin account address with pagination flags", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.GroupAccountsByAdmin(cmd.Context(), &group.QueryGroupAccountsByAdminRequest{ + Admin: args[0], + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryProposalCmd creates a CLI command for Query/Proposal. +func QueryProposalCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "proposal [id]", + Short: "Query for proposal by id", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + proposalID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.Proposal(cmd.Context(), &group.QueryProposalRequest{ + ProposalId: proposalID, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryProposalsByGroupAccountCmd creates a CLI command for Query/ProposalsByGroupAccount. +func QueryProposalsByGroupAccountCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "proposals-by-group-account [group-account]", + Short: "Query for proposals by group account address with pagination flags", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.ProposalsByGroupAccount(cmd.Context(), &group.QueryProposalsByGroupAccountRequest{ + Address: args[0], + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryVoteByProposalVoterCmd creates a CLI command for Query/VoteByProposalVoter. +func QueryVoteByProposalVoterCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "vote [proposal-id] [voter]", + Short: "Query for vote by proposal id and voter account address", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + proposalID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.VoteByProposalVoter(cmd.Context(), &group.QueryVoteByProposalVoterRequest{ + ProposalId: proposalID, + Voter: args[1], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryVotesByProposalCmd creates a CLI command for Query/VotesByProposal. +func QueryVotesByProposalCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "votes-by-proposal [proposal-id]", + Short: "Query for votes by proposal id with pagination flags", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + proposalID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.VotesByProposal(cmd.Context(), &group.QueryVotesByProposalRequest{ + ProposalId: proposalID, + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryVotesByVoterCmd creates a CLI command for Query/VotesByVoter. +func QueryVotesByVoterCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "votes-by-voter [voter]", + Short: "Query for votes by voter account address with pagination flags", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.VotesByVoter(cmd.Context(), &group.QueryVotesByVoterRequest{ + Voter: args[0], + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/group/client/testsuite/query_test.go b/x/group/client/testsuite/query_test.go new file mode 100644 index 0000000000..00af59f854 --- /dev/null +++ b/x/group/client/testsuite/query_test.go @@ -0,0 +1,677 @@ +// +build experimental + +package testsuite + +import ( + "fmt" + "strconv" + + "github.com/regen-network/regen-ledger/testutil/cli" + "github.com/regen-network/regen-ledger/x/group" + "github.com/regen-network/regen-ledger/x/group/client" + tmcli "github.com/tendermint/tendermint/libs/cli" +) + +func (s *IntegrationTestSuite) TestQueryGroupInfo() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + }{ + { + "group not found", + []string{"12345", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "not found: invalid request", + 0, + }, + { + "group id invalid", + []string{"", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "strconv.ParseUint: parsing \"\": invalid syntax", + 0, + }, + { + "group found", + []string{strconv.FormatUint(s.group.GroupId, 10), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryGroupInfoCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + + var g group.GroupInfo + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &g)) + s.Require().Equal(s.group.GroupId, g.GroupId) + s.Require().Equal(s.group.Admin, g.Admin) + s.Require().Equal(s.group.TotalWeight, g.TotalWeight) + s.Require().Equal(s.group.Metadata, g.Metadata) + s.Require().Equal(s.group.Version, g.Version) + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryGroupMembers() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + expectMembers []*group.GroupMember + }{ + { + "no group", + []string{"12345", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.GroupMember{}, + }, + { + "members found", + []string{strconv.FormatUint(s.group.GroupId, 10), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.GroupMember{ + { + GroupId: s.group.GroupId, + Member: &group.Member{ + Address: val.Address.String(), + Weight: "1", + Metadata: []byte{1}, + }, + }, + }, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryGroupMembersCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + + var res group.QueryGroupMembersResponse + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res)) + s.Require().Equal(len(res.Members), len(tc.expectMembers)) + for i := range res.Members { + s.Require().Equal(res.Members[i].GroupId, tc.expectMembers[i].GroupId) + s.Require().Equal(res.Members[i].Member.Address, tc.expectMembers[i].Member.Address) + s.Require().Equal(res.Members[i].Member.Metadata, tc.expectMembers[i].Member.Metadata) + s.Require().Equal(res.Members[i].Member.Weight, tc.expectMembers[i].Member.Weight) + } + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryGroupsByAdmin() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + expectGroups []*group.GroupInfo + }{ + { + "invalid admin address", + []string{"invalid"}, + true, + "decoding bech32 failed: invalid bech32 string", + 0, + []*group.GroupInfo{}, + }, + { + "no group", + []string{s.network.Validators[1].Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.GroupInfo{}, + }, + { + "found groups", + []string{val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.GroupInfo{ + s.group, + }, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryGroupsByAdminCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + + var res group.QueryGroupsByAdminResponse + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res)) + s.Require().Equal(len(res.Groups), len(tc.expectGroups)) + for i := range res.Groups { + s.Require().Equal(res.Groups[i].GroupId, tc.expectGroups[i].GroupId) + s.Require().Equal(res.Groups[i].Metadata, tc.expectGroups[i].Metadata) + s.Require().Equal(res.Groups[i].Version, tc.expectGroups[i].Version) + s.Require().Equal(res.Groups[i].TotalWeight, tc.expectGroups[i].TotalWeight) + s.Require().Equal(res.Groups[i].Admin, tc.expectGroups[i].Admin) + } + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryGroupAccountInfo() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + }{ + { + "invalid account address", + []string{"invalid", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "decoding bech32 failed: invalid bech32", + 0, + }, + { + "group account not found", + []string{val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "not found: invalid request", + 0, + }, + { + "group account found", + []string{s.groupAccounts[0].Address, fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryGroupAccountInfoCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + + var g group.GroupAccountInfo + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &g)) + s.Require().Equal(s.groupAccounts[0].GroupId, g.GroupId) + s.Require().Equal(s.groupAccounts[0].Address, g.Address) + s.Require().Equal(s.groupAccounts[0].Admin, g.Admin) + s.Require().Equal(s.groupAccounts[0].Metadata, g.Metadata) + s.Require().Equal(s.groupAccounts[0].Version, g.Version) + s.Require().Equal(s.groupAccounts[0].GetDecisionPolicy(), g.GetDecisionPolicy()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryGroupAccountsByGroup() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + expectGroupAccounts []*group.GroupAccountInfo + }{ + { + "invalid group id", + []string{""}, + true, + "strconv.ParseUint: parsing \"\": invalid syntax", + 0, + []*group.GroupAccountInfo{}, + }, + { + "no group account", + []string{"12345", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.GroupAccountInfo{}, + }, + { + "found group accounts", + []string{strconv.FormatUint(s.group.GroupId, 10), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.GroupAccountInfo{ + s.groupAccounts[0], + s.groupAccounts[1], + s.groupAccounts[2], + s.groupAccounts[3], + }, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryGroupAccountsByGroupCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + + var res group.QueryGroupAccountsByGroupResponse + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res)) + s.Require().Equal(len(res.GroupAccounts), len(tc.expectGroupAccounts)) + for i := range res.GroupAccounts { + s.Require().Equal(res.GroupAccounts[i].GroupId, tc.expectGroupAccounts[i].GroupId) + s.Require().Equal(res.GroupAccounts[i].Metadata, tc.expectGroupAccounts[i].Metadata) + s.Require().Equal(res.GroupAccounts[i].Version, tc.expectGroupAccounts[i].Version) + s.Require().Equal(res.GroupAccounts[i].Admin, tc.expectGroupAccounts[i].Admin) + s.Require().Equal(res.GroupAccounts[i].GetDecisionPolicy(), tc.expectGroupAccounts[i].GetDecisionPolicy()) + } + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryGroupAccountsByAdmin() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + expectGroupAccounts []*group.GroupAccountInfo + }{ + { + "invalid admin address", + []string{"invalid"}, + true, + "decoding bech32 failed: invalid bech32 string", + 0, + []*group.GroupAccountInfo{}, + }, + { + "no group account", + []string{s.network.Validators[1].Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.GroupAccountInfo{}, + }, + { + "found group accounts", + []string{val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.GroupAccountInfo{ + s.groupAccounts[0], + s.groupAccounts[1], + s.groupAccounts[2], + s.groupAccounts[3], + }, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryGroupAccountsByAdminCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + + var res group.QueryGroupAccountsByAdminResponse + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res)) + s.Require().Equal(len(res.GroupAccounts), len(tc.expectGroupAccounts)) + for i := range res.GroupAccounts { + s.Require().Equal(res.GroupAccounts[i].GroupId, tc.expectGroupAccounts[i].GroupId) + s.Require().Equal(res.GroupAccounts[i].Metadata, tc.expectGroupAccounts[i].Metadata) + s.Require().Equal(res.GroupAccounts[i].Version, tc.expectGroupAccounts[i].Version) + s.Require().Equal(res.GroupAccounts[i].Admin, tc.expectGroupAccounts[i].Admin) + s.Require().Equal(res.GroupAccounts[i].GetDecisionPolicy(), tc.expectGroupAccounts[i].GetDecisionPolicy()) + } + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryProposal() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + }{ + { + "not found", + []string{"12345", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "not found", + 0, + }, + { + "invalid proposal id", + []string{"", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "strconv.ParseUint: parsing \"\": invalid syntax", + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryProposalCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryProposalsByGroupAccount() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + expectProposals []*group.Proposal + }{ + { + "invalid group account address", + []string{"invalid"}, + true, + "decoding bech32 failed: invalid bech32 string", + 0, + []*group.Proposal{}, + }, + { + "no group account", + []string{s.network.Validators[1].Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.Proposal{}, + }, + { + "found proposals", + []string{s.groupAccounts[0].Address, fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.Proposal{ + s.proposal, + }, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryProposalsByGroupAccountCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + + var res group.QueryProposalsByGroupAccountResponse + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res)) + s.Require().Equal(len(res.Proposals), len(tc.expectProposals)) + for i := range res.Proposals { + s.Require().Equal(res.Proposals[i], tc.expectProposals[i]) + } + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryVoteByProposalVoter() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + }{ + { + "invalid voter address", + []string{"1", "invalid", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "decoding bech32 failed: invalid bech32", + 0, + }, + { + "invalid proposal id", + []string{"", val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "strconv.ParseUint: parsing \"\": invalid syntax", + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryVoteByProposalVoterCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryVotesByProposal() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + expectVotes []*group.Vote + }{ + { + "invalid proposal id", + []string{"", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "strconv.ParseUint: parsing \"\": invalid syntax", + 0, + []*group.Vote{}, + }, + { + "no votes", + []string{"12345", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.Vote{}, + }, + { + "found votes", + []string{"1", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.Vote{ + s.vote, + }, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryVotesByProposalCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + + var res group.QueryVotesByProposalResponse + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res)) + s.Require().Equal(len(res.Votes), len(tc.expectVotes)) + for i := range res.Votes { + s.Require().Equal(res.Votes[i], tc.expectVotes[i]) + } + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryVotesByVoter() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + expectVotes []*group.Vote + }{ + { + "invalid voter address", + []string{"abcd", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "decoding bech32 failed: invalid bech32", + 0, + []*group.Vote{}, + }, + { + "no votes", + []string{s.groupAccounts[0].Address, fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "", + 0, + []*group.Vote{}, + }, + { + "found votes", + []string{val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.Vote{ + s.vote, + }, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryVotesByVoterCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + + var res group.QueryVotesByVoterResponse + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res)) + s.Require().Equal(len(res.Votes), len(tc.expectVotes)) + for i := range res.Votes { + s.Require().Equal(res.Votes[i], tc.expectVotes[i]) + } + } + }) + } +} diff --git a/x/group/client/testsuite/tx_test.go b/x/group/client/testsuite/tx_test.go new file mode 100644 index 0000000000..b1bb0713c2 --- /dev/null +++ b/x/group/client/testsuite/tx_test.go @@ -0,0 +1,1571 @@ +// +build experimental + +package testsuite + +import ( + "fmt" + "strconv" + "strings" + "testing" + + tmcli "github.com/tendermint/tendermint/libs/cli" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/testutil" + banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" + "github.com/gogo/protobuf/proto" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/regen-network/regen-ledger/testutil/cli" + "github.com/regen-network/regen-ledger/testutil/network" + + "github.com/regen-network/regen-ledger/x/group" + "github.com/regen-network/regen-ledger/x/group/client" + "github.com/stretchr/testify/suite" +) + +type IntegrationTestSuite struct { + suite.Suite + + cfg network.Config + network *network.Network + + group *group.GroupInfo + groupAccounts []*group.GroupAccountInfo + proposal *group.Proposal + vote *group.Vote +} + +const validMetadata = "AQ==" + +func (s *IntegrationTestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + cfg := network.DefaultConfig() + cfg.NumValidators = 2 + + s.cfg = cfg + s.network = network.New(s.T(), cfg) + + _, err := s.network.WaitForHeight(1) + s.Require().NoError(err) + + val := s.network.Validators[0] + + // create a new account + info, _, err := val.ClientCtx.Keyring.NewMnemonic("NewValidator", keyring.English, sdk.FullFundraiserPath, hd.Secp256k1) + s.Require().NoError(err) + + account := sdk.AccAddress(info.GetPubKey().Address()) + _, err = banktestutil.MsgSendExec( + val.ClientCtx, + val.Address, + account, + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(2000))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + ) + s.Require().NoError(err) + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + // create a group + validMembers := fmt.Sprintf(`{"members": [{ + "address": "%s", + "weight": "1", + "metadata": "%s" + }]}`, val.Address.String(), validMetadata) + validMembersFile := testutil.WriteToNewTempFile(s.T(), validMembers) + out, err := cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateGroupCmd(), + append( + []string{ + val.Address.String(), + validMetadata, + validMembersFile.Name(), + }, + commonFlags..., + ), + ) + + s.Require().NoError(err, out.String()) + var txResp = sdk.TxResponse{} + s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + s.group = &group.GroupInfo{GroupId: 1, Admin: val.Address.String(), Metadata: []byte{1}, TotalWeight: "1", Version: 1} + + // create 4 group accounts + for i := 0; i < 4; i++ { + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateGroupAccountCmd(), + append( + []string{ + val.Address.String(), + "1", + validMetadata, + "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"timeout\":\"30000s\"}", + }, + commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.QueryGroupAccountsByGroupCmd(), []string{"1", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) + s.Require().NoError(err, out.String()) + } + + var res group.QueryGroupAccountsByGroupResponse + s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res)) + s.Require().Equal(len(res.GroupAccounts), 4) + s.groupAccounts = res.GroupAccounts + + // create a proposal + validTxFileName := getTxSendFileName(s, s.groupAccounts[0].Address, val.Address.String()) + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateProposalCmd(), + append( + []string{ + s.groupAccounts[0].Address, + val.Address.String(), + validTxFileName, + "", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + }, + commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + // vote + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgVoteCmd(), + append( + []string{ + "1", + val.Address.String(), + "CHOICE_YES", + "", + }, + commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.QueryProposalCmd(), []string{"1", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) + s.Require().NoError(err, out.String()) + + var proposalRes group.QueryProposalResponse + s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &proposalRes)) + s.proposal = proposalRes.Proposal + + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.QueryVoteByProposalVoterCmd(), []string{"1", val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) + s.Require().NoError(err, out.String()) + + var voteRes group.QueryVoteByProposalVoterResponse + s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &voteRes)) + s.vote = voteRes.Vote +} + +func (s *IntegrationTestSuite) TearDownSuite() { + s.T().Log("tearing down integration test suite") + s.network.Cleanup() +} + +func (s *IntegrationTestSuite) TestTxCreateGroup() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + validMembers := fmt.Sprintf(`{"members": [{ + "address": "%s", + "weight": "1", + "metadata": "%s" + }]}`, val.Address.String(), validMetadata) + validMembersFile := testutil.WriteToNewTempFile(s.T(), validMembers) + + invalidMembersAddress := `{"members": [{ + "address": "", + "weight": "1" +}]}` + invalidMembersAddressFile := testutil.WriteToNewTempFile(s.T(), invalidMembersAddress) + + invalidMembersWeight := fmt.Sprintf(`{"members": [{ + "address": "%s", + "weight": "0" + }]}`, val.Address.String()) + invalidMembersWeightFile := testutil.WriteToNewTempFile(s.T(), invalidMembersWeight) + + invalidMembersMetadata := fmt.Sprintf(`{"members": [{ + "address": "%s", + "weight": "1", + "metadata": "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ==" + }]}`, val.Address.String()) + invalidMembersMetadataFile := testutil.WriteToNewTempFile(s.T(), invalidMembersMetadata) + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + expectedCode uint32 + }{ + { + "correct data", + append( + []string{ + val.Address.String(), + "", + validMembersFile.Name(), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "with amino-json", + append( + []string{ + val.Address.String(), + "", + validMembersFile.Name(), + fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "group metadata too long", + append( + []string{ + val.Address.String(), + "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ==", + "", + }, + commonFlags..., + ), + true, + "group metadata: limit exceeded", + nil, + 0, + }, + { + "invalid members address", + append( + []string{ + val.Address.String(), + "null", + invalidMembersAddressFile.Name(), + }, + commonFlags..., + ), + true, + "message validation failed: members: address: empty address string is not allowed", + nil, + 0, + }, + { + "invalid members weight", + append( + []string{ + val.Address.String(), + "null", + invalidMembersWeightFile.Name(), + }, + commonFlags..., + ), + true, + "message validation failed: member weight: expected a positive decimal, got 0", + nil, + 0, + }, + { + "members metadata too long", + append( + []string{ + val.Address.String(), + "null", + invalidMembersMetadataFile.Name(), + }, + commonFlags..., + ), + true, + "member metadata: limit exceeded", + nil, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.MsgCreateGroupCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestTxUpdateGroupAdmin() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + validMembers := fmt.Sprintf(`{"members": [{ + "address": "%s", + "weight": "1", + "metadata": "%s" + }]}`, val.Address.String(), validMetadata) + validMembersFile := testutil.WriteToNewTempFile(s.T(), validMembers) + out, err := cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateGroupCmd(), + append( + []string{ + val.Address.String(), + validMetadata, + validMembersFile.Name(), + }, + commonFlags..., + ), + ) + + s.Require().NoError(err, out.String()) + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + expectedCode uint32 + }{ + { + "correct data", + append( + []string{ + val.Address.String(), + "3", + s.network.Validators[1].Address.String(), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "with amino-json", + append( + []string{ + val.Address.String(), + "4", + s.network.Validators[1].Address.String(), + fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "group id invalid", + append( + []string{ + val.Address.String(), + "", + s.network.Validators[1].Address.String(), + }, + commonFlags..., + ), + true, + "strconv.ParseUint: parsing \"\": invalid syntax", + nil, + 0, + }, + { + "group doesn't exist", + append( + []string{ + val.Address.String(), + "12345", + s.network.Validators[1].Address.String(), + }, + commonFlags..., + ), + true, + "not found", + nil, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.MsgUpdateGroupAdminCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestTxUpdateGroupMetadata() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + expectedCode uint32 + }{ + { + "correct data", + append( + []string{ + val.Address.String(), + "2", + validMetadata, + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "with amino-json", + append( + []string{ + val.Address.String(), + "2", + validMetadata, + fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "group metadata too long", + append( + []string{ + val.Address.String(), + strconv.FormatUint(s.group.GroupId, 10), + "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ==", + }, + commonFlags..., + ), + true, + "group metadata: limit exceeded", + nil, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.MsgUpdateGroupMetadataCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestTxUpdateGroupMembers() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + validUpdatedMembersFileName := testutil.WriteToNewTempFile(s.T(), fmt.Sprintf(`{"members": [{ + "address": "%s", + "weight": "0", + "metadata": "%s" + }, { + "address": "%s", + "weight": "1", + "metadata": "%s" + }]}`, val.Address.String(), validMetadata, s.groupAccounts[0].Address, validMetadata)).Name() + + invalidMembersMetadata := fmt.Sprintf(`{"members": [{ + "address": "%s", + "weight": "1", + "metadata": "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ==" + }]}`, val.Address.String()) + invalidMembersMetadataFileName := testutil.WriteToNewTempFile(s.T(), invalidMembersMetadata).Name() + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + expectedCode uint32 + }{ + { + "correct data", + append( + []string{ + val.Address.String(), + "2", + validUpdatedMembersFileName, + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "with amino-json", + append( + []string{ + val.Address.String(), + "2", + testutil.WriteToNewTempFile(s.T(), fmt.Sprintf(`{"members": [{ + "address": "%s", + "weight": "2", + "metadata": "%s" + }]}`, s.groupAccounts[0].Address, validMetadata)).Name(), + fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "group member metadata too long", + append( + []string{ + val.Address.String(), + strconv.FormatUint(s.group.GroupId, 10), + invalidMembersMetadataFileName, + }, + commonFlags..., + ), + true, + "group member metadata: limit exceeded", + nil, + 0, + }, + { + "group doesn't exist", + append( + []string{ + val.Address.String(), + "12345", + validUpdatedMembersFileName, + }, + commonFlags..., + ), + true, + "not found", + nil, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.MsgUpdateGroupMembersCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestTxCreateGroupAccount() { + val := s.network.Validators[0] + wrongAdmin := s.network.Validators[1].Address + clientCtx := val.ClientCtx + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + groupID := s.group.GroupId + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + expectedCode uint32 + }{ + { + "correct data", + append( + []string{ + val.Address.String(), + fmt.Sprintf("%v", groupID), + validMetadata, + "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"timeout\":\"1s\"}", + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "with amino-json", + append( + []string{ + val.Address.String(), + fmt.Sprintf("%v", groupID), + validMetadata, + "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"timeout\":\"1s\"}", + fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "wrong admin", + append( + []string{ + wrongAdmin.String(), + fmt.Sprintf("%v", groupID), + validMetadata, + "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"timeout\":\"1s\"}", + }, + commonFlags..., + ), + true, + "The specified item could not be found in the keyring", + &sdk.TxResponse{}, + 0, + }, + { + "metadata too long", + append( + []string{ + val.Address.String(), + fmt.Sprintf("%v", groupID), + strings.Repeat("a", 500), + "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"timeout\":\"1s\"}", + }, + commonFlags..., + ), + true, + "group account metadata: limit exceeded", + &sdk.TxResponse{}, + 0, + }, + { + "wrong group id", + append( + []string{ + val.Address.String(), + "10", + validMetadata, + "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"timeout\":\"1s\"}", + }, + commonFlags..., + ), + true, + "not found", + &sdk.TxResponse{}, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.MsgCreateGroupAccountCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestTxUpdateGroupAccountAdmin() { + val := s.network.Validators[0] + newAdmin := s.network.Validators[1].Address + clientCtx := val.ClientCtx + groupAccount := s.groupAccounts[1] + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + expectedCode uint32 + }{ + { + "correct data", + append( + []string{ + groupAccount.Admin, + groupAccount.Address, + newAdmin.String(), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "with amino-json", + append( + []string{ + groupAccount.Admin, + s.groupAccounts[2].Address, + newAdmin.String(), + fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "wrong admin", + append( + []string{ + newAdmin.String(), + groupAccount.Address, + newAdmin.String(), + }, + commonFlags..., + ), + true, + "The specified item could not be found in the keyring", + &sdk.TxResponse{}, + 0, + }, + { + "wrong group account", + append( + []string{ + groupAccount.Admin, + newAdmin.String(), + newAdmin.String(), + }, + commonFlags..., + ), + true, + "load group account: not found", + &sdk.TxResponse{}, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.MsgUpdateGroupAccountAdminCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestTxUpdateGroupAccountDecisionPolicy() { + val := s.network.Validators[0] + newAdmin := s.network.Validators[1].Address + clientCtx := val.ClientCtx + groupAccount := s.groupAccounts[3] + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + expectedCode uint32 + }{ + { + "correct data", + append( + []string{ + groupAccount.Admin, + groupAccount.Address, + "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"2\", \"timeout\":\"2s\"}", + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "with amino-json", + append( + []string{ + groupAccount.Admin, + groupAccount.Address, + "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"2\", \"timeout\":\"2s\"}", + fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "wrong admin", + append( + []string{ + newAdmin.String(), + groupAccount.Address, + "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"timeout\":\"1s\"}", + }, + commonFlags..., + ), + true, + "The specified item could not be found in the keyring", + &sdk.TxResponse{}, + 0, + }, + { + "wrong group account", + append( + []string{ + groupAccount.Admin, + newAdmin.String(), + "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"timeout\":\"1s\"}", + }, + commonFlags..., + ), + true, + "load group account: not found", + &sdk.TxResponse{}, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.MsgUpdateGroupAccountDecisionPolicyCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestTxUpdateGroupAccountMetadata() { + val := s.network.Validators[0] + newAdmin := s.network.Validators[1].Address + clientCtx := val.ClientCtx + groupAccount := s.groupAccounts[3] + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + expectedCode uint32 + }{ + { + "correct data", + append( + []string{ + groupAccount.Admin, + groupAccount.Address, + validMetadata, + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "with amino-json", + append( + []string{ + groupAccount.Admin, + groupAccount.Address, + validMetadata, + fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "long metadata", + append( + []string{ + groupAccount.Admin, + groupAccount.Address, + strings.Repeat("a", 500), + }, + commonFlags..., + ), + true, + "group account metadata: limit exceeded", + &sdk.TxResponse{}, + 0, + }, + { + "wrong admin", + append( + []string{ + newAdmin.String(), + groupAccount.Address, + validMetadata, + }, + commonFlags..., + ), + true, + "The specified item could not be found in the keyring", + &sdk.TxResponse{}, + 0, + }, + { + "wrong group account", + append( + []string{ + groupAccount.Admin, + newAdmin.String(), + validMetadata, + }, + commonFlags..., + ), + true, + "load group account: not found", + &sdk.TxResponse{}, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.MsgUpdateGroupAccountMetadataCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestTxCreateProposal() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + validTxFileName := getTxSendFileName(s, s.groupAccounts[0].Address, val.Address.String()) + unauthzTxFileName := getTxSendFileName(s, val.Address.String(), s.groupAccounts[0].Address) + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + expectedCode uint32 + }{ + { + "correct data", + append( + []string{ + s.groupAccounts[0].Address, + val.Address.String(), + validTxFileName, + "", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "with amino-json", + append( + []string{ + s.groupAccounts[0].Address, + val.Address.String(), + validTxFileName, + "", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "metadata too long", + append( + []string{ + s.groupAccounts[0].Address, + val.Address.String(), + validTxFileName, + "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ==", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + }, + commonFlags..., + ), + true, + "metadata: limit exceeded", + nil, + 0, + }, + { + "unauthorized msg", + append( + []string{ + s.groupAccounts[0].Address, + val.Address.String(), + unauthzTxFileName, + "", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + }, + commonFlags..., + ), + true, + "msg does not have group account authorization: unauthorized", + nil, + 0, + }, + { + "invalid proposers", + append( + []string{ + s.groupAccounts[0].Address, + "invalid", + validTxFileName, + "", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + }, + commonFlags..., + ), + true, + "proposers: decoding bech32 failed", + nil, + 0, + }, + { + "invalid group account", + append( + []string{ + "invalid", + val.Address.String(), + validTxFileName, + "", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + }, + commonFlags..., + ), + true, + "group account: decoding bech32 failed", + nil, + 0, + }, + { + "no group account", + append( + []string{ + val.Address.String(), + val.Address.String(), + validTxFileName, + "", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + }, + commonFlags..., + ), + true, + "group account: not found", + nil, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.MsgCreateProposalCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestTxVote() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + validTxFileName := getTxSendFileName(s, s.groupAccounts[3].Address, val.Address.String()) + for i := 0; i < 2; i++ { + out, err := cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateProposalCmd(), + append( + []string{ + s.groupAccounts[3].Address, + val.Address.String(), + validTxFileName, + "", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + }, + commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + } + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + expectedCode uint32 + }{ + { + "correct data", + append( + []string{ + "2", + val.Address.String(), + "CHOICE_YES", + "", + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "with amino-json", + append( + []string{ + "5", + val.Address.String(), + "CHOICE_YES", + "", + fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "invalid proposal id", + append( + []string{ + "abcd", + val.Address.String(), + "CHOICE_YES", + "", + }, + commonFlags..., + ), + true, + "invalid syntax", + nil, + 0, + }, + { + "proposal not found", + append( + []string{ + "1234", + val.Address.String(), + "CHOICE_YES", + "", + }, + commonFlags..., + ), + true, + "proposal: not found", + nil, + 0, + }, + { + "metadata too long", + append( + []string{ + "2", + val.Address.String(), + "CHOICE_YES", + "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ==", + }, + commonFlags..., + ), + true, + "metadata: limit exceeded", + nil, + 0, + }, + { + "invalid choice", + append( + []string{ + "2", + val.Address.String(), + "INVALID_CHOICE", + "", + }, + commonFlags..., + ), + true, + "not a valid vote choice", + nil, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.MsgVoteCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestTxExec() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + // create proposals and vote + for i := 3; i <= 4; i++ { + validTxFileName := getTxSendFileName(s, s.groupAccounts[0].Address, val.Address.String()) + out, err := cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateProposalCmd(), + append( + []string{ + s.groupAccounts[0].Address, + val.Address.String(), + validTxFileName, + "", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + }, + commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgVoteCmd(), + append( + []string{ + fmt.Sprintf("%d", i), + val.Address.String(), + "CHOICE_YES", + "", + }, + commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + } + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + expectedCode uint32 + }{ + { + "correct data", + append( + []string{ + "3", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "with amino-json", + append( + []string{ + "4", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "invalid proposal id", + append( + []string{ + "abcd", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + }, + commonFlags..., + ), + true, + "invalid syntax", + nil, + 0, + }, + { + "proposal not found", + append( + []string{ + "1234", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + }, + commonFlags..., + ), + true, + "proposal: not found", + nil, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.MsgExecCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func getTxSendFileName(s *IntegrationTestSuite, from string, to string) string { + tx := fmt.Sprintf( + `{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"%s","to_address":"%s","amount":[{"denom":"%s","amount":"10"}]}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}`, + from, to, s.cfg.BondDenom, + ) + return testutil.WriteToNewTempFile(s.T(), tx).Name() +} + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} diff --git a/x/group/client/tx.go b/x/group/client/tx.go new file mode 100644 index 0000000000..7fb1bab6dd --- /dev/null +++ b/x/group/client/tx.go @@ -0,0 +1,641 @@ +package client + +import ( + "encoding/base64" + "fmt" + "strconv" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/version" + authclient "github.com/cosmos/cosmos-sdk/x/auth/client" + "github.com/spf13/cobra" + + "github.com/regen-network/regen-ledger/x/group" +) + +const flagMembers = "members" + +// TxCmd returns a root CLI command handler for all x/group transaction commands. +func TxCmd(name string) *cobra.Command { + txCmd := &cobra.Command{ + Use: name, + Short: "Group transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand( + MsgCreateGroupCmd(), + MsgUpdateGroupAdminCmd(), + MsgUpdateGroupMetadataCmd(), + MsgUpdateGroupMembersCmd(), + MsgCreateGroupAccountCmd(), + MsgUpdateGroupAccountAdminCmd(), + MsgUpdateGroupAccountDecisionPolicyCmd(), + MsgUpdateGroupAccountMetadataCmd(), + MsgCreateProposalCmd(), + MsgVoteCmd(), + MsgExecCmd(), + ) + + return txCmd +} + +// MsgCreateGroupCmd creates a CLI command for Msg/CreateGroup. +func MsgCreateGroupCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-group [admin] [metadata] [members-json-file]", + Short: "Create a group which is an aggregation " + + "of member accounts with associated weights and " + + "an administrator account. Note, the '--from' flag is " + + "ignored as it is implied from [admin].", + Long: strings.TrimSpace( + fmt.Sprintf(`Create a group which is an aggregation of member accounts with associated weights and +an administrator account. Note, the '--from' flag is ignored as it is implied from [admin]. +Members accounts can be given through a members JSON file that contains an array of members. + +Example: +$ %s tx group create-group [admin] [metadata] [members-json-file] + +Where members.json contains: + +{ + "members": [ + { + "address": "addr1", + "weight": "1", + "metadata": "some metadata" + }, + { + "address": "addr2", + "weight": "1", + "metadata": "some metadata" + } + ] +} +`, + version.AppName, + ), + ), + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + members, err := parseMembers(clientCtx, args[2]) + if err != nil { + return err + } + + b, err := base64.StdEncoding.DecodeString(args[1]) + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "metadata is malformed, proper base64 string is required") + } + + msg := &group.MsgCreateGroupRequest{ + Admin: clientCtx.GetFromAddress().String(), + Members: members, + Metadata: b, + } + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(flagMembers, "", "Members file path") + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// MsgUpdateGroupMembersCmd creates a CLI command for Msg/UpdateGroupMembers. +func MsgUpdateGroupMembersCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-group-members [admin] [group-id] [members-json-file]", + Short: "Update a group's members. Set a member's weight to \"0\" to delete it.", + Long: strings.TrimSpace( + fmt.Sprintf(`Update a group's members + +Example: +$ %s tx group update-group-members [admin] [group-id] [members-json-file] + +Where members.json contains: + +{ + "members": [ + { + "address": "addr1", + "weight": "1", + "metadata": "some new metadata" + }, + { + "address": "addr2", + "weight": "0", + "metadata": "some metadata" + } + ] +} + +Set a member's weight to "0" to delete it. +`, + version.AppName, + ), + ), + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + members, err := parseMembers(clientCtx, args[2]) + if err != nil { + return err + } + + groupID, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } + + msg := &group.MsgUpdateGroupMembersRequest{ + Admin: clientCtx.GetFromAddress().String(), + MemberUpdates: members, + GroupId: groupID, + } + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(flagMembers, "", "Members file path") + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// MsgUpdateGroupAdminCmd creates a CLI command for Msg/UpdateGroupAdmin. +func MsgUpdateGroupAdminCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-group-admin [admin] [group-id] [new-admin]", + Short: "Update a group's admin", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + groupID, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } + + msg := &group.MsgUpdateGroupAdminRequest{ + Admin: clientCtx.GetFromAddress().String(), + NewAdmin: args[2], + GroupId: groupID, + } + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// MsgUpdateGroupMetadataCmd creates a CLI command for Msg/UpdateGroupMetadata. +func MsgUpdateGroupMetadataCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-group-metadata [admin] [group-id] [metadata]", + Short: "Update a group's metadata", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + groupID, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } + + b, err := base64.StdEncoding.DecodeString(args[2]) + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "metadata is malformed, proper base64 string is required") + } + + msg := &group.MsgUpdateGroupMetadataRequest{ + Admin: clientCtx.GetFromAddress().String(), + Metadata: b, + GroupId: groupID, + } + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// MsgCreateGroupAccountCmd creates a CLI command for Msg/CreateGroupAccount. +func MsgCreateGroupAccountCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-group-account [admin] [group-id] [metadata] [decision-policy]", + Short: "Create a group account which is an account " + + "associated with a group and a decision policy. " + + "Note, the '--from' flag is " + + "ignored as it is implied from [admin].", + Long: strings.TrimSpace( + fmt.Sprintf(`Create a group account which is an account associated with a group and a decision policy. +Note, the '--from' flag is ignored as it is implied from [admin]. + +Example: +$ %s tx group create-group-account [admin] [group-id] [metadata] \ +'{"@type":"/regen.group.v1alpha1.ThresholdDecisionPolicy", "threshold":"1", "timeout":"1s"}' +`, + version.AppName, + ), + ), + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + groupID, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } + + var policy group.DecisionPolicy + if err := clientCtx.JSONMarshaler.UnmarshalInterfaceJSON([]byte(args[3]), &policy); err != nil { + return err + } + + b, err := base64.StdEncoding.DecodeString(args[2]) + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "metadata is malformed, proper base64 string is required") + } + + msg, err := group.NewMsgCreateGroupAccountRequest( + clientCtx.GetFromAddress(), + groupID, + b, + policy, + ) + if err != nil { + return err + } + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// MsgUpdateGroupAccountAdminCmd creates a CLI command for Msg/UpdateGroupAccountAdmin. +func MsgUpdateGroupAccountAdminCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-group-account-admin [admin] [group-account] [new-admin]", + Short: "Update a group account admin", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &group.MsgUpdateGroupAccountAdminRequest{ + Admin: clientCtx.GetFromAddress().String(), + Address: args[1], + NewAdmin: args[2], + } + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// MsgUpdateGroupAccountDecisionPolicyCmd creates a CLI command for Msg/UpdateGroupAccountDecisionPolicy. +func MsgUpdateGroupAccountDecisionPolicyCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-group-account-policy [admin] [group-account] [decision-policy]", + Short: "Update a group account decision policy", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + var policy group.DecisionPolicy + if err := clientCtx.JSONMarshaler.UnmarshalInterfaceJSON([]byte(args[2]), &policy); err != nil { + return err + } + + accountAddress, err := sdk.AccAddressFromBech32(args[1]) + if err != nil { + return err + } + + msg, err := group.NewMsgUpdateGroupAccountDecisionPolicyRequest( + clientCtx.GetFromAddress(), + accountAddress, + policy, + ) + if err != nil { + return err + } + + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// MsgUpdateGroupAccountMetadataCmd creates a CLI command for Msg/MsgUpdateGroupAccountMetadata. +func MsgUpdateGroupAccountMetadataCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-group-account-metadata [admin] [group-account] [new-metadata]", + Short: "Update a group account metadata", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + b, err := base64.StdEncoding.DecodeString(args[2]) + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "metadata is malformed, proper base64 string is required") + } + + msg := &group.MsgUpdateGroupAccountMetadataRequest{ + Admin: clientCtx.GetFromAddress().String(), + Address: args[1], + Metadata: b, + } + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// MsgCreateProposalCmd creates a CLI command for Msg/CreateProposal. +func MsgCreateProposalCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-proposal [group-account] [proposer[,proposer]*] [msg_tx_json_file] [metadata]", + Short: "Submit a new proposal", + Long: `Submit a new proposal. + +Parameters: + group-account: address of the group account + proposer: comma separated (no spaces) list of proposer account addresses. Example: "addr1,addr2" + Metadata: metadata for the proposal + msg_tx_json_file: path to json file with messages that will be executed if the proposal is accepted. +`, + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + proposers := strings.Split(args[1], ",") + for i := range proposers { + proposers[i] = strings.TrimSpace(proposers[i]) + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + theTx, err := authclient.ReadTxFromFile(clientCtx, args[2]) + if err != nil { + return err + } + msgs := theTx.GetMsgs() + + b, err := base64.StdEncoding.DecodeString(args[3]) + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "metadata is malformed, proper base64 string is required") + } + + msg, err := group.NewMsgCreateProposalRequest( + args[0], + proposers, + msgs, + b, + ) + if err != nil { + return err + } + + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// MsgVoteCmd creates a CLI command for Msg/Vote. +func MsgVoteCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "vote [proposal-id] [voter] [choice] [metadata]", + Short: "Vote on a proposal", + Long: `Vote on a proposal. + +Parameters: + proposal-id: unique ID of the proposal + voter: voter account addresses. + choice: choice of the voter(s) + CHOICE_UNSPECIFIED: no-op + CHOICE_NO: no + CHOICE_YES: yes + CHOICE_ABSTAIN: abstain + CHOICE_VETO: veto + Metadata: metadata for the vote +`, + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[1]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + proposalID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + choice, err := group.ChoiceFromString(args[2]) + if err != nil { + return err + } + + b, err := base64.StdEncoding.DecodeString(args[3]) + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "metadata is malformed, proper base64 string is required") + } + + msg := &group.MsgVoteRequest{ + ProposalId: proposalID, + Voter: args[1], + Choice: choice, + Metadata: b, + } + if err != nil { + return err + } + + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// MsgExecCmd creates a CLI command for Msg/MsgExec. +func MsgExecCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "exec [proposal-id]", + Short: "Execute a proposal", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + proposalID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + msg := &group.MsgExecRequest{ + ProposalId: proposalID, + Signer: clientCtx.GetFromAddress().String(), + } + if err != nil { + return err + } + + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/group/client/util.go b/x/group/client/util.go new file mode 100644 index 0000000000..5b326b6c06 --- /dev/null +++ b/x/group/client/util.go @@ -0,0 +1,28 @@ +package client + +import ( + "io/ioutil" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/regen-network/regen-ledger/x/group" +) + +func parseMembers(clientCtx client.Context, membersFile string) ([]group.Member, error) { + members := group.Members{} + + if membersFile == "" { + return members.Members, nil + } + + contents, err := ioutil.ReadFile(membersFile) + if err != nil { + return nil, err + } + + err = clientCtx.JSONMarshaler.UnmarshalJSON(contents, &members) + if err != nil { + return nil, err + } + + return members.Members, nil +} diff --git a/x/group/codec.go b/x/group/codec.go new file mode 100644 index 0000000000..75be45627f --- /dev/null +++ b/x/group/codec.go @@ -0,0 +1,62 @@ +package group + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterLegacyAminoCodec registers all the necessary group module concrete +// types and interfaces with the provided codec reference. +// These types are used for Amino JSON serialization. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterInterface((*DecisionPolicy)(nil), nil) + cdc.RegisterConcrete(&ThresholdDecisionPolicy{}, "cosmos-sdk/ThresholdDecisionPolicy", nil) + cdc.RegisterConcrete(&MsgCreateGroupRequest{}, "cosmos-sdk/MsgCreateGroup", nil) + cdc.RegisterConcrete(&MsgUpdateGroupMembersRequest{}, "cosmos-sdk/MsgUpdateGroupMembers", nil) + cdc.RegisterConcrete(&MsgUpdateGroupAdminRequest{}, "cosmos-sdk/MsgUpdateGroupAdmin", nil) + cdc.RegisterConcrete(&MsgUpdateGroupMetadataRequest{}, "cosmos-sdk/MsgUpdateGroupMetadata", nil) + cdc.RegisterConcrete(&MsgCreateGroupAccountRequest{}, "cosmos-sdk/MsgCreateGroupAccount", nil) + cdc.RegisterConcrete(&MsgUpdateGroupAccountAdminRequest{}, "cosmos-sdk/MsgUpdateGroupAccountAdmin", nil) + cdc.RegisterConcrete(&MsgUpdateGroupAccountDecisionPolicyRequest{}, "cosmos-sdk/MsgUpdateGroupAccountDecisionPolicy", nil) + cdc.RegisterConcrete(&MsgUpdateGroupAccountMetadataRequest{}, "cosmos-sdk/MsgUpdateGroupAccountMetadata", nil) + cdc.RegisterConcrete(&MsgCreateProposalRequest{}, "cosmos-sdk/group/MsgCreateProposal", nil) + cdc.RegisterConcrete(&MsgVoteRequest{}, "cosmos-sdk/group/MsgVote", nil) + cdc.RegisterConcrete(&MsgExecRequest{}, "cosmos-sdk/group/MsgExec", nil) +} + +func RegisterTypes(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgCreateGroupRequest{}, + &MsgUpdateGroupMembersRequest{}, + &MsgUpdateGroupAdminRequest{}, + &MsgUpdateGroupMetadataRequest{}, + &MsgCreateGroupAccountRequest{}, + &MsgUpdateGroupAccountAdminRequest{}, + &MsgUpdateGroupAccountDecisionPolicyRequest{}, + &MsgUpdateGroupAccountMetadataRequest{}, + &MsgCreateProposalRequest{}, + &MsgVoteRequest{}, + &MsgExecRequest{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &Msg_ServiceDesc) + + registry.RegisterInterface( + "regen.group.v1alpha1.DecisionPolicy", + (*DecisionPolicy)(nil), + &ThresholdDecisionPolicy{}, + ) +} + +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) +} diff --git a/x/group/errors.go b/x/group/errors.go new file mode 100644 index 0000000000..5155ff867b --- /dev/null +++ b/x/group/errors.go @@ -0,0 +1,16 @@ +package group + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var ( + ErrEmpty = sdkerrors.Register(ModuleName, 202, "value is empty") + ErrDuplicate = sdkerrors.Register(ModuleName, 203, "duplicate value") + ErrMaxLimit = sdkerrors.Register(ModuleName, 204, "limit exceeded") + ErrType = sdkerrors.Register(ModuleName, 205, "invalid type") + ErrInvalid = sdkerrors.Register(ModuleName, 206, "invalid value") + ErrUnauthorized = sdkerrors.Register(ModuleName, 207, "unauthorized") + ErrModified = sdkerrors.Register(ModuleName, 208, "modified") + ErrExpired = sdkerrors.Register(ModuleName, 209, "expired") +) diff --git a/x/group/events.pb.go b/x/group/events.pb.go new file mode 100644 index 0000000000..685b731056 --- /dev/null +++ b/x/group/events.pb.go @@ -0,0 +1,1296 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: regen/group/v1alpha1/events.proto + +package group + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/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 + +// EventCreateGroup is an event emitted when a group is created. +type EventCreateGroup struct { + // group_id is the unique ID of the group. + GroupId uint64 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` +} + +func (m *EventCreateGroup) Reset() { *m = EventCreateGroup{} } +func (m *EventCreateGroup) String() string { return proto.CompactTextString(m) } +func (*EventCreateGroup) ProtoMessage() {} +func (*EventCreateGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_3545d78da3f76a06, []int{0} +} +func (m *EventCreateGroup) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventCreateGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventCreateGroup.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 *EventCreateGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventCreateGroup.Merge(m, src) +} +func (m *EventCreateGroup) XXX_Size() int { + return m.Size() +} +func (m *EventCreateGroup) XXX_DiscardUnknown() { + xxx_messageInfo_EventCreateGroup.DiscardUnknown(m) +} + +var xxx_messageInfo_EventCreateGroup proto.InternalMessageInfo + +func (m *EventCreateGroup) GetGroupId() uint64 { + if m != nil { + return m.GroupId + } + return 0 +} + +// EventUpdateGroup is an event emitted when a group is updated. +type EventUpdateGroup struct { + // group_id is the unique ID of the group. + GroupId uint64 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` +} + +func (m *EventUpdateGroup) Reset() { *m = EventUpdateGroup{} } +func (m *EventUpdateGroup) String() string { return proto.CompactTextString(m) } +func (*EventUpdateGroup) ProtoMessage() {} +func (*EventUpdateGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_3545d78da3f76a06, []int{1} +} +func (m *EventUpdateGroup) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventUpdateGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventUpdateGroup.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 *EventUpdateGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventUpdateGroup.Merge(m, src) +} +func (m *EventUpdateGroup) XXX_Size() int { + return m.Size() +} +func (m *EventUpdateGroup) XXX_DiscardUnknown() { + xxx_messageInfo_EventUpdateGroup.DiscardUnknown(m) +} + +var xxx_messageInfo_EventUpdateGroup proto.InternalMessageInfo + +func (m *EventUpdateGroup) GetGroupId() uint64 { + if m != nil { + return m.GroupId + } + return 0 +} + +// EventCreateGroupAccount is an event emitted when a group account is created. +type EventCreateGroupAccount struct { + // address is the address of the group account. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *EventCreateGroupAccount) Reset() { *m = EventCreateGroupAccount{} } +func (m *EventCreateGroupAccount) String() string { return proto.CompactTextString(m) } +func (*EventCreateGroupAccount) ProtoMessage() {} +func (*EventCreateGroupAccount) Descriptor() ([]byte, []int) { + return fileDescriptor_3545d78da3f76a06, []int{2} +} +func (m *EventCreateGroupAccount) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventCreateGroupAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventCreateGroupAccount.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 *EventCreateGroupAccount) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventCreateGroupAccount.Merge(m, src) +} +func (m *EventCreateGroupAccount) XXX_Size() int { + return m.Size() +} +func (m *EventCreateGroupAccount) XXX_DiscardUnknown() { + xxx_messageInfo_EventCreateGroupAccount.DiscardUnknown(m) +} + +var xxx_messageInfo_EventCreateGroupAccount proto.InternalMessageInfo + +func (m *EventCreateGroupAccount) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +// EventUpdateGroupAccount is an event emitted when a group account is updated. +type EventUpdateGroupAccount struct { + // address is the address of the group account. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *EventUpdateGroupAccount) Reset() { *m = EventUpdateGroupAccount{} } +func (m *EventUpdateGroupAccount) String() string { return proto.CompactTextString(m) } +func (*EventUpdateGroupAccount) ProtoMessage() {} +func (*EventUpdateGroupAccount) Descriptor() ([]byte, []int) { + return fileDescriptor_3545d78da3f76a06, []int{3} +} +func (m *EventUpdateGroupAccount) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventUpdateGroupAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventUpdateGroupAccount.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 *EventUpdateGroupAccount) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventUpdateGroupAccount.Merge(m, src) +} +func (m *EventUpdateGroupAccount) XXX_Size() int { + return m.Size() +} +func (m *EventUpdateGroupAccount) XXX_DiscardUnknown() { + xxx_messageInfo_EventUpdateGroupAccount.DiscardUnknown(m) +} + +var xxx_messageInfo_EventUpdateGroupAccount proto.InternalMessageInfo + +func (m *EventUpdateGroupAccount) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +// EventCreateProposal is an event emitted when a proposal is created. +type EventCreateProposal struct { + // proposal_id is the unique ID of the proposal. + ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` +} + +func (m *EventCreateProposal) Reset() { *m = EventCreateProposal{} } +func (m *EventCreateProposal) String() string { return proto.CompactTextString(m) } +func (*EventCreateProposal) ProtoMessage() {} +func (*EventCreateProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_3545d78da3f76a06, []int{4} +} +func (m *EventCreateProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventCreateProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventCreateProposal.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 *EventCreateProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventCreateProposal.Merge(m, src) +} +func (m *EventCreateProposal) XXX_Size() int { + return m.Size() +} +func (m *EventCreateProposal) XXX_DiscardUnknown() { + xxx_messageInfo_EventCreateProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_EventCreateProposal proto.InternalMessageInfo + +func (m *EventCreateProposal) GetProposalId() uint64 { + if m != nil { + return m.ProposalId + } + return 0 +} + +// EventVote is an event emitted when a voter votes on a proposal. +type EventVote struct { + // proposal_id is the unique ID of the proposal. + ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` +} + +func (m *EventVote) Reset() { *m = EventVote{} } +func (m *EventVote) String() string { return proto.CompactTextString(m) } +func (*EventVote) ProtoMessage() {} +func (*EventVote) Descriptor() ([]byte, []int) { + return fileDescriptor_3545d78da3f76a06, []int{5} +} +func (m *EventVote) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventVote.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 *EventVote) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventVote.Merge(m, src) +} +func (m *EventVote) XXX_Size() int { + return m.Size() +} +func (m *EventVote) XXX_DiscardUnknown() { + xxx_messageInfo_EventVote.DiscardUnknown(m) +} + +var xxx_messageInfo_EventVote proto.InternalMessageInfo + +func (m *EventVote) GetProposalId() uint64 { + if m != nil { + return m.ProposalId + } + return 0 +} + +// EventExec is an event emitted when a proposal is executed. +type EventExec struct { + // proposal_id is the unique ID of the proposal. + ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` +} + +func (m *EventExec) Reset() { *m = EventExec{} } +func (m *EventExec) String() string { return proto.CompactTextString(m) } +func (*EventExec) ProtoMessage() {} +func (*EventExec) Descriptor() ([]byte, []int) { + return fileDescriptor_3545d78da3f76a06, []int{6} +} +func (m *EventExec) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventExec) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventExec.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 *EventExec) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventExec.Merge(m, src) +} +func (m *EventExec) XXX_Size() int { + return m.Size() +} +func (m *EventExec) XXX_DiscardUnknown() { + xxx_messageInfo_EventExec.DiscardUnknown(m) +} + +var xxx_messageInfo_EventExec proto.InternalMessageInfo + +func (m *EventExec) GetProposalId() uint64 { + if m != nil { + return m.ProposalId + } + return 0 +} + +func init() { + proto.RegisterType((*EventCreateGroup)(nil), "regen.group.v1alpha1.EventCreateGroup") + proto.RegisterType((*EventUpdateGroup)(nil), "regen.group.v1alpha1.EventUpdateGroup") + proto.RegisterType((*EventCreateGroupAccount)(nil), "regen.group.v1alpha1.EventCreateGroupAccount") + proto.RegisterType((*EventUpdateGroupAccount)(nil), "regen.group.v1alpha1.EventUpdateGroupAccount") + proto.RegisterType((*EventCreateProposal)(nil), "regen.group.v1alpha1.EventCreateProposal") + proto.RegisterType((*EventVote)(nil), "regen.group.v1alpha1.EventVote") + proto.RegisterType((*EventExec)(nil), "regen.group.v1alpha1.EventExec") +} + +func init() { proto.RegisterFile("regen/group/v1alpha1/events.proto", fileDescriptor_3545d78da3f76a06) } + +var fileDescriptor_3545d78da3f76a06 = []byte{ + // 263 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2c, 0x4a, 0x4d, 0x4f, + 0xcd, 0xd3, 0x4f, 0x2f, 0xca, 0x2f, 0x2d, 0xd0, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, 0x48, 0x34, + 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x01, + 0x2b, 0xd1, 0x03, 0x2b, 0xd1, 0x83, 0x29, 0x51, 0xd2, 0xe5, 0x12, 0x70, 0x05, 0xa9, 0x72, 0x2e, + 0x4a, 0x4d, 0x2c, 0x49, 0x75, 0x07, 0x49, 0x0a, 0x49, 0x72, 0x71, 0x80, 0x55, 0xc5, 0x67, 0xa6, + 0x48, 0x30, 0x2a, 0x30, 0x6a, 0xb0, 0x04, 0xb1, 0x83, 0xf9, 0x9e, 0x29, 0x70, 0xe5, 0xa1, 0x05, + 0x29, 0xc4, 0x28, 0x37, 0xe6, 0x12, 0x47, 0x37, 0xdd, 0x31, 0x39, 0x39, 0xbf, 0x34, 0xaf, 0x44, + 0x48, 0x82, 0x8b, 0x3d, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x18, 0xac, 0x89, 0x33, 0x08, 0xc6, + 0x85, 0x6b, 0x42, 0xb2, 0x83, 0xb0, 0x26, 0x33, 0x2e, 0x61, 0x24, 0x9b, 0x02, 0x8a, 0xf2, 0x0b, + 0xf2, 0x8b, 0x13, 0x73, 0x84, 0xe4, 0xb9, 0xb8, 0x0b, 0xa0, 0x6c, 0x84, 0xf3, 0xb8, 0x60, 0x42, + 0x9e, 0x29, 0x4a, 0x3a, 0x5c, 0x9c, 0x60, 0x7d, 0x61, 0xf9, 0x25, 0xa9, 0xc4, 0xab, 0x76, 0xad, + 0x48, 0x4d, 0x26, 0xa8, 0xda, 0xc9, 0xfd, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, + 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, + 0xa2, 0x74, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xc1, 0xd1, 0xa2, + 0x9b, 0x97, 0x5a, 0x52, 0x9e, 0x5f, 0x94, 0x0d, 0xe5, 0xe5, 0xa4, 0xa6, 0xa4, 0xa7, 0x16, 0xe9, + 0x57, 0x40, 0x22, 0x34, 0x89, 0x0d, 0x1c, 0x83, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2a, + 0x52, 0x60, 0x9b, 0xe6, 0x01, 0x00, 0x00, +} + +func (m *EventCreateGroup) 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 *EventCreateGroup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventCreateGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.GroupId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *EventUpdateGroup) 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 *EventUpdateGroup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventUpdateGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.GroupId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *EventCreateGroupAccount) 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 *EventCreateGroupAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventCreateGroupAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventUpdateGroupAccount) 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 *EventUpdateGroupAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventUpdateGroupAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventCreateProposal) 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 *EventCreateProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventCreateProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ProposalId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *EventVote) 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 *EventVote) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ProposalId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *EventExec) 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 *EventExec) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventExec) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ProposalId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { + offset -= sovEvents(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EventCreateGroup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovEvents(uint64(m.GroupId)) + } + return n +} + +func (m *EventUpdateGroup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovEvents(uint64(m.GroupId)) + } + return n +} + +func (m *EventCreateGroupAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventUpdateGroupAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventCreateProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovEvents(uint64(m.ProposalId)) + } + return n +} + +func (m *EventVote) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovEvents(uint64(m.ProposalId)) + } + return n +} + +func (m *EventExec) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovEvents(uint64(m.ProposalId)) + } + return n +} + +func sovEvents(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvents(x uint64) (n int) { + return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EventCreateGroup) 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 ErrIntOverflowEvents + } + 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: EventCreateGroup: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventCreateGroup: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventUpdateGroup) 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 ErrIntOverflowEvents + } + 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: EventUpdateGroup: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventUpdateGroup: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventCreateGroupAccount) 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 ErrIntOverflowEvents + } + 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: EventCreateGroupAccount: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventCreateGroupAccount: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventUpdateGroupAccount) 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 ErrIntOverflowEvents + } + 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: EventUpdateGroupAccount: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventUpdateGroupAccount: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventCreateProposal) 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 ErrIntOverflowEvents + } + 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: EventCreateProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventCreateProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventVote) 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 ErrIntOverflowEvents + } + 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: EventVote: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventVote: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventExec) 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 ErrIntOverflowEvents + } + 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: EventExec: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventExec: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvents(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, ErrIntOverflowEvents + } + 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, ErrIntOverflowEvents + } + 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, ErrIntOverflowEvents + } + 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, ErrInvalidLengthEvents + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvents + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvents + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvents = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvents = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvents = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/group/genesis.go b/x/group/genesis.go new file mode 100644 index 0000000000..53c25888ed --- /dev/null +++ b/x/group/genesis.go @@ -0,0 +1,29 @@ +package group + +import "github.com/cosmos/cosmos-sdk/codec/types" + +// NewGenesisState creates a new genesis state with default values. +func NewGenesisState() *GenesisState { + return &GenesisState{} +} + +func (s GenesisState) Validate() error { + return nil +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (s GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { + for _, g := range s.GroupAccounts { + err := g.UnpackInterfaces(unpacker) + if err != nil { + return err + } + } + for _, p := range s.Proposals { + err := p.UnpackInterfaces(unpacker) + if err != nil { + return err + } + } + return nil +} diff --git a/x/group/genesis.pb.go b/x/group/genesis.pb.go new file mode 100644 index 0000000000..092cf9853b --- /dev/null +++ b/x/group/genesis.pb.go @@ -0,0 +1,709 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: regen/group/v1alpha1/genesis.proto + +package group + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/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 group module's genesis state. +type GenesisState struct { + // group_seq is the group table orm.Sequence, + // it is used to get the next group ID. + GroupSeq uint64 `protobuf:"varint,1,opt,name=group_seq,json=groupSeq,proto3" json:"group_seq,omitempty"` + // groups is the list of groups info. + Groups []*GroupInfo `protobuf:"bytes,2,rep,name=groups,proto3" json:"groups,omitempty"` + // group_members is the list of groups members. + GroupMembers []*GroupMember `protobuf:"bytes,3,rep,name=group_members,json=groupMembers,proto3" json:"group_members,omitempty"` + // group_account_seq is the group account table orm.Sequence, + // it is used to generate the next group account address. + GroupAccountSeq uint64 `protobuf:"varint,4,opt,name=group_account_seq,json=groupAccountSeq,proto3" json:"group_account_seq,omitempty"` + // group_accounts is the list of group accounts info. + GroupAccounts []*GroupAccountInfo `protobuf:"bytes,5,rep,name=group_accounts,json=groupAccounts,proto3" json:"group_accounts,omitempty"` + // proposal_seq is the proposal table orm.Sequence, + // it is used to get the next proposal ID. + ProposalSeq uint64 `protobuf:"varint,6,opt,name=proposal_seq,json=proposalSeq,proto3" json:"proposal_seq,omitempty"` + // proposals is the list of proposals. + Proposals []*Proposal `protobuf:"bytes,7,rep,name=proposals,proto3" json:"proposals,omitempty"` + // votes is the list of votes. + Votes []*Vote `protobuf:"bytes,8,rep,name=votes,proto3" json:"votes,omitempty"` +} + +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_6ccc5d002e96a4ab, []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) GetGroupSeq() uint64 { + if m != nil { + return m.GroupSeq + } + return 0 +} + +func (m *GenesisState) GetGroups() []*GroupInfo { + if m != nil { + return m.Groups + } + return nil +} + +func (m *GenesisState) GetGroupMembers() []*GroupMember { + if m != nil { + return m.GroupMembers + } + return nil +} + +func (m *GenesisState) GetGroupAccountSeq() uint64 { + if m != nil { + return m.GroupAccountSeq + } + return 0 +} + +func (m *GenesisState) GetGroupAccounts() []*GroupAccountInfo { + if m != nil { + return m.GroupAccounts + } + return nil +} + +func (m *GenesisState) GetProposalSeq() uint64 { + if m != nil { + return m.ProposalSeq + } + return 0 +} + +func (m *GenesisState) GetProposals() []*Proposal { + if m != nil { + return m.Proposals + } + return nil +} + +func (m *GenesisState) GetVotes() []*Vote { + if m != nil { + return m.Votes + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "regen.group.v1alpha1.GenesisState") +} + +func init() { + proto.RegisterFile("regen/group/v1alpha1/genesis.proto", fileDescriptor_6ccc5d002e96a4ab) +} + +var fileDescriptor_6ccc5d002e96a4ab = []byte{ + // 358 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xbd, 0x4e, 0x02, 0x41, + 0x10, 0xc7, 0x39, 0xf9, 0x10, 0x16, 0xd0, 0xb8, 0xa1, 0xb8, 0x60, 0xb2, 0x02, 0x85, 0x21, 0x26, + 0xdc, 0x89, 0x16, 0x36, 0x36, 0x5a, 0x48, 0x2c, 0x48, 0xcc, 0x91, 0x58, 0xd8, 0x98, 0x03, 0xc7, + 0x85, 0x08, 0xb7, 0xc7, 0xee, 0x82, 0xfa, 0x16, 0x3e, 0x8f, 0x4f, 0x60, 0x49, 0x69, 0x69, 0xe0, + 0x45, 0xcc, 0xcd, 0x1e, 0x41, 0x93, 0x0b, 0xdd, 0xce, 0xec, 0xef, 0xff, 0x51, 0x0c, 0x69, 0x48, + 0xe0, 0x10, 0xb8, 0x5c, 0x8a, 0x59, 0xe8, 0xce, 0xdb, 0xfe, 0x38, 0x1c, 0xfa, 0x6d, 0x97, 0x43, + 0x00, 0x6a, 0xa4, 0x9c, 0x50, 0x0a, 0x2d, 0x68, 0x05, 0x19, 0x07, 0x19, 0x67, 0xcd, 0x54, 0x2b, + 0x5c, 0x70, 0x81, 0x80, 0x1b, 0xbd, 0x0c, 0x5b, 0xad, 0x25, 0xfa, 0xe9, 0xf7, 0x10, 0x62, 0xb7, + 0xc6, 0x67, 0x9a, 0x94, 0x3a, 0xc6, 0xbf, 0xa7, 0x7d, 0x0d, 0xf4, 0x90, 0x14, 0x10, 0x7f, 0x54, + 0x30, 0xb5, 0xad, 0x9a, 0xd5, 0xcc, 0x78, 0x79, 0x5c, 0xf4, 0x60, 0x4a, 0x2f, 0x48, 0x0e, 0xdf, + 0xca, 0xde, 0xa9, 0xa5, 0x9b, 0xc5, 0xb3, 0x23, 0x27, 0xa9, 0x8c, 0xd3, 0x89, 0xc6, 0xdb, 0xe0, + 0x59, 0x78, 0x31, 0x4e, 0x6f, 0x48, 0xd9, 0xb8, 0x4e, 0x60, 0xd2, 0x07, 0xa9, 0xec, 0x34, 0xea, + 0xeb, 0x5b, 0xf4, 0x5d, 0x24, 0xbd, 0x12, 0xdf, 0x0c, 0x8a, 0x9e, 0x90, 0x03, 0xe3, 0xe3, 0x0f, + 0x06, 0x62, 0x16, 0x68, 0x6c, 0x99, 0xc1, 0x96, 0xfb, 0xf8, 0x71, 0x65, 0xf6, 0x51, 0xd9, 0x2e, + 0xd9, 0xfb, 0xc7, 0x2a, 0x3b, 0x8b, 0xa1, 0xc7, 0x5b, 0x42, 0x63, 0x39, 0x76, 0x2f, 0xff, 0x35, + 0x54, 0xb4, 0x4e, 0x4a, 0xa1, 0x14, 0xa1, 0x50, 0xfe, 0x18, 0x53, 0x73, 0x98, 0x5a, 0x5c, 0xef, + 0xa2, 0xc4, 0x4b, 0x52, 0x58, 0x8f, 0xca, 0xde, 0xc5, 0x30, 0x96, 0x1c, 0x76, 0x17, 0x63, 0xde, + 0x46, 0x40, 0x4f, 0x49, 0x76, 0x2e, 0x34, 0x28, 0x3b, 0x8f, 0xca, 0x6a, 0xb2, 0xf2, 0x5e, 0x68, + 0xf0, 0x0c, 0x78, 0xdd, 0xf9, 0x5a, 0x32, 0x6b, 0xb1, 0x64, 0xd6, 0xcf, 0x92, 0x59, 0x1f, 0x2b, + 0x96, 0x5a, 0xac, 0x58, 0xea, 0x7b, 0xc5, 0x52, 0x0f, 0x2d, 0x3e, 0xd2, 0xc3, 0x59, 0xdf, 0x19, + 0x88, 0x89, 0x8b, 0x36, 0xad, 0x00, 0xf4, 0xab, 0x90, 0x2f, 0xf1, 0x34, 0x86, 0x27, 0x0e, 0xd2, + 0x7d, 0x33, 0xa7, 0xd1, 0xcf, 0xe1, 0x31, 0x9c, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x38, 0x49, + 0x53, 0x1b, 0x80, 0x02, 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.Votes) > 0 { + for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Votes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } + if len(m.Proposals) > 0 { + for iNdEx := len(m.Proposals) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Proposals[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if m.ProposalSeq != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.ProposalSeq)) + i-- + dAtA[i] = 0x30 + } + if len(m.GroupAccounts) > 0 { + for iNdEx := len(m.GroupAccounts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.GroupAccounts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if m.GroupAccountSeq != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.GroupAccountSeq)) + i-- + dAtA[i] = 0x20 + } + if len(m.GroupMembers) > 0 { + for iNdEx := len(m.GroupMembers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.GroupMembers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Groups) > 0 { + for iNdEx := len(m.Groups) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Groups[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.GroupSeq != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.GroupSeq)) + i-- + dAtA[i] = 0x8 + } + 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 + if m.GroupSeq != 0 { + n += 1 + sovGenesis(uint64(m.GroupSeq)) + } + if len(m.Groups) > 0 { + for _, e := range m.Groups { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.GroupMembers) > 0 { + for _, e := range m.GroupMembers { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.GroupAccountSeq != 0 { + n += 1 + sovGenesis(uint64(m.GroupAccountSeq)) + } + if len(m.GroupAccounts) > 0 { + for _, e := range m.GroupAccounts { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.ProposalSeq != 0 { + n += 1 + sovGenesis(uint64(m.ProposalSeq)) + } + if len(m.Proposals) > 0 { + for _, e := range m.Proposals { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Votes) > 0 { + for _, e := range m.Votes { + 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 != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupSeq", wireType) + } + m.GroupSeq = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupSeq |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Groups", 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.Groups = append(m.Groups, &GroupInfo{}) + if err := m.Groups[len(m.Groups)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupMembers", 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.GroupMembers = append(m.GroupMembers, &GroupMember{}) + if err := m.GroupMembers[len(m.GroupMembers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupAccountSeq", wireType) + } + m.GroupAccountSeq = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupAccountSeq |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupAccounts", 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.GroupAccounts = append(m.GroupAccounts, &GroupAccountInfo{}) + if err := m.GroupAccounts[len(m.GroupAccounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalSeq", wireType) + } + m.ProposalSeq = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalSeq |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proposals", 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.Proposals = append(m.Proposals, &Proposal{}) + if err := m.Proposals[len(m.Proposals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Votes", 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.Votes = append(m.Votes, &Vote{}) + if err := m.Votes[len(m.Votes)-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 { + return ErrInvalidLengthGenesis + } + if (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/group/keys.go b/x/group/keys.go new file mode 100644 index 0000000000..4086423f60 --- /dev/null +++ b/x/group/keys.go @@ -0,0 +1,14 @@ +package group + +const ( + // ModuleName is the module name constant used in many places + ModuleName = "group" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + DefaultParamspace = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName +) diff --git a/x/group/module/module.go b/x/group/module/module.go new file mode 100644 index 0000000000..df7ab72532 --- /dev/null +++ b/x/group/module/module.go @@ -0,0 +1,75 @@ +package module + +import ( + "encoding/json" + "fmt" + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + climodule "github.com/regen-network/regen-ledger/types/module/client/cli" + servermodule "github.com/regen-network/regen-ledger/types/module/server" + "github.com/regen-network/regen-ledger/x/group" + "github.com/regen-network/regen-ledger/x/group/client" + "github.com/regen-network/regen-ledger/x/group/server" + + sdkclient "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" + "github.com/spf13/cobra" +) + +type Module struct { + AccountKeeper server.AccountKeeper +} + +var _ module.AppModuleBasic = Module{} +var _ servermodule.Module = Module{} +var _ climodule.Module = Module{} +var _ servermodule.LegacyRouteModule = Module{} + +func (a Module) Name() string { + return group.ModuleName +} + +// RegisterInterfaces registers module concrete types into protobuf Any. +func (a Module) RegisterInterfaces(registry types.InterfaceRegistry) { + group.RegisterTypes(registry) +} + +func (a Module) RegisterServices(configurator servermodule.Configurator) { + server.RegisterServices(configurator, a.AccountKeeper) +} + +func (a Module) DefaultGenesis(marshaler codec.JSONMarshaler) json.RawMessage { + return marshaler.MustMarshalJSON(group.NewGenesisState()) +} + +func (a Module) ValidateGenesis(cdc codec.JSONMarshaler, config sdkclient.TxEncodingConfig, bz json.RawMessage) error { + var data group.GenesisState + if err := cdc.UnmarshalJSON(bz, &data); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", group.ModuleName, err) + } + return data.Validate() +} + +func (a Module) RegisterGRPCGatewayRoutes(sdkclient.Context, *runtime.ServeMux) {} + +func (a Module) GetTxCmd() *cobra.Command { + return client.TxCmd(a.Name()) +} + +func (a Module) GetQueryCmd() *cobra.Command { + return client.QueryCmd(a.Name()) +} + +/**** DEPRECATED ****/ +func (a Module) RegisterRESTRoutes(sdkclient.Context, *mux.Router) {} +func (a Module) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + group.RegisterLegacyAminoCodec(cdc) +} + +func (a Module) Route(configurator servermodule.Configurator) sdk.Route { + return sdk.NewRoute(group.RouterKey, server.NewHandler(configurator, a.AccountKeeper)) +} diff --git a/x/group/msgs.go b/x/group/msgs.go new file mode 100644 index 0000000000..22bbbfc565 --- /dev/null +++ b/x/group/msgs.go @@ -0,0 +1,677 @@ +package group + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + proto "github.com/gogo/protobuf/proto" + "github.com/regen-network/regen-ledger/math" +) + +// Group message types and routes +const ( + TypeMsgCreateGroup = "create_group" + TypeMsgUpdateGroupAdmin = "update_group_admin" + TypeMsgUpdateGroupComment = "update_group_comment" + TypeMsgUpdateGroupMembers = "update_group_members" + TypeMsgCreateGroupAccount = "create_group_account" + TypeMsgUpdateGroupAccountAdmin = "update_group_account_admin" + TypeMsgUpdateGroupAccountDecisionPolicy = "update_group_account_decision_policy" + TypeMsgUpdateGroupAccountComment = "update_group_account_comment" + TypeMsgCreateProposal = "create_proposal" + TypeMsgVote = "vote" + TypeMsgExec = "exec" +) + +var _ sdk.Msg = &MsgCreateGroupRequest{} + +// Route Implements Msg. +func (m MsgCreateGroupRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (m MsgCreateGroupRequest) Type() string { return TypeMsgCreateGroup } + +// GetSignBytes Implements Msg. +func (m MsgCreateGroupRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgCreateGroupRequest. +func (m MsgCreateGroupRequest) GetSigners() []sdk.AccAddress { + admin, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + panic(err) + } + return []sdk.AccAddress{admin} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgCreateGroupRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + return sdkerrors.Wrap(err, "admin") + } + + members := Members{Members: m.Members} + if err := members.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "members") + } + for i := range m.Members { + member := m.Members[i] + if _, err := math.ParsePositiveDecimal(member.Weight); err != nil { + return sdkerrors.Wrap(err, "member weight") + } + } + return nil +} + +func (m Member) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Address) + if err != nil { + return sdkerrors.Wrap(err, "address") + } + if _, err := math.ParseNonNegativeDecimal(m.Weight); err != nil { + return sdkerrors.Wrap(err, "weight") + } + + return nil +} + +var _ sdk.Msg = &MsgUpdateGroupAdminRequest{} + +// Route Implements Msg. +func (m MsgUpdateGroupAdminRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (m MsgUpdateGroupAdminRequest) Type() string { return TypeMsgUpdateGroupAdmin } + +// GetSignBytes Implements Msg. +func (m MsgUpdateGroupAdminRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgUpdateGroupAdminRequest. +func (m MsgUpdateGroupAdminRequest) GetSigners() []sdk.AccAddress { + admin, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + panic(err) + } + return []sdk.AccAddress{admin} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgUpdateGroupAdminRequest) ValidateBasic() error { + if m.GroupId == 0 { + return sdkerrors.Wrap(ErrEmpty, "group") + } + + admin, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + return sdkerrors.Wrap(err, "admin") + } + + newAdmin, err := sdk.AccAddressFromBech32(m.NewAdmin) + if err != nil { + return sdkerrors.Wrap(err, "new admin") + } + + if admin.Equals(newAdmin) { + return sdkerrors.Wrap(ErrInvalid, "new and old admin are the same") + } + return nil +} + +func (m *MsgUpdateGroupAdminRequest) GetGroupID() uint64 { + return m.GroupId +} + +var _ sdk.Msg = &MsgUpdateGroupMetadataRequest{} + +// Route Implements Msg. +func (m MsgUpdateGroupMetadataRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (m MsgUpdateGroupMetadataRequest) Type() string { return TypeMsgUpdateGroupComment } + +// GetSignBytes Implements Msg. +func (m MsgUpdateGroupMetadataRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgUpdateGroupMetadataRequest. +func (m MsgUpdateGroupMetadataRequest) GetSigners() []sdk.AccAddress { + admin, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + panic(err) + } + return []sdk.AccAddress{admin} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgUpdateGroupMetadataRequest) ValidateBasic() error { + if m.GroupId == 0 { + return sdkerrors.Wrap(ErrEmpty, "group") + + } + _, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + return sdkerrors.Wrap(err, "admin") + } + return nil +} + +func (m *MsgUpdateGroupMetadataRequest) GetGroupID() uint64 { + return m.GroupId +} + +var _ sdk.Msg = &MsgUpdateGroupMembersRequest{} + +// Route Implements Msg. +func (m MsgUpdateGroupMembersRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (m MsgUpdateGroupMembersRequest) Type() string { return TypeMsgUpdateGroupMembers } + +// GetSignBytes Implements Msg. +func (m MsgUpdateGroupMembersRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +var _ sdk.MsgRequest = &MsgUpdateGroupMembersRequest{} + +// GetSigners returns the expected signers for a MsgUpdateGroupMembersRequest. +func (m MsgUpdateGroupMembersRequest) GetSigners() []sdk.AccAddress { + admin, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + panic(err) + } + return []sdk.AccAddress{admin} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgUpdateGroupMembersRequest) ValidateBasic() error { + if m.GroupId == 0 { + return sdkerrors.Wrap(ErrEmpty, "group") + + } + _, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + return sdkerrors.Wrap(err, "admin") + } + + if len(m.MemberUpdates) == 0 { + return sdkerrors.Wrap(ErrEmpty, "member updates") + } + members := Members{Members: m.MemberUpdates} + if err := members.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "members") + } + return nil +} + +func (m *MsgUpdateGroupMembersRequest) GetGroupID() uint64 { + return m.GroupId +} + +var _ sdk.Msg = &MsgCreateGroupAccountRequest{} + +// Route Implements Msg. +func (m MsgCreateGroupAccountRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (m MsgCreateGroupAccountRequest) Type() string { return TypeMsgCreateGroupAccount } + +// GetSignBytes Implements Msg. +func (m MsgCreateGroupAccountRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgCreateGroupAccountRequest. +func (m MsgCreateGroupAccountRequest) GetSigners() []sdk.AccAddress { + admin, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + panic(err) + } + return []sdk.AccAddress{admin} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgCreateGroupAccountRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + return sdkerrors.Wrap(err, "admin") + } + if m.GroupId == 0 { + return sdkerrors.Wrap(ErrEmpty, "group") + } + + policy := m.GetDecisionPolicy() + if policy == nil { + return sdkerrors.Wrap(ErrEmpty, "decision policy") + } + + if err := policy.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "decision policy") + } + return nil +} + +var _ sdk.Msg = &MsgUpdateGroupAccountAdminRequest{} + +// Route Implements Msg. +func (m MsgUpdateGroupAccountAdminRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (m MsgUpdateGroupAccountAdminRequest) Type() string { return TypeMsgUpdateGroupAccountAdmin } + +// GetSignBytes Implements Msg. +func (m MsgUpdateGroupAccountAdminRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgUpdateGroupAccountAdminRequest. +func (m MsgUpdateGroupAccountAdminRequest) GetSigners() []sdk.AccAddress { + admin, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + panic(err) + } + return []sdk.AccAddress{admin} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgUpdateGroupAccountAdminRequest) ValidateBasic() error { + admin, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + return sdkerrors.Wrap(err, "admin") + } + + newAdmin, err := sdk.AccAddressFromBech32(m.NewAdmin) + if err != nil { + return sdkerrors.Wrap(err, "new admin") + } + + _, err = sdk.AccAddressFromBech32(m.Address) + if err != nil { + return sdkerrors.Wrap(err, "group account") + } + + if admin.Equals(newAdmin) { + return sdkerrors.Wrap(ErrInvalid, "new and old admin are the same") + } + return nil +} + +var _ sdk.Msg = &MsgUpdateGroupAccountDecisionPolicyRequest{} +var _ types.UnpackInterfacesMessage = MsgUpdateGroupAccountDecisionPolicyRequest{} + +func NewMsgUpdateGroupAccountDecisionPolicyRequest(admin sdk.AccAddress, address sdk.AccAddress, decisionPolicy DecisionPolicy) (*MsgUpdateGroupAccountDecisionPolicyRequest, error) { + m := &MsgUpdateGroupAccountDecisionPolicyRequest{ + Admin: admin.String(), + Address: address.String(), + } + err := m.SetDecisionPolicy(decisionPolicy) + if err != nil { + return nil, err + } + return m, nil +} + +func (m *MsgUpdateGroupAccountDecisionPolicyRequest) SetDecisionPolicy(decisionPolicy DecisionPolicy) error { + msg, ok := decisionPolicy.(proto.Message) + if !ok { + return fmt.Errorf("can't proto marshal %T", msg) + } + any, err := types.NewAnyWithValue(msg) + if err != nil { + return err + } + m.DecisionPolicy = any + return nil +} + +// Route Implements Msg. +func (m MsgUpdateGroupAccountDecisionPolicyRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (m MsgUpdateGroupAccountDecisionPolicyRequest) Type() string { + return TypeMsgUpdateGroupAccountDecisionPolicy +} + +// GetSignBytes Implements Msg. +func (m MsgUpdateGroupAccountDecisionPolicyRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgUpdateGroupAccountDecisionPolicyRequest. +func (m MsgUpdateGroupAccountDecisionPolicyRequest) GetSigners() []sdk.AccAddress { + admin, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + panic(err) + } + return []sdk.AccAddress{admin} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgUpdateGroupAccountDecisionPolicyRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + return sdkerrors.Wrap(err, "admin") + } + + _, err = sdk.AccAddressFromBech32(m.Address) + if err != nil { + return sdkerrors.Wrap(err, "group account") + } + + policy := m.GetDecisionPolicy() + if policy == nil { + return sdkerrors.Wrap(ErrEmpty, "decision policy") + } + + if err := policy.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "decision policy") + } + + return nil +} + +func (m *MsgUpdateGroupAccountDecisionPolicyRequest) GetDecisionPolicy() DecisionPolicy { + decisionPolicy, ok := m.DecisionPolicy.GetCachedValue().(DecisionPolicy) + if !ok { + return nil + } + return decisionPolicy +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (m MsgUpdateGroupAccountDecisionPolicyRequest) UnpackInterfaces(unpacker types.AnyUnpacker) error { + var decisionPolicy DecisionPolicy + return unpacker.UnpackAny(m.DecisionPolicy, &decisionPolicy) +} + +var _ sdk.Msg = &MsgUpdateGroupAccountMetadataRequest{} + +// Route Implements Msg. +func (m MsgUpdateGroupAccountMetadataRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (m MsgUpdateGroupAccountMetadataRequest) Type() string { return TypeMsgUpdateGroupAccountComment } + +// GetSignBytes Implements Msg. +func (m MsgUpdateGroupAccountMetadataRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgUpdateGroupAccountMetadataRequest. +func (m MsgUpdateGroupAccountMetadataRequest) GetSigners() []sdk.AccAddress { + admin, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + panic(err) + } + return []sdk.AccAddress{admin} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgUpdateGroupAccountMetadataRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Admin) + if err != nil { + return sdkerrors.Wrap(err, "admin") + } + + _, err = sdk.AccAddressFromBech32(m.Address) + if err != nil { + return sdkerrors.Wrap(err, "group account") + } + + return nil +} + +var _ sdk.Msg = &MsgCreateGroupAccountRequest{} +var _ types.UnpackInterfacesMessage = MsgCreateGroupAccountRequest{} + +// NewMsgCreateGroupAccountRequest creates a new MsgCreateGroupAccountRequest. +func NewMsgCreateGroupAccountRequest(admin sdk.AccAddress, group uint64, metadata []byte, decisionPolicy DecisionPolicy) (*MsgCreateGroupAccountRequest, error) { + m := &MsgCreateGroupAccountRequest{ + Admin: admin.String(), + GroupId: group, + Metadata: metadata, + } + err := m.SetDecisionPolicy(decisionPolicy) + if err != nil { + return nil, err + } + return m, nil +} + +func (m *MsgCreateGroupAccountRequest) GetAdmin() string { + return m.Admin +} + +func (m *MsgCreateGroupAccountRequest) GetGroupID() uint64 { + return m.GroupId +} + +func (m *MsgCreateGroupAccountRequest) GetMetadata() []byte { + return m.Metadata +} + +func (m *MsgCreateGroupAccountRequest) GetDecisionPolicy() DecisionPolicy { + decisionPolicy, ok := m.DecisionPolicy.GetCachedValue().(DecisionPolicy) + if !ok { + return nil + } + return decisionPolicy +} + +func (m *MsgCreateGroupAccountRequest) SetDecisionPolicy(decisionPolicy DecisionPolicy) error { + msg, ok := decisionPolicy.(proto.Message) + if !ok { + return fmt.Errorf("can't proto marshal %T", msg) + } + any, err := types.NewAnyWithValue(msg) + if err != nil { + return err + } + m.DecisionPolicy = any + return nil +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (m MsgCreateGroupAccountRequest) UnpackInterfaces(unpacker types.AnyUnpacker) error { + var decisionPolicy DecisionPolicy + return unpacker.UnpackAny(m.DecisionPolicy, &decisionPolicy) +} + +var _ sdk.Msg = &MsgCreateProposalRequest{} + +// NewMsgCreateProposalRequest creates a new MsgCreateProposalRequest. +func NewMsgCreateProposalRequest(address string, proposers []string, msgs []sdk.Msg, metadata []byte) (*MsgCreateProposalRequest, error) { + m := &MsgCreateProposalRequest{ + Address: address, + Proposers: proposers, + Metadata: metadata, + } + err := m.SetMsgs(msgs) + if err != nil { + return nil, err + } + return m, nil +} + +// Route Implements Msg. +func (m MsgCreateProposalRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (m MsgCreateProposalRequest) Type() string { return TypeMsgCreateProposal } + +// GetSignBytes Implements Msg. +func (m MsgCreateProposalRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgCreateProposalRequest. +func (m MsgCreateProposalRequest) GetSigners() []sdk.AccAddress { + addrs := make([]sdk.AccAddress, len(m.Proposers)) + for i, proposer := range m.Proposers { + addr, err := sdk.AccAddressFromBech32(proposer) + if err != nil { + panic(err) + } + addrs[i] = addr + } + return addrs +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgCreateProposalRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Address) + if err != nil { + return sdkerrors.Wrap(err, "group account") + } + + if len(m.Proposers) == 0 { + return sdkerrors.Wrap(ErrEmpty, "proposers") + } + addrs := make([]sdk.AccAddress, len(m.Proposers)) + for i, proposer := range m.Proposers { + addr, err := sdk.AccAddressFromBech32(proposer) + if err != nil { + return sdkerrors.Wrap(err, "proposers") + } + addrs[i] = addr + } + if err := AccAddresses(addrs).ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "proposers") + } + + msgs := m.GetMsgs() + for i, msg := range msgs { + if err := msg.ValidateBasic(); err != nil { + return sdkerrors.Wrapf(err, "msg %d", i) + } + } + return nil +} + +// SetMsgs packs msgs into Any's +func (m *MsgCreateProposalRequest) SetMsgs(msgs []sdk.Msg) error { + anys := make([]*types.Any, len(msgs)) + + for i, msg := range msgs { + var err error + anys[i], err = types.NewAnyWithValue(msg) + if err != nil { + return err + } + } + m.Msgs = anys + return nil +} + +// GetMsgs unpacks m.Msgs Any's into sdk.Msg's +func (m MsgCreateProposalRequest) GetMsgs() []sdk.Msg { + msgs := make([]sdk.Msg, len(m.Msgs)) + for i, any := range m.Msgs { + msg, ok := any.GetCachedValue().(sdk.Msg) + if !ok { + return nil + } + msgs[i] = msg + } + return msgs +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (m MsgCreateProposalRequest) UnpackInterfaces(unpacker types.AnyUnpacker) error { + // for _, m := range m.Msgs { + // err := types.UnpackInterfaces(m, unpacker) + // if err != nil { + // return err + // } + // } + for _, any := range m.Msgs { + var msg sdk.Msg + err := unpacker.UnpackAny(any, &msg) + if err != nil { + return err + } + } + + return nil +} + +var _ sdk.Msg = &MsgVoteRequest{} + +// Route Implements Msg. +func (m MsgVoteRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (m MsgVoteRequest) Type() string { return TypeMsgVote } + +// GetSignBytes Implements Msg. +func (m MsgVoteRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgVoteRequest. +func (m MsgVoteRequest) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Voter) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgVoteRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Voter) + if err != nil { + return sdkerrors.Wrap(err, "voter") + } + if m.ProposalId == 0 { + return sdkerrors.Wrap(ErrEmpty, "proposal") + } + if m.Choice == Choice_CHOICE_UNSPECIFIED { + return sdkerrors.Wrap(ErrEmpty, "choice") + } + if _, ok := Choice_name[int32(m.Choice)]; !ok { + return sdkerrors.Wrap(ErrInvalid, "choice") + } + return nil +} + +var _ sdk.Msg = &MsgExecRequest{} + +// Route Implements Msg. +func (m MsgExecRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (m MsgExecRequest) Type() string { return TypeMsgExec } + +// GetSignBytes Implements Msg. +func (m MsgExecRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgExecRequest. +func (m MsgExecRequest) GetSigners() []sdk.AccAddress { + signer, err := sdk.AccAddressFromBech32(m.Signer) + if err != nil { + panic(err) + } + return []sdk.AccAddress{signer} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgExecRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Signer) + if err != nil { + return sdkerrors.Wrap(err, "signer") + } + if m.ProposalId == 0 { + return sdkerrors.Wrap(ErrEmpty, "proposal") + } + return nil +} diff --git a/x/group/msgs_test.go b/x/group/msgs_test.go new file mode 100644 index 0000000000..4d4a825c23 --- /dev/null +++ b/x/group/msgs_test.go @@ -0,0 +1,350 @@ +package group + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + proto "github.com/gogo/protobuf/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestMsgCreateGroupValidation(t *testing.T) { + _, _, myAddr := testdata.KeyTestPubAddr() + _, _, myOtherAddr := testdata.KeyTestPubAddr() + + specs := map[string]struct { + src MsgCreateGroupRequest + expErr bool + }{ + "all good with minimum fields set": { + src: MsgCreateGroupRequest{Admin: myAddr.String()}, + }, + "all good with a member": { + src: MsgCreateGroupRequest{ + Admin: myAddr.String(), + Members: []Member{ + {Address: myAddr.String(), Weight: "1"}, + }, + }, + }, + "all good with multiple members": { + src: MsgCreateGroupRequest{ + Admin: myAddr.String(), + Members: []Member{ + {Address: myAddr.String(), Weight: "1"}, + {Address: myOtherAddr.String(), Weight: "2"}, + }, + }, + }, + "admin required": { + src: MsgCreateGroupRequest{}, + expErr: true, + }, + "valid admin required": { + src: MsgCreateGroupRequest{ + Admin: "invalid-address", + }, + expErr: true, + }, + "duplicate member addresses not allowed": { + src: MsgCreateGroupRequest{ + Admin: myAddr.String(), + Members: []Member{ + {Address: myAddr.String(), Weight: "1"}, + {Address: myAddr.String(), Weight: "2"}, + }, + }, + expErr: true, + }, + "negative member's weight not allowed": { + src: MsgCreateGroupRequest{ + Admin: myAddr.String(), + Members: []Member{ + {Address: myAddr.String(), Weight: "-1"}, + }, + }, + expErr: true, + }, + "empty member's weight not allowed": { + src: MsgCreateGroupRequest{ + Admin: myAddr.String(), + Members: []Member{{Address: myAddr.String()}}, + }, + expErr: true, + }, + "zero member's weight not allowed": { + src: MsgCreateGroupRequest{ + Admin: myAddr.String(), + Members: []Member{{Address: myAddr.String(), Weight: "0"}}, + }, + expErr: true, + }, + "member address required": { + src: MsgCreateGroupRequest{ + Admin: myAddr.String(), + Members: []Member{ + {Weight: "1"}, + }, + }, + expErr: true, + }, + "valid member address required": { + src: MsgCreateGroupRequest{ + Admin: myAddr.String(), + Members: []Member{ + {Address: "invalid-address", Weight: "1"}, + }, + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgCreateGroupSigner(t *testing.T) { + _, _, myAddr := testdata.KeyTestPubAddr() + assert.Equal(t, []sdk.AccAddress{myAddr}, MsgCreateGroupRequest{Admin: myAddr.String()}.GetSigners()) +} + +func TestMsgCreateGroupAccount(t *testing.T) { + _, _, myAddr := testdata.KeyTestPubAddr() + + specs := map[string]struct { + admin sdk.AccAddress + group uint64 + threshold string + timeout proto.Duration + expErr bool + }{ + "all good with minimum fields set": { + admin: myAddr, + group: 1, + threshold: "1", + timeout: proto.Duration{Seconds: 1}, + }, + "zero threshold not allowed": { + admin: myAddr, + group: 1, + threshold: "0", + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + "admin required": { + group: 1, + threshold: "1", + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + "valid admin required": { + admin: []byte("invalid-address"), + group: 1, + threshold: "1", + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + "group required": { + admin: myAddr, + threshold: "1", + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + "decision policy required": { + admin: myAddr, + group: 1, + expErr: true, + }, + "decision policy without timeout": { + admin: myAddr, + group: 1, + threshold: "1", + expErr: true, + }, + "decision policy with invalid timeout": { + admin: myAddr, + group: 1, + threshold: "1", + timeout: proto.Duration{Seconds: -1}, + expErr: true, + }, + "decision policy without threshold": { + admin: myAddr, + group: 1, + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + "decision policy with negative threshold": { + admin: myAddr, + group: 1, + threshold: "-1", + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + m, err := NewMsgCreateGroupAccountRequest( + spec.admin, + spec.group, + nil, + &ThresholdDecisionPolicy{ + Threshold: spec.threshold, + Timeout: spec.timeout, + }, + ) + require.NoError(t, err) + + if spec.expErr { + require.Error(t, m.ValidateBasic()) + } else { + require.NoError(t, m.ValidateBasic()) + } + }) + } +} + +func TestMsgCreateProposalRequest(t *testing.T) { + _, _, addr := testdata.KeyTestPubAddr() + groupAccAddr := addr.String() + + _, _, addr = testdata.KeyTestPubAddr() + memberAddr := addr.String() + + specs := map[string]struct { + src MsgCreateProposalRequest + expErr bool + }{ + "all good with minimum fields set": { + src: MsgCreateProposalRequest{ + Address: groupAccAddr, + Proposers: []string{memberAddr}, + }, + }, + "group account required": { + src: MsgCreateProposalRequest{ + Proposers: []string{memberAddr}, + }, + expErr: true, + }, + "proposers required": { + src: MsgCreateProposalRequest{ + Address: groupAccAddr, + }, + expErr: true, + }, + "valid proposer address required": { + src: MsgCreateProposalRequest{ + Address: groupAccAddr, + Proposers: []string{"invalid-member-address"}, + }, + expErr: true, + }, + "no duplicate proposers": { + src: MsgCreateProposalRequest{ + Address: groupAccAddr, + Proposers: []string{memberAddr, memberAddr}, + }, + expErr: true, + }, + "empty proposer address not allowed": { + src: MsgCreateProposalRequest{ + Address: groupAccAddr, + Proposers: []string{memberAddr, ""}, + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgVote(t *testing.T) { + _, _, addr := testdata.KeyTestPubAddr() + memberAddr := addr.String() + + specs := map[string]struct { + src MsgVoteRequest + expErr bool + }{ + "all good with minimum fields set": { + src: MsgVoteRequest{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + Voter: memberAddr, + }, + }, + "proposal required": { + src: MsgVoteRequest{ + Choice: Choice_CHOICE_YES, + Voter: memberAddr, + }, + expErr: true, + }, + "choice required": { + src: MsgVoteRequest{ + ProposalId: 1, + Voter: memberAddr, + }, + expErr: true, + }, + "valid choice required": { + src: MsgVoteRequest{ + ProposalId: 1, + Choice: 5, + Voter: memberAddr, + }, + expErr: true, + }, + "voter required": { + src: MsgVoteRequest{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + }, + expErr: true, + }, + "valid voter address required": { + src: MsgVoteRequest{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + Voter: "invalid-member-address", + }, + expErr: true, + }, + "empty voters address not allowed": { + src: MsgVoteRequest{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + Voter: "", + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/group/proposal.go b/x/group/proposal.go new file mode 100644 index 0000000000..c7ac4b7f7c --- /dev/null +++ b/x/group/proposal.go @@ -0,0 +1,115 @@ +package group + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/regen-network/regen-ledger/orm" +) + +func (p *Proposal) GetMsgs() []sdk.Msg { + msgs := make([]sdk.Msg, len(p.Msgs)) + for i, any := range p.Msgs { + msg, ok := any.GetCachedValue().(sdk.Msg) + if !ok { + return nil + } + msgs[i] = msg + } + return msgs +} + +func (p *Proposal) SetMsgs(new []sdk.Msg) error { + p.Msgs = make([]*codectypes.Any, len(new)) + for i := range new { + if new[i] == nil { + return sdkerrors.Wrap(ErrInvalid, "msg must not be nil") + } + any, err := codectypes.NewAnyWithValue(new[i]) + if err != nil { + return err + } + p.Msgs[i] = any + } + return nil +} + +func (p Proposal) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(p.Address) + if err != nil { + return sdkerrors.Wrap(err, "group account") + } + + if len(p.Proposers) == 0 { + return sdkerrors.Wrap(ErrEmpty, "proposers") + } + addrs := make([]sdk.AccAddress, len(p.Proposers)) + for i, proposer := range p.Proposers { + addr, err := sdk.AccAddressFromBech32(proposer) + if err != nil { + return sdkerrors.Wrap(err, "proposers") + } + addrs[i] = addr + } + if err := AccAddresses(addrs).ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "proposers") + } + + if p.SubmittedAt.Seconds == 0 && p.SubmittedAt.Nanos == 0 { + return sdkerrors.Wrap(ErrEmpty, "submitted at") + } + if p.GroupVersion == 0 { + return sdkerrors.Wrap(ErrEmpty, "group version") + } + if p.GroupAccountVersion == 0 { + return sdkerrors.Wrap(ErrEmpty, "group account version") + } + if p.Status == ProposalStatusInvalid { + return sdkerrors.Wrap(ErrEmpty, "status") + } + if _, ok := Proposal_Status_name[int32(p.Status)]; !ok { + return sdkerrors.Wrap(ErrInvalid, "status") + } + if p.Result == ProposalResultInvalid { + return sdkerrors.Wrap(ErrEmpty, "result") + } + if _, ok := Proposal_Result_name[int32(p.Result)]; !ok { + return sdkerrors.Wrap(ErrInvalid, "result") + } + if p.ExecutorResult == ProposalExecutorResultInvalid { + return sdkerrors.Wrap(ErrEmpty, "executor result") + } + if _, ok := Proposal_ExecutorResult_name[int32(p.ExecutorResult)]; !ok { + return sdkerrors.Wrap(ErrInvalid, "executor result") + } + if err := p.VoteState.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "vote state") + } + if p.Timeout.Seconds == 0 && p.Timeout.Nanos == 0 { + return sdkerrors.Wrap(ErrEmpty, "timeout") + } + msgs := p.GetMsgs() + for i, msg := range msgs { + if err := msg.ValidateBasic(); err != nil { + return sdkerrors.Wrapf(err, "message %d", i) + } + } + return nil +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (p Proposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + for _, any := range p.Msgs { + var msg sdk.Msg + err := unpacker.UnpackAny(any, &msg) + if err != nil { + return err + } + } + + return nil +} + +func (p Proposal) PrimaryKey() []byte { + return orm.EncodeSequence(p.ProposalId) +} diff --git a/x/group/query.pb.go b/x/group/query.pb.go new file mode 100644 index 0000000000..a6e72cd36f --- /dev/null +++ b/x/group/query.pb.go @@ -0,0 +1,4966 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: regen/group/v1alpha1/query.proto + +package group + +import ( + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/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 + +// QueryGroupInfoRequest is the Query/GroupInfo request type. +type QueryGroupInfoRequest struct { + // group_id is the unique ID of the group. + GroupId uint64 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` +} + +func (m *QueryGroupInfoRequest) Reset() { *m = QueryGroupInfoRequest{} } +func (m *QueryGroupInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGroupInfoRequest) ProtoMessage() {} +func (*QueryGroupInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{0} +} +func (m *QueryGroupInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupInfoRequest.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 *QueryGroupInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupInfoRequest.Merge(m, src) +} +func (m *QueryGroupInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupInfoRequest proto.InternalMessageInfo + +func (m *QueryGroupInfoRequest) GetGroupId() uint64 { + if m != nil { + return m.GroupId + } + return 0 +} + +// QueryGroupInfoResponse is the Query/GroupInfo response type. +type QueryGroupInfoResponse struct { + // info is the GroupInfo for the group. + Info *GroupInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"` +} + +func (m *QueryGroupInfoResponse) Reset() { *m = QueryGroupInfoResponse{} } +func (m *QueryGroupInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGroupInfoResponse) ProtoMessage() {} +func (*QueryGroupInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{1} +} +func (m *QueryGroupInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupInfoResponse.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 *QueryGroupInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupInfoResponse.Merge(m, src) +} +func (m *QueryGroupInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupInfoResponse proto.InternalMessageInfo + +func (m *QueryGroupInfoResponse) GetInfo() *GroupInfo { + if m != nil { + return m.Info + } + return nil +} + +// QueryGroupAccountInfoRequest is the Query/GroupAccountInfo request type. +type QueryGroupAccountInfoRequest struct { + // address is the account address of the group account. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryGroupAccountInfoRequest) Reset() { *m = QueryGroupAccountInfoRequest{} } +func (m *QueryGroupAccountInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGroupAccountInfoRequest) ProtoMessage() {} +func (*QueryGroupAccountInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{2} +} +func (m *QueryGroupAccountInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupAccountInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupAccountInfoRequest.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 *QueryGroupAccountInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupAccountInfoRequest.Merge(m, src) +} +func (m *QueryGroupAccountInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupAccountInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupAccountInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupAccountInfoRequest proto.InternalMessageInfo + +func (m *QueryGroupAccountInfoRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +// QueryGroupAccountInfoResponse is the Query/GroupAccountInfo response type. +type QueryGroupAccountInfoResponse struct { + // info is the GroupAccountInfo for the group account. + Info *GroupAccountInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"` +} + +func (m *QueryGroupAccountInfoResponse) Reset() { *m = QueryGroupAccountInfoResponse{} } +func (m *QueryGroupAccountInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGroupAccountInfoResponse) ProtoMessage() {} +func (*QueryGroupAccountInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{3} +} +func (m *QueryGroupAccountInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupAccountInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupAccountInfoResponse.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 *QueryGroupAccountInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupAccountInfoResponse.Merge(m, src) +} +func (m *QueryGroupAccountInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupAccountInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupAccountInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupAccountInfoResponse proto.InternalMessageInfo + +func (m *QueryGroupAccountInfoResponse) GetInfo() *GroupAccountInfo { + if m != nil { + return m.Info + } + return nil +} + +// QueryGroupMembersRequest is the Query/GroupMembersRequest request type. +type QueryGroupMembersRequest struct { + // group_id is the unique ID of the group. + GroupId uint64 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGroupMembersRequest) Reset() { *m = QueryGroupMembersRequest{} } +func (m *QueryGroupMembersRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGroupMembersRequest) ProtoMessage() {} +func (*QueryGroupMembersRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{4} +} +func (m *QueryGroupMembersRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupMembersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupMembersRequest.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 *QueryGroupMembersRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupMembersRequest.Merge(m, src) +} +func (m *QueryGroupMembersRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupMembersRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupMembersRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupMembersRequest proto.InternalMessageInfo + +func (m *QueryGroupMembersRequest) GetGroupId() uint64 { + if m != nil { + return m.GroupId + } + return 0 +} + +func (m *QueryGroupMembersRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGroupMembersResponse is the Query/GroupMembersResponse response type. +type QueryGroupMembersResponse struct { + // members are the members of the group with given group_id. + Members []*GroupMember `protobuf:"bytes,1,rep,name=members,proto3" json:"members,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGroupMembersResponse) Reset() { *m = QueryGroupMembersResponse{} } +func (m *QueryGroupMembersResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGroupMembersResponse) ProtoMessage() {} +func (*QueryGroupMembersResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{5} +} +func (m *QueryGroupMembersResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupMembersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupMembersResponse.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 *QueryGroupMembersResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupMembersResponse.Merge(m, src) +} +func (m *QueryGroupMembersResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupMembersResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupMembersResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupMembersResponse proto.InternalMessageInfo + +func (m *QueryGroupMembersResponse) GetMembers() []*GroupMember { + if m != nil { + return m.Members + } + return nil +} + +func (m *QueryGroupMembersResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGroupsByAdminRequest is the Query/GroupsByAdminRequest request type. +type QueryGroupsByAdminRequest struct { + // admin is the account address of a group's admin. + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGroupsByAdminRequest) Reset() { *m = QueryGroupsByAdminRequest{} } +func (m *QueryGroupsByAdminRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGroupsByAdminRequest) ProtoMessage() {} +func (*QueryGroupsByAdminRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{6} +} +func (m *QueryGroupsByAdminRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupsByAdminRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupsByAdminRequest.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 *QueryGroupsByAdminRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupsByAdminRequest.Merge(m, src) +} +func (m *QueryGroupsByAdminRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupsByAdminRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupsByAdminRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupsByAdminRequest proto.InternalMessageInfo + +func (m *QueryGroupsByAdminRequest) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func (m *QueryGroupsByAdminRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGroupsByAdminResponse is the Query/GroupsByAdminResponse response type. +type QueryGroupsByAdminResponse struct { + // groups are the groups info with the provided admin. + Groups []*GroupInfo `protobuf:"bytes,1,rep,name=groups,proto3" json:"groups,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGroupsByAdminResponse) Reset() { *m = QueryGroupsByAdminResponse{} } +func (m *QueryGroupsByAdminResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGroupsByAdminResponse) ProtoMessage() {} +func (*QueryGroupsByAdminResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{7} +} +func (m *QueryGroupsByAdminResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupsByAdminResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupsByAdminResponse.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 *QueryGroupsByAdminResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupsByAdminResponse.Merge(m, src) +} +func (m *QueryGroupsByAdminResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupsByAdminResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupsByAdminResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupsByAdminResponse proto.InternalMessageInfo + +func (m *QueryGroupsByAdminResponse) GetGroups() []*GroupInfo { + if m != nil { + return m.Groups + } + return nil +} + +func (m *QueryGroupsByAdminResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGroupAccountsByGroupRequest is the Query/GroupAccountsByGroup request type. +type QueryGroupAccountsByGroupRequest struct { + // group_id is the unique ID of the group account's group. + GroupId uint64 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGroupAccountsByGroupRequest) Reset() { *m = QueryGroupAccountsByGroupRequest{} } +func (m *QueryGroupAccountsByGroupRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGroupAccountsByGroupRequest) ProtoMessage() {} +func (*QueryGroupAccountsByGroupRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{8} +} +func (m *QueryGroupAccountsByGroupRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupAccountsByGroupRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupAccountsByGroupRequest.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 *QueryGroupAccountsByGroupRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupAccountsByGroupRequest.Merge(m, src) +} +func (m *QueryGroupAccountsByGroupRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupAccountsByGroupRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupAccountsByGroupRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupAccountsByGroupRequest proto.InternalMessageInfo + +func (m *QueryGroupAccountsByGroupRequest) GetGroupId() uint64 { + if m != nil { + return m.GroupId + } + return 0 +} + +func (m *QueryGroupAccountsByGroupRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGroupAccountsByGroupResponse is the Query/GroupAccountsByGroup response type. +type QueryGroupAccountsByGroupResponse struct { + // group_accounts are the group accounts info associated with the provided group. + GroupAccounts []*GroupAccountInfo `protobuf:"bytes,1,rep,name=group_accounts,json=groupAccounts,proto3" json:"group_accounts,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGroupAccountsByGroupResponse) Reset() { *m = QueryGroupAccountsByGroupResponse{} } +func (m *QueryGroupAccountsByGroupResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGroupAccountsByGroupResponse) ProtoMessage() {} +func (*QueryGroupAccountsByGroupResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{9} +} +func (m *QueryGroupAccountsByGroupResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupAccountsByGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupAccountsByGroupResponse.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 *QueryGroupAccountsByGroupResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupAccountsByGroupResponse.Merge(m, src) +} +func (m *QueryGroupAccountsByGroupResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupAccountsByGroupResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupAccountsByGroupResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupAccountsByGroupResponse proto.InternalMessageInfo + +func (m *QueryGroupAccountsByGroupResponse) GetGroupAccounts() []*GroupAccountInfo { + if m != nil { + return m.GroupAccounts + } + return nil +} + +func (m *QueryGroupAccountsByGroupResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGroupAccountsByAdminRequest is the Query/GroupAccountsByAdmin request type. +type QueryGroupAccountsByAdminRequest struct { + // admin is the admin address of the group account. + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGroupAccountsByAdminRequest) Reset() { *m = QueryGroupAccountsByAdminRequest{} } +func (m *QueryGroupAccountsByAdminRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGroupAccountsByAdminRequest) ProtoMessage() {} +func (*QueryGroupAccountsByAdminRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{10} +} +func (m *QueryGroupAccountsByAdminRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupAccountsByAdminRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupAccountsByAdminRequest.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 *QueryGroupAccountsByAdminRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupAccountsByAdminRequest.Merge(m, src) +} +func (m *QueryGroupAccountsByAdminRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupAccountsByAdminRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupAccountsByAdminRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupAccountsByAdminRequest proto.InternalMessageInfo + +func (m *QueryGroupAccountsByAdminRequest) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func (m *QueryGroupAccountsByAdminRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGroupAccountsByAdminResponse is the Query/GroupAccountsByAdmin response type. +type QueryGroupAccountsByAdminResponse struct { + // group_accounts are the group accounts info with provided admin. + GroupAccounts []*GroupAccountInfo `protobuf:"bytes,1,rep,name=group_accounts,json=groupAccounts,proto3" json:"group_accounts,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGroupAccountsByAdminResponse) Reset() { *m = QueryGroupAccountsByAdminResponse{} } +func (m *QueryGroupAccountsByAdminResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGroupAccountsByAdminResponse) ProtoMessage() {} +func (*QueryGroupAccountsByAdminResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{11} +} +func (m *QueryGroupAccountsByAdminResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGroupAccountsByAdminResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGroupAccountsByAdminResponse.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 *QueryGroupAccountsByAdminResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGroupAccountsByAdminResponse.Merge(m, src) +} +func (m *QueryGroupAccountsByAdminResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGroupAccountsByAdminResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGroupAccountsByAdminResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGroupAccountsByAdminResponse proto.InternalMessageInfo + +func (m *QueryGroupAccountsByAdminResponse) GetGroupAccounts() []*GroupAccountInfo { + if m != nil { + return m.GroupAccounts + } + return nil +} + +func (m *QueryGroupAccountsByAdminResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryProposalRequest is the Query/Proposal request type. +type QueryProposalRequest struct { + // proposal_id is the unique ID of a proposal. + ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` +} + +func (m *QueryProposalRequest) Reset() { *m = QueryProposalRequest{} } +func (m *QueryProposalRequest) String() string { return proto.CompactTextString(m) } +func (*QueryProposalRequest) ProtoMessage() {} +func (*QueryProposalRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{12} +} +func (m *QueryProposalRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryProposalRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryProposalRequest.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 *QueryProposalRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryProposalRequest.Merge(m, src) +} +func (m *QueryProposalRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryProposalRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryProposalRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryProposalRequest proto.InternalMessageInfo + +func (m *QueryProposalRequest) GetProposalId() uint64 { + if m != nil { + return m.ProposalId + } + return 0 +} + +// QueryProposalResponse is the Query/Proposal response type. +type QueryProposalResponse struct { + // proposal is the proposal info. + Proposal *Proposal `protobuf:"bytes,1,opt,name=proposal,proto3" json:"proposal,omitempty"` +} + +func (m *QueryProposalResponse) Reset() { *m = QueryProposalResponse{} } +func (m *QueryProposalResponse) String() string { return proto.CompactTextString(m) } +func (*QueryProposalResponse) ProtoMessage() {} +func (*QueryProposalResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{13} +} +func (m *QueryProposalResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryProposalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryProposalResponse.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 *QueryProposalResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryProposalResponse.Merge(m, src) +} +func (m *QueryProposalResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryProposalResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryProposalResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryProposalResponse proto.InternalMessageInfo + +func (m *QueryProposalResponse) GetProposal() *Proposal { + if m != nil { + return m.Proposal + } + return nil +} + +// QueryProposalsByGroupAccountRequest is the Query/ProposalByGroupAccount request type. +type QueryProposalsByGroupAccountRequest struct { + // address is the group account address related to proposals. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryProposalsByGroupAccountRequest) Reset() { *m = QueryProposalsByGroupAccountRequest{} } +func (m *QueryProposalsByGroupAccountRequest) String() string { return proto.CompactTextString(m) } +func (*QueryProposalsByGroupAccountRequest) ProtoMessage() {} +func (*QueryProposalsByGroupAccountRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{14} +} +func (m *QueryProposalsByGroupAccountRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryProposalsByGroupAccountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryProposalsByGroupAccountRequest.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 *QueryProposalsByGroupAccountRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryProposalsByGroupAccountRequest.Merge(m, src) +} +func (m *QueryProposalsByGroupAccountRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryProposalsByGroupAccountRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryProposalsByGroupAccountRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryProposalsByGroupAccountRequest proto.InternalMessageInfo + +func (m *QueryProposalsByGroupAccountRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *QueryProposalsByGroupAccountRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryProposalsByGroupAccountResponse is the Query/ProposalByGroupAccount response type. +type QueryProposalsByGroupAccountResponse struct { + // proposals are the proposals with given group account. + Proposals []*Proposal `protobuf:"bytes,1,rep,name=proposals,proto3" json:"proposals,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryProposalsByGroupAccountResponse) Reset() { *m = QueryProposalsByGroupAccountResponse{} } +func (m *QueryProposalsByGroupAccountResponse) String() string { return proto.CompactTextString(m) } +func (*QueryProposalsByGroupAccountResponse) ProtoMessage() {} +func (*QueryProposalsByGroupAccountResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{15} +} +func (m *QueryProposalsByGroupAccountResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryProposalsByGroupAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryProposalsByGroupAccountResponse.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 *QueryProposalsByGroupAccountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryProposalsByGroupAccountResponse.Merge(m, src) +} +func (m *QueryProposalsByGroupAccountResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryProposalsByGroupAccountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryProposalsByGroupAccountResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryProposalsByGroupAccountResponse proto.InternalMessageInfo + +func (m *QueryProposalsByGroupAccountResponse) GetProposals() []*Proposal { + if m != nil { + return m.Proposals + } + return nil +} + +func (m *QueryProposalsByGroupAccountResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryVoteByProposalVoterResponse is the Query/VoteByProposalVoter request type. +type QueryVoteByProposalVoterRequest struct { + // proposal_id is the unique ID of a proposal. + ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` + // voter is a proposal voter account address. + Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"` +} + +func (m *QueryVoteByProposalVoterRequest) Reset() { *m = QueryVoteByProposalVoterRequest{} } +func (m *QueryVoteByProposalVoterRequest) String() string { return proto.CompactTextString(m) } +func (*QueryVoteByProposalVoterRequest) ProtoMessage() {} +func (*QueryVoteByProposalVoterRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{16} +} +func (m *QueryVoteByProposalVoterRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVoteByProposalVoterRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVoteByProposalVoterRequest.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 *QueryVoteByProposalVoterRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVoteByProposalVoterRequest.Merge(m, src) +} +func (m *QueryVoteByProposalVoterRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryVoteByProposalVoterRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVoteByProposalVoterRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryVoteByProposalVoterRequest proto.InternalMessageInfo + +func (m *QueryVoteByProposalVoterRequest) GetProposalId() uint64 { + if m != nil { + return m.ProposalId + } + return 0 +} + +func (m *QueryVoteByProposalVoterRequest) GetVoter() string { + if m != nil { + return m.Voter + } + return "" +} + +// QueryVoteByProposalVoterResponse is the Query/VoteByProposalVoter response type. +type QueryVoteByProposalVoterResponse struct { + // vote is the vote with given proposal_id and voter. + Vote *Vote `protobuf:"bytes,1,opt,name=vote,proto3" json:"vote,omitempty"` +} + +func (m *QueryVoteByProposalVoterResponse) Reset() { *m = QueryVoteByProposalVoterResponse{} } +func (m *QueryVoteByProposalVoterResponse) String() string { return proto.CompactTextString(m) } +func (*QueryVoteByProposalVoterResponse) ProtoMessage() {} +func (*QueryVoteByProposalVoterResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{17} +} +func (m *QueryVoteByProposalVoterResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVoteByProposalVoterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVoteByProposalVoterResponse.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 *QueryVoteByProposalVoterResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVoteByProposalVoterResponse.Merge(m, src) +} +func (m *QueryVoteByProposalVoterResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryVoteByProposalVoterResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVoteByProposalVoterResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryVoteByProposalVoterResponse proto.InternalMessageInfo + +func (m *QueryVoteByProposalVoterResponse) GetVote() *Vote { + if m != nil { + return m.Vote + } + return nil +} + +// QueryVotesByProposalResponse is the Query/VotesByProposal request type. +type QueryVotesByProposalRequest struct { + // proposal_id is the unique ID of a proposal. + ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryVotesByProposalRequest) Reset() { *m = QueryVotesByProposalRequest{} } +func (m *QueryVotesByProposalRequest) String() string { return proto.CompactTextString(m) } +func (*QueryVotesByProposalRequest) ProtoMessage() {} +func (*QueryVotesByProposalRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{18} +} +func (m *QueryVotesByProposalRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVotesByProposalRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVotesByProposalRequest.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 *QueryVotesByProposalRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVotesByProposalRequest.Merge(m, src) +} +func (m *QueryVotesByProposalRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryVotesByProposalRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVotesByProposalRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryVotesByProposalRequest proto.InternalMessageInfo + +func (m *QueryVotesByProposalRequest) GetProposalId() uint64 { + if m != nil { + return m.ProposalId + } + return 0 +} + +func (m *QueryVotesByProposalRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryVotesByProposalResponse is the Query/VotesByProposal response type. +type QueryVotesByProposalResponse struct { + // votes are the list of votes for given proposal_id. + Votes []*Vote `protobuf:"bytes,1,rep,name=votes,proto3" json:"votes,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryVotesByProposalResponse) Reset() { *m = QueryVotesByProposalResponse{} } +func (m *QueryVotesByProposalResponse) String() string { return proto.CompactTextString(m) } +func (*QueryVotesByProposalResponse) ProtoMessage() {} +func (*QueryVotesByProposalResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{19} +} +func (m *QueryVotesByProposalResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVotesByProposalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVotesByProposalResponse.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 *QueryVotesByProposalResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVotesByProposalResponse.Merge(m, src) +} +func (m *QueryVotesByProposalResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryVotesByProposalResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVotesByProposalResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryVotesByProposalResponse proto.InternalMessageInfo + +func (m *QueryVotesByProposalResponse) GetVotes() []*Vote { + if m != nil { + return m.Votes + } + return nil +} + +func (m *QueryVotesByProposalResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryVotesByVoterResponse is the Query/VotesByVoter request type. +type QueryVotesByVoterRequest struct { + // voter is a proposal voter account address. + Voter string `protobuf:"bytes,1,opt,name=voter,proto3" json:"voter,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryVotesByVoterRequest) Reset() { *m = QueryVotesByVoterRequest{} } +func (m *QueryVotesByVoterRequest) String() string { return proto.CompactTextString(m) } +func (*QueryVotesByVoterRequest) ProtoMessage() {} +func (*QueryVotesByVoterRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{20} +} +func (m *QueryVotesByVoterRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVotesByVoterRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVotesByVoterRequest.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 *QueryVotesByVoterRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVotesByVoterRequest.Merge(m, src) +} +func (m *QueryVotesByVoterRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryVotesByVoterRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVotesByVoterRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryVotesByVoterRequest proto.InternalMessageInfo + +func (m *QueryVotesByVoterRequest) GetVoter() string { + if m != nil { + return m.Voter + } + return "" +} + +func (m *QueryVotesByVoterRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryVotesByVoterResponse is the Query/VotesByVoter response type. +type QueryVotesByVoterResponse struct { + // votes are the list of votes by given voter. + Votes []*Vote `protobuf:"bytes,1,rep,name=votes,proto3" json:"votes,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryVotesByVoterResponse) Reset() { *m = QueryVotesByVoterResponse{} } +func (m *QueryVotesByVoterResponse) String() string { return proto.CompactTextString(m) } +func (*QueryVotesByVoterResponse) ProtoMessage() {} +func (*QueryVotesByVoterResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{21} +} +func (m *QueryVotesByVoterResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVotesByVoterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVotesByVoterResponse.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 *QueryVotesByVoterResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVotesByVoterResponse.Merge(m, src) +} +func (m *QueryVotesByVoterResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryVotesByVoterResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVotesByVoterResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryVotesByVoterResponse proto.InternalMessageInfo + +func (m *QueryVotesByVoterResponse) GetVotes() []*Vote { + if m != nil { + return m.Votes + } + return nil +} + +func (m *QueryVotesByVoterResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +func init() { + proto.RegisterType((*QueryGroupInfoRequest)(nil), "regen.group.v1alpha1.QueryGroupInfoRequest") + proto.RegisterType((*QueryGroupInfoResponse)(nil), "regen.group.v1alpha1.QueryGroupInfoResponse") + proto.RegisterType((*QueryGroupAccountInfoRequest)(nil), "regen.group.v1alpha1.QueryGroupAccountInfoRequest") + proto.RegisterType((*QueryGroupAccountInfoResponse)(nil), "regen.group.v1alpha1.QueryGroupAccountInfoResponse") + proto.RegisterType((*QueryGroupMembersRequest)(nil), "regen.group.v1alpha1.QueryGroupMembersRequest") + proto.RegisterType((*QueryGroupMembersResponse)(nil), "regen.group.v1alpha1.QueryGroupMembersResponse") + proto.RegisterType((*QueryGroupsByAdminRequest)(nil), "regen.group.v1alpha1.QueryGroupsByAdminRequest") + proto.RegisterType((*QueryGroupsByAdminResponse)(nil), "regen.group.v1alpha1.QueryGroupsByAdminResponse") + proto.RegisterType((*QueryGroupAccountsByGroupRequest)(nil), "regen.group.v1alpha1.QueryGroupAccountsByGroupRequest") + proto.RegisterType((*QueryGroupAccountsByGroupResponse)(nil), "regen.group.v1alpha1.QueryGroupAccountsByGroupResponse") + proto.RegisterType((*QueryGroupAccountsByAdminRequest)(nil), "regen.group.v1alpha1.QueryGroupAccountsByAdminRequest") + proto.RegisterType((*QueryGroupAccountsByAdminResponse)(nil), "regen.group.v1alpha1.QueryGroupAccountsByAdminResponse") + proto.RegisterType((*QueryProposalRequest)(nil), "regen.group.v1alpha1.QueryProposalRequest") + proto.RegisterType((*QueryProposalResponse)(nil), "regen.group.v1alpha1.QueryProposalResponse") + proto.RegisterType((*QueryProposalsByGroupAccountRequest)(nil), "regen.group.v1alpha1.QueryProposalsByGroupAccountRequest") + proto.RegisterType((*QueryProposalsByGroupAccountResponse)(nil), "regen.group.v1alpha1.QueryProposalsByGroupAccountResponse") + proto.RegisterType((*QueryVoteByProposalVoterRequest)(nil), "regen.group.v1alpha1.QueryVoteByProposalVoterRequest") + proto.RegisterType((*QueryVoteByProposalVoterResponse)(nil), "regen.group.v1alpha1.QueryVoteByProposalVoterResponse") + proto.RegisterType((*QueryVotesByProposalRequest)(nil), "regen.group.v1alpha1.QueryVotesByProposalRequest") + proto.RegisterType((*QueryVotesByProposalResponse)(nil), "regen.group.v1alpha1.QueryVotesByProposalResponse") + proto.RegisterType((*QueryVotesByVoterRequest)(nil), "regen.group.v1alpha1.QueryVotesByVoterRequest") + proto.RegisterType((*QueryVotesByVoterResponse)(nil), "regen.group.v1alpha1.QueryVotesByVoterResponse") +} + +func init() { proto.RegisterFile("regen/group/v1alpha1/query.proto", fileDescriptor_2523b81f3b315123) } + +var fileDescriptor_2523b81f3b315123 = []byte{ + // 904 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcf, 0x6e, 0xf3, 0x44, + 0x10, 0xef, 0x42, 0xff, 0x65, 0x4a, 0x01, 0x99, 0x00, 0xa9, 0x81, 0x34, 0x35, 0x08, 0xaa, 0x96, + 0xda, 0x4d, 0x2a, 0x1a, 0x28, 0x5c, 0x9a, 0x03, 0x55, 0x0f, 0x95, 0x8a, 0x91, 0x10, 0x82, 0x03, + 0x72, 0x92, 0xad, 0x1b, 0xd1, 0x78, 0x5d, 0xdb, 0x29, 0x8d, 0x10, 0x12, 0x07, 0xa0, 0xd7, 0x9e, + 0x90, 0xb8, 0x20, 0xf1, 0x00, 0x3c, 0x01, 0x2f, 0xc0, 0x8d, 0x1e, 0x39, 0xa2, 0xf6, 0x45, 0x90, + 0x77, 0xc7, 0xb1, 0x9d, 0x38, 0xb6, 0xf3, 0xc9, 0xea, 0xf7, 0xdd, 0xb2, 0xd6, 0xfc, 0x66, 0x7e, + 0xf3, 0x9b, 0xdd, 0x99, 0x51, 0xa0, 0xe6, 0x50, 0x93, 0x5a, 0x9a, 0xe9, 0xb0, 0x81, 0xad, 0x5d, + 0xd5, 0x8d, 0x0b, 0xfb, 0xdc, 0xa8, 0x6b, 0x97, 0x03, 0xea, 0x0c, 0x55, 0xdb, 0x61, 0x1e, 0x93, + 0xca, 0xdc, 0x42, 0xe5, 0x16, 0x6a, 0x60, 0x21, 0x27, 0xe3, 0xbc, 0xa1, 0x4d, 0x5d, 0x81, 0x93, + 0xcb, 0x26, 0x33, 0x19, 0xff, 0xa9, 0xf9, 0xbf, 0xf0, 0xeb, 0x56, 0x87, 0xb9, 0x7d, 0xe6, 0x6a, + 0x6d, 0xc3, 0xa5, 0x22, 0x8c, 0x76, 0x55, 0x6f, 0x53, 0xcf, 0xa8, 0x6b, 0xb6, 0x61, 0xf6, 0x2c, + 0xc3, 0xeb, 0x31, 0x4b, 0xd8, 0x2a, 0x0d, 0x78, 0xf5, 0x33, 0xdf, 0xe2, 0xc8, 0x0f, 0x72, 0x6c, + 0x9d, 0x31, 0x9d, 0x5e, 0x0e, 0xa8, 0xeb, 0x49, 0x6b, 0xb0, 0xcc, 0x03, 0x7f, 0xd3, 0xeb, 0x56, + 0x48, 0x8d, 0x6c, 0xce, 0xeb, 0x4b, 0xfc, 0x7c, 0xdc, 0x55, 0x4e, 0xe0, 0xb5, 0x71, 0x8c, 0x6b, + 0x33, 0xcb, 0xa5, 0xd2, 0x1e, 0xcc, 0xf7, 0xac, 0x33, 0xc6, 0x01, 0x2b, 0x8d, 0x75, 0x35, 0x29, + 0x2d, 0x35, 0x84, 0x71, 0x63, 0xe5, 0x43, 0x78, 0x33, 0x74, 0x77, 0xd8, 0xe9, 0xb0, 0x81, 0xe5, + 0x45, 0x99, 0x54, 0x60, 0xc9, 0xe8, 0x76, 0x1d, 0xea, 0xba, 0xdc, 0x6f, 0x49, 0x0f, 0x8e, 0xca, + 0xd7, 0xf0, 0xd6, 0x14, 0x24, 0xf2, 0x39, 0x88, 0xf1, 0x79, 0x37, 0x85, 0x4f, 0x14, 0x2d, 0x68, + 0xfd, 0x00, 0x95, 0xd0, 0xf9, 0x09, 0xed, 0xb7, 0xa9, 0xe3, 0x66, 0x8b, 0x23, 0x7d, 0x0a, 0x10, + 0x8a, 0x5c, 0x79, 0x0e, 0x03, 0x8b, 0x8a, 0xa8, 0x7e, 0x45, 0x54, 0x51, 0x78, 0xac, 0x88, 0x7a, + 0x6a, 0x98, 0x14, 0xdd, 0xea, 0x11, 0xa4, 0xf2, 0x07, 0x81, 0xb5, 0x84, 0xf8, 0x98, 0xd8, 0xc7, + 0xb0, 0xd4, 0x17, 0x9f, 0x2a, 0xa4, 0xf6, 0xfc, 0xe6, 0x4a, 0x63, 0x23, 0x25, 0x37, 0x01, 0xd6, + 0x03, 0x84, 0x74, 0x94, 0x40, 0xf1, 0xbd, 0x4c, 0x8a, 0x22, 0x72, 0x8c, 0xe3, 0x30, 0x4a, 0xd1, + 0x6d, 0x0d, 0x0f, 0xbb, 0xfd, 0x9e, 0x15, 0x68, 0x54, 0x86, 0x05, 0xc3, 0x3f, 0x63, 0xd1, 0xc4, + 0xa1, 0x30, 0x79, 0x7e, 0x27, 0x20, 0x27, 0xc5, 0x46, 0x7d, 0x9a, 0xb0, 0xc8, 0x95, 0x08, 0xe4, + 0xc9, 0xbc, 0x8a, 0x68, 0x5e, 0x9c, 0x36, 0x3f, 0x13, 0xa8, 0x4d, 0x5c, 0x4e, 0xb7, 0x25, 0x8e, + 0x8f, 0x78, 0x8f, 0xfe, 0x22, 0xb0, 0x91, 0xc2, 0x03, 0xf5, 0x3a, 0x81, 0x17, 0x05, 0x11, 0x03, + 0x0d, 0x50, 0xb7, 0xbc, 0x4f, 0x66, 0xd5, 0x8c, 0x7a, 0x2f, 0x4e, 0xc5, 0x1f, 0xa7, 0xa8, 0xf8, + 0x88, 0x37, 0x6d, 0x9a, 0x80, 0xf1, 0x0b, 0xf7, 0xac, 0x0a, 0xd8, 0x84, 0x32, 0x27, 0x7f, 0xea, + 0x30, 0x9b, 0xb9, 0xc6, 0x45, 0xa0, 0xd9, 0x3a, 0xac, 0xd8, 0xf8, 0x29, 0xbc, 0x7c, 0x10, 0x7c, + 0x3a, 0xee, 0x2a, 0x9f, 0xe3, 0x60, 0x08, 0x81, 0xa3, 0x9e, 0xba, 0x1c, 0x98, 0x61, 0x5f, 0xad, + 0x26, 0xe7, 0x38, 0x42, 0x8e, 0xec, 0x95, 0x1b, 0x02, 0x6f, 0xc7, 0xbc, 0x06, 0x17, 0x11, 0x13, + 0xcf, 0x6c, 0xf9, 0x85, 0x55, 0xf5, 0x4f, 0x02, 0xef, 0xa4, 0x33, 0xc1, 0x74, 0x3f, 0x81, 0x52, + 0x40, 0x3f, 0xa8, 0x69, 0x56, 0xbe, 0x21, 0xa0, 0xb8, 0x3a, 0x7e, 0x09, 0xeb, 0x9c, 0xee, 0x17, + 0xcc, 0xa3, 0xad, 0x11, 0x69, 0xff, 0xe4, 0xe4, 0x2d, 0xa9, 0xff, 0x4e, 0xae, 0x7c, 0x00, 0xe7, + 0x51, 0xd2, 0xc5, 0x41, 0xd1, 0xf1, 0x85, 0x25, 0x7a, 0x46, 0x11, 0x54, 0x98, 0xf7, 0x8d, 0xb1, + 0xde, 0x72, 0x72, 0xfe, 0x3e, 0x44, 0xe7, 0x76, 0xca, 0x2f, 0x04, 0xde, 0x18, 0x39, 0x75, 0x5b, + 0x33, 0xdf, 0xbe, 0xc2, 0xca, 0xfc, 0x1b, 0xc1, 0xe5, 0x62, 0x82, 0x08, 0x66, 0xb6, 0x2b, 0x34, + 0x09, 0x4a, 0x9b, 0x96, 0x9a, 0x30, 0x2c, 0xae, 0xa4, 0xd7, 0xb8, 0x60, 0x20, 0xb5, 0x58, 0x2d, + 0x47, 0xa5, 0x22, 0x91, 0x52, 0x15, 0xa6, 0xca, 0xaf, 0xc1, 0x6e, 0x11, 0x0f, 0xfd, 0xd4, 0x25, + 0x69, 0xfc, 0x03, 0xb0, 0xc0, 0x89, 0x49, 0x67, 0x50, 0x1a, 0x0d, 0x67, 0x69, 0x3b, 0x99, 0x42, + 0xe2, 0xe2, 0x2a, 0xbf, 0x9f, 0xcf, 0x18, 0x93, 0xfd, 0x1e, 0x5e, 0x1e, 0xef, 0xc5, 0x52, 0x23, + 0xcb, 0xc3, 0xe4, 0x92, 0x2a, 0xef, 0xcd, 0x84, 0xc1, 0xe0, 0x0c, 0x5e, 0x88, 0x6e, 0x77, 0x92, + 0x9a, 0xe5, 0x24, 0xbe, 0x86, 0xca, 0x5a, 0x6e, 0x7b, 0x0c, 0xe8, 0xc0, 0x6a, 0x6c, 0x5f, 0x92, + 0x32, 0x3d, 0x8c, 0xcd, 0x5a, 0x79, 0x37, 0x3f, 0x00, 0x63, 0xde, 0x10, 0x28, 0x27, 0xed, 0x1e, + 0xd2, 0x7e, 0x4e, 0xc9, 0xc6, 0x96, 0x26, 0xb9, 0x39, 0x33, 0x6e, 0x3a, 0x13, 0xa1, 0xc2, 0x0c, + 0x4c, 0x62, 0x62, 0x34, 0x67, 0xc6, 0x21, 0x93, 0x0e, 0x2c, 0x07, 0x9d, 0x48, 0xda, 0x4a, 0x71, + 0x32, 0xd6, 0x37, 0xe5, 0xed, 0x5c, 0xb6, 0x18, 0xe4, 0x96, 0xc0, 0xeb, 0x53, 0xa6, 0x9b, 0xf4, + 0x51, 0x0e, 0x47, 0xc9, 0xb3, 0x59, 0x3e, 0x78, 0x12, 0x28, 0x52, 0xfa, 0x89, 0xc0, 0x2b, 0x09, + 0x73, 0x46, 0xfa, 0x20, 0xc5, 0xe7, 0xf4, 0x89, 0x27, 0xef, 0xcf, 0x0a, 0x43, 0x1a, 0xd7, 0xf0, + 0xd2, 0xd8, 0x3c, 0x90, 0xea, 0x19, 0xae, 0x26, 0x87, 0x98, 0xdc, 0x98, 0x05, 0x12, 0xbe, 0xf8, + 0x68, 0xcf, 0x4d, 0x7d, 0xf1, 0x09, 0x73, 0x21, 0xf5, 0xc5, 0x27, 0x35, 0xf3, 0xd6, 0xd1, 0xdf, + 0xf7, 0x55, 0x72, 0x77, 0x5f, 0x25, 0xff, 0xdd, 0x57, 0xc9, 0xed, 0x43, 0x75, 0xee, 0xee, 0xa1, + 0x3a, 0xf7, 0xef, 0x43, 0x75, 0xee, 0xab, 0x1d, 0xb3, 0xe7, 0x9d, 0x0f, 0xda, 0x6a, 0x87, 0xf5, + 0x35, 0xee, 0x74, 0xc7, 0xa2, 0xde, 0x77, 0xcc, 0xf9, 0x16, 0x4f, 0x17, 0xb4, 0x6b, 0x52, 0x47, + 0xbb, 0x16, 0xff, 0x3f, 0xb4, 0x17, 0xf9, 0xff, 0x05, 0x7b, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, + 0x50, 0x65, 0x7d, 0x48, 0xcd, 0x10, 0x00, 0x00, +} + +func (m *QueryGroupInfoRequest) 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 *QueryGroupInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.GroupId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryGroupInfoResponse) 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 *QueryGroupInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Info != nil { + { + size, err := m.Info.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 *QueryGroupAccountInfoRequest) 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 *QueryGroupAccountInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupAccountInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGroupAccountInfoResponse) 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 *QueryGroupAccountInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupAccountInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Info != nil { + { + size, err := m.Info.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 *QueryGroupMembersRequest) 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 *QueryGroupMembersRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupMembersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.GroupId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryGroupMembersResponse) 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 *QueryGroupMembersResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupMembersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Members) > 0 { + for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Members[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 (m *QueryGroupsByAdminRequest) 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 *QueryGroupsByAdminRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupsByAdminRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGroupsByAdminResponse) 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 *QueryGroupsByAdminResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupsByAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Groups) > 0 { + for iNdEx := len(m.Groups) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Groups[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 (m *QueryGroupAccountsByGroupRequest) 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 *QueryGroupAccountsByGroupRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupAccountsByGroupRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.GroupId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryGroupAccountsByGroupResponse) 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 *QueryGroupAccountsByGroupResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupAccountsByGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.GroupAccounts) > 0 { + for iNdEx := len(m.GroupAccounts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.GroupAccounts[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 (m *QueryGroupAccountsByAdminRequest) 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 *QueryGroupAccountsByAdminRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupAccountsByAdminRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGroupAccountsByAdminResponse) 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 *QueryGroupAccountsByAdminResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupAccountsByAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.GroupAccounts) > 0 { + for iNdEx := len(m.GroupAccounts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.GroupAccounts[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 (m *QueryProposalRequest) 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 *QueryProposalRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryProposalRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ProposalId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryProposalResponse) 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 *QueryProposalResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Proposal != nil { + { + size, err := m.Proposal.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 *QueryProposalsByGroupAccountRequest) 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 *QueryProposalsByGroupAccountRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryProposalsByGroupAccountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryProposalsByGroupAccountResponse) 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 *QueryProposalsByGroupAccountResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryProposalsByGroupAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Proposals) > 0 { + for iNdEx := len(m.Proposals) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Proposals[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 (m *QueryVoteByProposalVoterRequest) 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 *QueryVoteByProposalVoterRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVoteByProposalVoterRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x12 + } + if m.ProposalId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryVoteByProposalVoterResponse) 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 *QueryVoteByProposalVoterResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVoteByProposalVoterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Vote != nil { + { + size, err := m.Vote.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 *QueryVotesByProposalRequest) 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 *QueryVotesByProposalRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesByProposalRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.ProposalId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryVotesByProposalResponse) 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 *QueryVotesByProposalResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesByProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Votes) > 0 { + for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Votes[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 (m *QueryVotesByVoterRequest) 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 *QueryVotesByVoterRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesByVoterRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryVotesByVoterResponse) 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 *QueryVotesByVoterResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesByVoterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Votes) > 0 { + for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Votes[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 *QueryGroupInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovQuery(uint64(m.GroupId)) + } + return n +} + +func (m *QueryGroupInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Info != nil { + l = m.Info.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupAccountInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupAccountInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Info != nil { + l = m.Info.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupMembersRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovQuery(uint64(m.GroupId)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupMembersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Members) > 0 { + for _, e := range m.Members { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupsByAdminRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupsByAdminResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Groups) > 0 { + for _, e := range m.Groups { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupAccountsByGroupRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovQuery(uint64(m.GroupId)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupAccountsByGroupResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.GroupAccounts) > 0 { + for _, e := range m.GroupAccounts { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupAccountsByAdminRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupAccountsByAdminResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.GroupAccounts) > 0 { + for _, e := range m.GroupAccounts { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryProposalRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovQuery(uint64(m.ProposalId)) + } + return n +} + +func (m *QueryProposalResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Proposal != nil { + l = m.Proposal.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryProposalsByGroupAccountRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryProposalsByGroupAccountResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Proposals) > 0 { + for _, e := range m.Proposals { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVoteByProposalVoterRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovQuery(uint64(m.ProposalId)) + } + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVoteByProposalVoterResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Vote != nil { + l = m.Vote.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVotesByProposalRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovQuery(uint64(m.ProposalId)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVotesByProposalResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Votes) > 0 { + for _, e := range m.Votes { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVotesByVoterRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVotesByVoterResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Votes) > 0 { + for _, e := range m.Votes { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.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 *QueryGroupInfoRequest) 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: QueryGroupInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGroupInfoResponse) 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: QueryGroupInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", 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 m.Info == nil { + m.Info = &GroupInfo{} + } + if err := m.Info.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGroupAccountInfoRequest) 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: QueryGroupAccountInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupAccountInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGroupAccountInfoResponse) 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: QueryGroupAccountInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupAccountInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", 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 m.Info == nil { + m.Info = &GroupAccountInfo{} + } + if err := m.Info.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGroupMembersRequest) 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: QueryGroupMembersRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupMembersRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGroupMembersResponse) 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: QueryGroupMembersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupMembersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Members", 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.Members = append(m.Members, &GroupMember{}) + if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGroupsByAdminRequest) 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: QueryGroupsByAdminRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupsByAdminRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGroupsByAdminResponse) 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: QueryGroupsByAdminResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupsByAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Groups", 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.Groups = append(m.Groups, &GroupInfo{}) + if err := m.Groups[len(m.Groups)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGroupAccountsByGroupRequest) 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: QueryGroupAccountsByGroupRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupAccountsByGroupRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGroupAccountsByGroupResponse) 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: QueryGroupAccountsByGroupResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupAccountsByGroupResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupAccounts", 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.GroupAccounts = append(m.GroupAccounts, &GroupAccountInfo{}) + if err := m.GroupAccounts[len(m.GroupAccounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGroupAccountsByAdminRequest) 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: QueryGroupAccountsByAdminRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupAccountsByAdminRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGroupAccountsByAdminResponse) 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: QueryGroupAccountsByAdminResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupAccountsByAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupAccounts", 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.GroupAccounts = append(m.GroupAccounts, &GroupAccountInfo{}) + if err := m.GroupAccounts[len(m.GroupAccounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryProposalRequest) 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: QueryProposalRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryProposalRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryProposalResponse) 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: QueryProposalResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryProposalResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proposal", 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 m.Proposal == nil { + m.Proposal = &Proposal{} + } + if err := m.Proposal.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryProposalsByGroupAccountRequest) 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: QueryProposalsByGroupAccountRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryProposalsByGroupAccountRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryProposalsByGroupAccountResponse) 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: QueryProposalsByGroupAccountResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryProposalsByGroupAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proposals", 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.Proposals = append(m.Proposals, &Proposal{}) + if err := m.Proposals[len(m.Proposals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryVoteByProposalVoterRequest) 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: QueryVoteByProposalVoterRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryVoteByProposalVoterRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Voter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryVoteByProposalVoterResponse) 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: QueryVoteByProposalVoterResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryVoteByProposalVoterResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Vote", 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 m.Vote == nil { + m.Vote = &Vote{} + } + if err := m.Vote.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryVotesByProposalRequest) 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: QueryVotesByProposalRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryVotesByProposalRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryVotesByProposalResponse) 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: QueryVotesByProposalResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryVotesByProposalResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Votes", 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.Votes = append(m.Votes, &Vote{}) + if err := m.Votes[len(m.Votes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryVotesByVoterRequest) 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: QueryVotesByVoterRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryVotesByVoterRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Voter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryVotesByVoterResponse) 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: QueryVotesByVoterResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryVotesByVoterResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Votes", 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.Votes = append(m.Votes, &Vote{}) + if err := m.Votes[len(m.Votes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 { + return ErrInvalidLengthQuery + } + if (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/group/query_cosmos.pb.go b/x/group/query_cosmos.pb.go new file mode 100644 index 0000000000..6c239210ed --- /dev/null +++ b/x/group/query_cosmos.pb.go @@ -0,0 +1,610 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package group + +import ( + context "context" + types "github.com/regen-network/regen-ledger/types" + grpc "google.golang.org/grpc" +) + +// 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.SupportPackageIsVersion7 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type QueryClient interface { + // GroupInfo queries group info based on group id. + GroupInfo(ctx context.Context, in *QueryGroupInfoRequest, opts ...grpc.CallOption) (*QueryGroupInfoResponse, error) + // GroupAccountInfo queries group account info based on group account address. + GroupAccountInfo(ctx context.Context, in *QueryGroupAccountInfoRequest, opts ...grpc.CallOption) (*QueryGroupAccountInfoResponse, error) + // GroupMembers queries members of a group + GroupMembers(ctx context.Context, in *QueryGroupMembersRequest, opts ...grpc.CallOption) (*QueryGroupMembersResponse, error) + // GroupsByAdmin queries groups by admin address. + GroupsByAdmin(ctx context.Context, in *QueryGroupsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupsByAdminResponse, error) + // GroupAccountsByGroup queries group accounts by group id. + GroupAccountsByGroup(ctx context.Context, in *QueryGroupAccountsByGroupRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByGroupResponse, error) + // GroupsByAdmin queries group accounts by admin address. + GroupAccountsByAdmin(ctx context.Context, in *QueryGroupAccountsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByAdminResponse, error) + // Proposal queries a proposal based on proposal id. + Proposal(ctx context.Context, in *QueryProposalRequest, opts ...grpc.CallOption) (*QueryProposalResponse, error) + // ProposalsByGroupAccount queries proposals based on group account address. + ProposalsByGroupAccount(ctx context.Context, in *QueryProposalsByGroupAccountRequest, opts ...grpc.CallOption) (*QueryProposalsByGroupAccountResponse, error) + // VoteByProposalVoter queries a vote by proposal id and voter. + VoteByProposalVoter(ctx context.Context, in *QueryVoteByProposalVoterRequest, opts ...grpc.CallOption) (*QueryVoteByProposalVoterResponse, error) + // VotesByProposal queries a vote by proposal. + VotesByProposal(ctx context.Context, in *QueryVotesByProposalRequest, opts ...grpc.CallOption) (*QueryVotesByProposalResponse, error) + // VotesByVoter queries a vote by voter. + VotesByVoter(ctx context.Context, in *QueryVotesByVoterRequest, opts ...grpc.CallOption) (*QueryVotesByVoterResponse, error) +} + +type queryClient struct { + cc grpc.ClientConnInterface + _GroupInfo types.Invoker + _GroupAccountInfo types.Invoker + _GroupMembers types.Invoker + _GroupsByAdmin types.Invoker + _GroupAccountsByGroup types.Invoker + _GroupAccountsByAdmin types.Invoker + _Proposal types.Invoker + _ProposalsByGroupAccount types.Invoker + _VoteByProposalVoter types.Invoker + _VotesByProposal types.Invoker + _VotesByVoter types.Invoker +} + +func NewQueryClient(cc grpc.ClientConnInterface) QueryClient { + return &queryClient{cc: cc} +} + +func (c *queryClient) GroupInfo(ctx context.Context, in *QueryGroupInfoRequest, opts ...grpc.CallOption) (*QueryGroupInfoResponse, error) { + if invoker := c._GroupInfo; invoker != nil { + var out QueryGroupInfoResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._GroupInfo, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/GroupInfo") + if err != nil { + var out QueryGroupInfoResponse + err = c._GroupInfo(ctx, in, &out) + return &out, err + } + } + out := new(QueryGroupInfoResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GroupAccountInfo(ctx context.Context, in *QueryGroupAccountInfoRequest, opts ...grpc.CallOption) (*QueryGroupAccountInfoResponse, error) { + if invoker := c._GroupAccountInfo; invoker != nil { + var out QueryGroupAccountInfoResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._GroupAccountInfo, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/GroupAccountInfo") + if err != nil { + var out QueryGroupAccountInfoResponse + err = c._GroupAccountInfo(ctx, in, &out) + return &out, err + } + } + out := new(QueryGroupAccountInfoResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupAccountInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GroupMembers(ctx context.Context, in *QueryGroupMembersRequest, opts ...grpc.CallOption) (*QueryGroupMembersResponse, error) { + if invoker := c._GroupMembers; invoker != nil { + var out QueryGroupMembersResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._GroupMembers, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/GroupMembers") + if err != nil { + var out QueryGroupMembersResponse + err = c._GroupMembers(ctx, in, &out) + return &out, err + } + } + out := new(QueryGroupMembersResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupMembers", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GroupsByAdmin(ctx context.Context, in *QueryGroupsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupsByAdminResponse, error) { + if invoker := c._GroupsByAdmin; invoker != nil { + var out QueryGroupsByAdminResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._GroupsByAdmin, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/GroupsByAdmin") + if err != nil { + var out QueryGroupsByAdminResponse + err = c._GroupsByAdmin(ctx, in, &out) + return &out, err + } + } + out := new(QueryGroupsByAdminResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupsByAdmin", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GroupAccountsByGroup(ctx context.Context, in *QueryGroupAccountsByGroupRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByGroupResponse, error) { + if invoker := c._GroupAccountsByGroup; invoker != nil { + var out QueryGroupAccountsByGroupResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._GroupAccountsByGroup, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/GroupAccountsByGroup") + if err != nil { + var out QueryGroupAccountsByGroupResponse + err = c._GroupAccountsByGroup(ctx, in, &out) + return &out, err + } + } + out := new(QueryGroupAccountsByGroupResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupAccountsByGroup", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GroupAccountsByAdmin(ctx context.Context, in *QueryGroupAccountsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByAdminResponse, error) { + if invoker := c._GroupAccountsByAdmin; invoker != nil { + var out QueryGroupAccountsByAdminResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._GroupAccountsByAdmin, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/GroupAccountsByAdmin") + if err != nil { + var out QueryGroupAccountsByAdminResponse + err = c._GroupAccountsByAdmin(ctx, in, &out) + return &out, err + } + } + out := new(QueryGroupAccountsByAdminResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupAccountsByAdmin", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Proposal(ctx context.Context, in *QueryProposalRequest, opts ...grpc.CallOption) (*QueryProposalResponse, error) { + if invoker := c._Proposal; invoker != nil { + var out QueryProposalResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._Proposal, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/Proposal") + if err != nil { + var out QueryProposalResponse + err = c._Proposal(ctx, in, &out) + return &out, err + } + } + out := new(QueryProposalResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/Proposal", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ProposalsByGroupAccount(ctx context.Context, in *QueryProposalsByGroupAccountRequest, opts ...grpc.CallOption) (*QueryProposalsByGroupAccountResponse, error) { + if invoker := c._ProposalsByGroupAccount; invoker != nil { + var out QueryProposalsByGroupAccountResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._ProposalsByGroupAccount, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/ProposalsByGroupAccount") + if err != nil { + var out QueryProposalsByGroupAccountResponse + err = c._ProposalsByGroupAccount(ctx, in, &out) + return &out, err + } + } + out := new(QueryProposalsByGroupAccountResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/ProposalsByGroupAccount", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) VoteByProposalVoter(ctx context.Context, in *QueryVoteByProposalVoterRequest, opts ...grpc.CallOption) (*QueryVoteByProposalVoterResponse, error) { + if invoker := c._VoteByProposalVoter; invoker != nil { + var out QueryVoteByProposalVoterResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._VoteByProposalVoter, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/VoteByProposalVoter") + if err != nil { + var out QueryVoteByProposalVoterResponse + err = c._VoteByProposalVoter(ctx, in, &out) + return &out, err + } + } + out := new(QueryVoteByProposalVoterResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VoteByProposalVoter", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) VotesByProposal(ctx context.Context, in *QueryVotesByProposalRequest, opts ...grpc.CallOption) (*QueryVotesByProposalResponse, error) { + if invoker := c._VotesByProposal; invoker != nil { + var out QueryVotesByProposalResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._VotesByProposal, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/VotesByProposal") + if err != nil { + var out QueryVotesByProposalResponse + err = c._VotesByProposal(ctx, in, &out) + return &out, err + } + } + out := new(QueryVotesByProposalResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VotesByProposal", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) VotesByVoter(ctx context.Context, in *QueryVotesByVoterRequest, opts ...grpc.CallOption) (*QueryVotesByVoterResponse, error) { + if invoker := c._VotesByVoter; invoker != nil { + var out QueryVotesByVoterResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._VotesByVoter, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/VotesByVoter") + if err != nil { + var out QueryVotesByVoterResponse + err = c._VotesByVoter(ctx, in, &out) + return &out, err + } + } + out := new(QueryVotesByVoterResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VotesByVoter", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // GroupInfo queries group info based on group id. + GroupInfo(types.Context, *QueryGroupInfoRequest) (*QueryGroupInfoResponse, error) + // GroupAccountInfo queries group account info based on group account address. + GroupAccountInfo(types.Context, *QueryGroupAccountInfoRequest) (*QueryGroupAccountInfoResponse, error) + // GroupMembers queries members of a group + GroupMembers(types.Context, *QueryGroupMembersRequest) (*QueryGroupMembersResponse, error) + // GroupsByAdmin queries groups by admin address. + GroupsByAdmin(types.Context, *QueryGroupsByAdminRequest) (*QueryGroupsByAdminResponse, error) + // GroupAccountsByGroup queries group accounts by group id. + GroupAccountsByGroup(types.Context, *QueryGroupAccountsByGroupRequest) (*QueryGroupAccountsByGroupResponse, error) + // GroupsByAdmin queries group accounts by admin address. + GroupAccountsByAdmin(types.Context, *QueryGroupAccountsByAdminRequest) (*QueryGroupAccountsByAdminResponse, error) + // Proposal queries a proposal based on proposal id. + Proposal(types.Context, *QueryProposalRequest) (*QueryProposalResponse, error) + // ProposalsByGroupAccount queries proposals based on group account address. + ProposalsByGroupAccount(types.Context, *QueryProposalsByGroupAccountRequest) (*QueryProposalsByGroupAccountResponse, error) + // VoteByProposalVoter queries a vote by proposal id and voter. + VoteByProposalVoter(types.Context, *QueryVoteByProposalVoterRequest) (*QueryVoteByProposalVoterResponse, error) + // VotesByProposal queries a vote by proposal. + VotesByProposal(types.Context, *QueryVotesByProposalRequest) (*QueryVotesByProposalResponse, error) + // VotesByVoter queries a vote by voter. + VotesByVoter(types.Context, *QueryVotesByVoterRequest) (*QueryVotesByVoterResponse, error) +} + +func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) { + s.RegisterService(&Query_ServiceDesc, srv) +} + +func _Query_GroupInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GroupInfo(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/GroupInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GroupInfo(types.UnwrapSDKContext(ctx), req.(*QueryGroupInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GroupAccountInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupAccountInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GroupAccountInfo(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/GroupAccountInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GroupAccountInfo(types.UnwrapSDKContext(ctx), req.(*QueryGroupAccountInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GroupMembers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupMembersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GroupMembers(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/GroupMembers", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GroupMembers(types.UnwrapSDKContext(ctx), req.(*QueryGroupMembersRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GroupsByAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupsByAdminRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GroupsByAdmin(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/GroupsByAdmin", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GroupsByAdmin(types.UnwrapSDKContext(ctx), req.(*QueryGroupsByAdminRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GroupAccountsByGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupAccountsByGroupRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GroupAccountsByGroup(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/GroupAccountsByGroup", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GroupAccountsByGroup(types.UnwrapSDKContext(ctx), req.(*QueryGroupAccountsByGroupRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GroupAccountsByAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupAccountsByAdminRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GroupAccountsByAdmin(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/GroupAccountsByAdmin", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GroupAccountsByAdmin(types.UnwrapSDKContext(ctx), req.(*QueryGroupAccountsByAdminRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Proposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryProposalRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Proposal(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/Proposal", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Proposal(types.UnwrapSDKContext(ctx), req.(*QueryProposalRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ProposalsByGroupAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryProposalsByGroupAccountRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ProposalsByGroupAccount(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/ProposalsByGroupAccount", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ProposalsByGroupAccount(types.UnwrapSDKContext(ctx), req.(*QueryProposalsByGroupAccountRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_VoteByProposalVoter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryVoteByProposalVoterRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).VoteByProposalVoter(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/VoteByProposalVoter", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).VoteByProposalVoter(types.UnwrapSDKContext(ctx), req.(*QueryVoteByProposalVoterRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_VotesByProposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryVotesByProposalRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).VotesByProposal(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/VotesByProposal", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).VotesByProposal(types.UnwrapSDKContext(ctx), req.(*QueryVotesByProposalRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_VotesByVoter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryVotesByVoterRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).VotesByVoter(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/VotesByVoter", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).VotesByVoter(types.UnwrapSDKContext(ctx), req.(*QueryVotesByVoterRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Query_ServiceDesc is the grpc.ServiceDesc for Query service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Query_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "regen.group.v1alpha1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GroupInfo", + Handler: _Query_GroupInfo_Handler, + }, + { + MethodName: "GroupAccountInfo", + Handler: _Query_GroupAccountInfo_Handler, + }, + { + MethodName: "GroupMembers", + Handler: _Query_GroupMembers_Handler, + }, + { + MethodName: "GroupsByAdmin", + Handler: _Query_GroupsByAdmin_Handler, + }, + { + MethodName: "GroupAccountsByGroup", + Handler: _Query_GroupAccountsByGroup_Handler, + }, + { + MethodName: "GroupAccountsByAdmin", + Handler: _Query_GroupAccountsByAdmin_Handler, + }, + { + MethodName: "Proposal", + Handler: _Query_Proposal_Handler, + }, + { + MethodName: "ProposalsByGroupAccount", + Handler: _Query_ProposalsByGroupAccount_Handler, + }, + { + MethodName: "VoteByProposalVoter", + Handler: _Query_VoteByProposalVoter_Handler, + }, + { + MethodName: "VotesByProposal", + Handler: _Query_VotesByProposal_Handler, + }, + { + MethodName: "VotesByVoter", + Handler: _Query_VotesByVoter_Handler, + }, + }, + Metadata: "regen/group/v1alpha1/query.proto", +} + +const ( + QueryGroupInfoMethod = "/regen.group.v1alpha1.Query/GroupInfo" + QueryGroupAccountInfoMethod = "/regen.group.v1alpha1.Query/GroupAccountInfo" + QueryGroupMembersMethod = "/regen.group.v1alpha1.Query/GroupMembers" + QueryGroupsByAdminMethod = "/regen.group.v1alpha1.Query/GroupsByAdmin" + QueryGroupAccountsByGroupMethod = "/regen.group.v1alpha1.Query/GroupAccountsByGroup" + QueryGroupAccountsByAdminMethod = "/regen.group.v1alpha1.Query/GroupAccountsByAdmin" + QueryProposalMethod = "/regen.group.v1alpha1.Query/Proposal" + QueryProposalsByGroupAccountMethod = "/regen.group.v1alpha1.Query/ProposalsByGroupAccount" + QueryVoteByProposalVoterMethod = "/regen.group.v1alpha1.Query/VoteByProposalVoter" + QueryVotesByProposalMethod = "/regen.group.v1alpha1.Query/VotesByProposal" + QueryVotesByVoterMethod = "/regen.group.v1alpha1.Query/VotesByVoter" +) diff --git a/x/group/server/expected_keepers.go b/x/group/server/expected_keepers.go new file mode 100644 index 0000000000..83c583b6e9 --- /dev/null +++ b/x/group/server/expected_keepers.go @@ -0,0 +1,17 @@ +package server + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +type AccountKeeper interface { + // Return a new account with the next account number. Does not save the new account to the store. + NewAccount(sdk.Context, types.AccountI) types.AccountI + + // Retrieve an account from the store. + GetAccount(sdk.Context, sdk.AccAddress) types.AccountI + + // Set an account in the store. + SetAccount(sdk.Context, types.AccountI) +} diff --git a/x/group/server/genesis.go b/x/group/server/genesis.go new file mode 100644 index 0000000000..8df0f2f2ca --- /dev/null +++ b/x/group/server/genesis.go @@ -0,0 +1,91 @@ +package server + +import ( + "encoding/json" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/errors" + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/regen-network/regen-ledger/orm" + "github.com/regen-network/regen-ledger/types" + "github.com/regen-network/regen-ledger/x/group" +) + +func (s serverImpl) InitGenesis(ctx types.Context, cdc codec.JSONMarshaler, data json.RawMessage) ([]abci.ValidatorUpdate, error) { + var genesisState group.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + + if err := orm.ImportTableData(ctx, s.groupTable, genesisState.Groups, 0); err != nil { + return nil, errors.Wrap(err, "groups") + } + if err := s.groupSeq.InitVal(ctx, genesisState.GroupSeq); err != nil { + return nil, errors.Wrap(err, "group seq") + } + + if err := orm.ImportTableData(ctx, s.groupMemberTable, genesisState.GroupMembers, 0); err != nil { + return nil, errors.Wrap(err, "group members") + } + + if err := orm.ImportTableData(ctx, s.groupAccountTable, genesisState.GroupAccounts, 0); err != nil { + return nil, errors.Wrap(err, "group accounts") + } + if err := s.groupAccountSeq.InitVal(ctx, genesisState.GroupAccountSeq); err != nil { + return nil, errors.Wrap(err, "group account seq") + } + + if err := orm.ImportTableData(ctx, s.proposalTable, genesisState.Proposals, genesisState.ProposalSeq); err != nil { + return nil, errors.Wrap(err, "proposals") + } + + if err := orm.ImportTableData(ctx, s.voteTable, genesisState.Votes, 0); err != nil { + return nil, errors.Wrap(err, "votes") + } + + return []abci.ValidatorUpdate{}, nil +} + +func (s serverImpl) ExportGenesis(ctx types.Context, cdc codec.JSONMarshaler) (json.RawMessage, error) { + genesisState := group.NewGenesisState() + + var groups []*group.GroupInfo + _, err := orm.ExportTableData(ctx, s.groupTable, &groups) + if err != nil { + return nil, errors.Wrap(err, "groups") + } + genesisState.Groups = groups + genesisState.GroupSeq = s.groupSeq.CurVal(ctx) + + var groupMembers []*group.GroupMember + _, err = orm.ExportTableData(ctx, s.groupMemberTable, &groupMembers) + if err != nil { + return nil, errors.Wrap(err, "group members") + } + genesisState.GroupMembers = groupMembers + + var groupAccounts []*group.GroupAccountInfo + _, err = orm.ExportTableData(ctx, s.groupAccountTable, &groupAccounts) + if err != nil { + return nil, errors.Wrap(err, "group accounts") + } + genesisState.GroupAccounts = groupAccounts + genesisState.GroupAccountSeq = s.groupAccountSeq.CurVal(ctx) + + var proposals []*group.Proposal + proposalSeq, err := orm.ExportTableData(ctx, s.proposalTable, &proposals) + if err != nil { + return nil, errors.Wrap(err, "proposals") + } + genesisState.Proposals = proposals + genesisState.ProposalSeq = proposalSeq + + var votes []*group.Vote + _, err = orm.ExportTableData(ctx, s.voteTable, &votes) + if err != nil { + return nil, errors.Wrap(err, "votes") + } + genesisState.Votes = votes + + genesisBytes := cdc.MustMarshalJSON(genesisState) + return genesisBytes, nil +} diff --git a/x/group/server/handler.go b/x/group/server/handler.go new file mode 100644 index 0000000000..a63f46dfad --- /dev/null +++ b/x/group/server/handler.go @@ -0,0 +1,69 @@ +package server + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/regen-network/regen-ledger/types" + servermodule "github.com/regen-network/regen-ledger/types/module/server" + "github.com/regen-network/regen-ledger/x/group" +) + +// NewHandler creates an sdk.Handler for all the group type messages. +// This is needed for supporting amino-json signing. +func NewHandler(configurator servermodule.Configurator, accountKeeper AccountKeeper) sdk.Handler { + impl := newServer(configurator.ModuleKey(), configurator.Router(), accountKeeper, configurator.Marshaler()) + + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + regenCtx := types.Context{Context: ctx} + + switch msg := msg.(type) { + case *group.MsgCreateGroupRequest: + res, err := impl.CreateGroup(regenCtx, msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *group.MsgUpdateGroupMembersRequest: + res, err := impl.UpdateGroupMembers(regenCtx, msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *group.MsgUpdateGroupAdminRequest: + res, err := impl.UpdateGroupAdmin(regenCtx, msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *group.MsgUpdateGroupMetadataRequest: + res, err := impl.UpdateGroupMetadata(regenCtx, msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *group.MsgCreateGroupAccountRequest: + res, err := impl.CreateGroupAccount(regenCtx, msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *group.MsgUpdateGroupAccountAdminRequest: + res, err := impl.UpdateGroupAccountAdmin(regenCtx, msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *group.MsgUpdateGroupAccountDecisionPolicyRequest: + res, err := impl.UpdateGroupAccountDecisionPolicy(regenCtx, msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *group.MsgUpdateGroupAccountMetadataRequest: + res, err := impl.UpdateGroupAccountMetadata(regenCtx, msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *group.MsgCreateProposalRequest: + res, err := impl.CreateProposal(regenCtx, msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *group.MsgVoteRequest: + res, err := impl.Vote(regenCtx, msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *group.MsgExecRequest: + res, err := impl.Exec(regenCtx, msg) + return sdk.WrapServiceResult(ctx, res, err) + + default: + return nil, errors.Wrapf(errors.ErrUnknownRequest, "unrecognized %s message type: %T", group.ModuleName, msg) + } + } +} diff --git a/x/group/server/msg_server.go b/x/group/server/msg_server.go new file mode 100644 index 0000000000..eb1c53ed82 --- /dev/null +++ b/x/group/server/msg_server.go @@ -0,0 +1,753 @@ +package server + +import ( + "bytes" + "encoding/binary" + "fmt" + "reflect" + + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + + "github.com/cockroachdb/apd/v2" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + gogotypes "github.com/gogo/protobuf/types" + "github.com/regen-network/regen-ledger/math" + "github.com/regen-network/regen-ledger/orm" + "github.com/regen-network/regen-ledger/types" + "github.com/regen-network/regen-ledger/x/group" +) + +func (s serverImpl) CreateGroup(ctx types.Context, req *group.MsgCreateGroupRequest) (*group.MsgCreateGroupResponse, error) { + metadata := req.Metadata + members := group.Members{Members: req.Members} + admin := req.Admin + + if err := members.ValidateBasic(); err != nil { + return nil, err + } + + if err := assertMetadataLength(metadata, "group metadata"); err != nil { + return nil, err + } + + totalWeight := apd.New(0, 0) + for i := range members.Members { + m := members.Members[i] + if err := assertMetadataLength(m.Metadata, "member metadata"); err != nil { + return nil, err + } + + // Members of a group must have a positive weight. + weight, err := math.ParsePositiveDecimal(m.Weight) + if err != nil { + return nil, err + } + + // Adding up members weights to compute group total weight. + err = math.Add(totalWeight, totalWeight, weight) + if err != nil { + return nil, err + } + } + + // Create a new group in the groupTable. + groupID := s.groupSeq.NextVal(ctx) + err := s.groupTable.Create(ctx, group.ID(groupID).Bytes(), &group.GroupInfo{ + GroupId: groupID, + Admin: admin, + Metadata: metadata, + Version: 1, + TotalWeight: math.DecimalString(totalWeight), + }) + if err != nil { + return nil, sdkerrors.Wrap(err, "could not create group") + } + + // Create new group members in the groupMemberTable. + for i := range members.Members { + m := members.Members[i] + err := s.groupMemberTable.Create(ctx, &group.GroupMember{ + GroupId: groupID, + Member: &group.Member{ + Address: m.Address, + Weight: m.Weight, + Metadata: m.Metadata, + }, + }) + if err != nil { + return nil, sdkerrors.Wrapf(err, "could not store member %d", i) + } + } + + err = ctx.EventManager().EmitTypedEvent(&group.EventCreateGroup{GroupId: groupID}) + if err != nil { + return nil, err + } + + return &group.MsgCreateGroupResponse{GroupId: groupID}, nil +} + +func (s serverImpl) UpdateGroupMembers(ctx types.Context, req *group.MsgUpdateGroupMembersRequest) (*group.MsgUpdateGroupMembersResponse, error) { + action := func(g *group.GroupInfo) error { + totalWeight, err := math.ParseNonNegativeDecimal(g.TotalWeight) + if err != nil { + return err + } + for i := range req.MemberUpdates { + if err := assertMetadataLength(req.MemberUpdates[i].Metadata, "group member metadata"); err != nil { + return err + } + groupMember := group.GroupMember{GroupId: req.GroupId, + Member: &group.Member{ + Address: req.MemberUpdates[i].Address, + Weight: req.MemberUpdates[i].Weight, + Metadata: req.MemberUpdates[i].Metadata, + }, + } + + // Checking if the group member is already part of the group. + var found bool + var prevGroupMember group.GroupMember + switch err := s.groupMemberTable.GetOne(ctx, groupMember.PrimaryKey(), &prevGroupMember); { + case err == nil: + found = true + case orm.ErrNotFound.Is(err): + found = false + default: + return sdkerrors.Wrap(err, "get group member") + } + + newMemberWeight, err := math.ParseNonNegativeDecimal(groupMember.Member.Weight) + if err != nil { + return err + } + + // Handle delete for members with zero weight. + if newMemberWeight.IsZero() { + // We can't delete a group member that doesn't already exist. + if !found { + return sdkerrors.Wrap(orm.ErrNotFound, "unknown member") + } + + previousMemberWeight, err := math.ParseNonNegativeDecimal(prevGroupMember.Member.Weight) + if err != nil { + return err + } + + // Subtract the weight of the group member to delete from the group total weight. + err = math.SafeSub(totalWeight, totalWeight, previousMemberWeight) + if err != nil { + return err + } + + // Delete group member in the groupMemberTable. + if err := s.groupMemberTable.Delete(ctx, &groupMember); err != nil { + return sdkerrors.Wrap(err, "delete member") + } + continue + } + // If group member already exists, handle update + if found { + previousMemberWeight, err := math.ParseNonNegativeDecimal(prevGroupMember.Member.Weight) + if err != nil { + return err + } + // Subtract previous weight from the group total weight. + err = math.SafeSub(totalWeight, totalWeight, previousMemberWeight) + if err != nil { + return err + } + // Save updated group member in the groupMemberTable. + if err := s.groupMemberTable.Save(ctx, &groupMember); err != nil { + return sdkerrors.Wrap(err, "add member") + } + // else handle create. + } else if err := s.groupMemberTable.Create(ctx, &groupMember); err != nil { + return sdkerrors.Wrap(err, "add member") + } + // In both cases (handle + update), we need to add the new member's weight to the group total weight. + err = math.Add(totalWeight, totalWeight, newMemberWeight) + if err != nil { + return err + } + } + // Update group in the groupTable. + g.TotalWeight = math.DecimalString(totalWeight) + g.Version++ + groupID := group.ID(g.GroupId).Bytes() + return s.groupTable.Save(ctx, groupID, g) + } + + err := s.doUpdateGroup(ctx, req, action, "members updated") + if err != nil { + return nil, err + } + + return &group.MsgUpdateGroupMembersResponse{}, nil +} + +func (s serverImpl) UpdateGroupAdmin(ctx types.Context, req *group.MsgUpdateGroupAdminRequest) (*group.MsgUpdateGroupAdminResponse, error) { + action := func(g *group.GroupInfo) error { + g.Admin = req.NewAdmin + g.Version++ + + groupID := group.ID(g.GroupId).Bytes() + return s.groupTable.Save(ctx, groupID, g) + } + + err := s.doUpdateGroup(ctx, req, action, "admin updated") + if err != nil { + return nil, err + } + + return &group.MsgUpdateGroupAdminResponse{}, nil +} + +func (s serverImpl) UpdateGroupMetadata(ctx types.Context, req *group.MsgUpdateGroupMetadataRequest) (*group.MsgUpdateGroupMetadataResponse, error) { + action := func(g *group.GroupInfo) error { + g.Metadata = req.Metadata + g.Version++ + groupID := group.ID(g.GroupId).Bytes() + return s.groupTable.Save(ctx, groupID, g) + } + + if err := assertMetadataLength(req.Metadata, "group metadata"); err != nil { + return nil, err + } + + err := s.doUpdateGroup(ctx, req, action, "metadata updated") + if err != nil { + return nil, err + } + + return &group.MsgUpdateGroupMetadataResponse{}, nil +} + +func (s serverImpl) CreateGroupAccount(ctx types.Context, req *group.MsgCreateGroupAccountRequest) (*group.MsgCreateGroupAccountResponse, error) { + admin, err := sdk.AccAddressFromBech32(req.GetAdmin()) + if err != nil { + return nil, sdkerrors.Wrap(err, "request admin") + } + policy := req.GetDecisionPolicy() + groupID := req.GetGroupID() + metadata := req.GetMetadata() + + if err := assertMetadataLength(metadata, "group account metadata"); err != nil { + return nil, err + } + + g, err := s.getGroupInfo(ctx, groupID) + if err != nil { + return nil, err + } + groupAdmin, err := sdk.AccAddressFromBech32(g.Admin) + if err != nil { + return nil, sdkerrors.Wrap(err, "group admin") + } + // Only current group admin is authorized to create a group account for this group. + if !groupAdmin.Equals(admin) { + return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "not group admin") + } + + // Generate group account address. + var accountAddr sdk.AccAddress + // loop here in the rare case of a collision + for { + nextAccVal := s.groupAccountSeq.NextVal(ctx) + buf := bytes.NewBuffer(nil) + err = binary.Write(buf, binary.LittleEndian, nextAccVal) + if err != nil { + return nil, err + } + + accountID := s.key.Derive(buf.Bytes()) + accountAddr = accountID.Address() + + if s.accKeeper.GetAccount(ctx.Context, accountAddr) != nil { + // handle a rare collision + continue + } + + acc := s.accKeeper.NewAccount(ctx.Context, &authtypes.ModuleAccount{ + BaseAccount: &authtypes.BaseAccount{ + Address: accountAddr.String(), + }, + Name: accountAddr.String(), + }) + s.accKeeper.SetAccount(ctx.Context, acc) + + break + } + + groupAccount, err := group.NewGroupAccountInfo( + accountAddr, + groupID, + admin, + metadata, + 1, + policy, + ) + if err != nil { + return nil, err + } + + if err := s.groupAccountTable.Create(ctx, &groupAccount); err != nil { + return nil, sdkerrors.Wrap(err, "could not create group account") + } + + err = ctx.EventManager().EmitTypedEvent(&group.EventCreateGroupAccount{Address: accountAddr.String()}) + if err != nil { + return nil, err + } + + return &group.MsgCreateGroupAccountResponse{Address: accountAddr.String()}, nil +} + +func (s serverImpl) UpdateGroupAccountAdmin(ctx types.Context, req *group.MsgUpdateGroupAccountAdminRequest) (*group.MsgUpdateGroupAccountAdminResponse, error) { + action := func(groupAccount *group.GroupAccountInfo) error { + groupAccount.Admin = req.NewAdmin + groupAccount.Version++ + return s.groupAccountTable.Save(ctx, groupAccount) + } + + err := s.doUpdateGroupAccount(ctx, req.Address, req.Admin, action, "group account admin updated") + if err != nil { + return nil, err + } + + return &group.MsgUpdateGroupAccountAdminResponse{}, nil +} + +func (s serverImpl) UpdateGroupAccountDecisionPolicy(ctx types.Context, req *group.MsgUpdateGroupAccountDecisionPolicyRequest) (*group.MsgUpdateGroupAccountDecisionPolicyResponse, error) { + policy := req.GetDecisionPolicy() + + action := func(groupAccount *group.GroupAccountInfo) error { + err := groupAccount.SetDecisionPolicy(policy) + if err != nil { + return err + } + + groupAccount.Version++ + return s.groupAccountTable.Save(ctx, groupAccount) + } + + err := s.doUpdateGroupAccount(ctx, req.Address, req.Admin, action, "group account decision policy updated") + if err != nil { + return nil, err + } + + return &group.MsgUpdateGroupAccountDecisionPolicyResponse{}, nil +} + +func (s serverImpl) UpdateGroupAccountMetadata(ctx types.Context, req *group.MsgUpdateGroupAccountMetadataRequest) (*group.MsgUpdateGroupAccountMetadataResponse, error) { + metadata := req.GetMetadata() + + action := func(groupAccount *group.GroupAccountInfo) error { + groupAccount.Metadata = metadata + groupAccount.Version++ + return s.groupAccountTable.Save(ctx, groupAccount) + } + + if err := assertMetadataLength(metadata, "group account metadata"); err != nil { + return nil, err + } + + err := s.doUpdateGroupAccount(ctx, req.Address, req.Admin, action, "group account metadata updated") + if err != nil { + return nil, err + } + + return &group.MsgUpdateGroupAccountMetadataResponse{}, nil +} + +func (s serverImpl) CreateProposal(ctx types.Context, req *group.MsgCreateProposalRequest) (*group.MsgCreateProposalResponse, error) { + accountAddress, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return nil, sdkerrors.Wrap(err, "request group account") + } + metadata := req.Metadata + proposers := req.Proposers + msgs := req.GetMsgs() + + if err := assertMetadataLength(metadata, "metadata"); err != nil { + return nil, err + } + + account, err := s.getGroupAccountInfo(ctx, accountAddress.Bytes()) + if err != nil { + return nil, sdkerrors.Wrap(err, "load group account") + } + + g, err := s.getGroupInfo(ctx, account.GroupId) + if err != nil { + return nil, sdkerrors.Wrap(err, "get group by account") + } + + // Only members of the group can submit a new proposal. + for i := range proposers { + if !s.groupMemberTable.Has(ctx, group.GroupMember{GroupId: g.GroupId, Member: &group.Member{Address: proposers[i]}}.PrimaryKey()) { + return nil, sdkerrors.Wrapf(group.ErrUnauthorized, "not in group: %s", proposers[i]) + } + } + + // Check that if the messages require signers, they are all equal to the given group account. + if err := ensureMsgAuthZ(msgs, accountAddress); err != nil { + return nil, err + } + + blockTime, err := gogotypes.TimestampProto(ctx.BlockTime()) + if err != nil { + return nil, sdkerrors.Wrap(err, "block time conversion") + } + + policy := account.GetDecisionPolicy() + if policy == nil { + return nil, sdkerrors.Wrap(group.ErrEmpty, "nil policy") + } + + // Prevent proposal that can not succeed. + err = policy.Validate(g) + if err != nil { + return nil, err + } + + // Define proposal timout. + // The voting window begins as soon as the proposal is submitted. + timeout := policy.GetTimeout() + window, err := gogotypes.DurationFromProto(&timeout) + if err != nil { + return nil, sdkerrors.Wrap(err, "maxVotingWindow time conversion") + } + endTime, err := gogotypes.TimestampProto(ctx.BlockTime().Add(window)) + if err != nil { + return nil, sdkerrors.Wrap(err, "end time conversion") + } + + m := &group.Proposal{ + ProposalId: s.proposalTable.Sequence().PeekNextVal(ctx), + Address: req.Address, + Metadata: metadata, + Proposers: proposers, + SubmittedAt: *blockTime, + GroupVersion: g.Version, + GroupAccountVersion: account.Version, + Result: group.ProposalResultUnfinalized, + Status: group.ProposalStatusSubmitted, + ExecutorResult: group.ProposalExecutorResultNotRun, + Timeout: *endTime, + VoteState: group.Tally{ + YesCount: "0", + NoCount: "0", + AbstainCount: "0", + VetoCount: "0", + }, + } + if err := m.SetMsgs(msgs); err != nil { + return nil, sdkerrors.Wrap(err, "create proposal") + } + + id, err := s.proposalTable.Create(ctx, m) + if err != nil { + return nil, sdkerrors.Wrap(err, "create proposal") + } + + err = ctx.EventManager().EmitTypedEvent(&group.EventCreateProposal{ProposalId: id}) + if err != nil { + return nil, err + } + + return &group.MsgCreateProposalResponse{ProposalId: id}, nil +} + +func (s serverImpl) Vote(ctx types.Context, req *group.MsgVoteRequest) (*group.MsgVoteResponse, error) { + id := req.ProposalId + choice := req.Choice + metadata := req.Metadata + + if err := assertMetadataLength(metadata, "metadata"); err != nil { + return nil, err + } + + blockTime, err := gogotypes.TimestampProto(ctx.BlockTime()) + if err != nil { + return nil, err + } + proposal, err := s.getProposal(ctx, id) + if err != nil { + return nil, err + } + // Ensure that we can still accept votes for this proposal. + if proposal.Status != group.ProposalStatusSubmitted { + return nil, sdkerrors.Wrap(group.ErrInvalid, "proposal not open for voting") + } + votingPeriodEnd, err := gogotypes.TimestampFromProto(&proposal.Timeout) + if err != nil { + return nil, err + } + if votingPeriodEnd.Before(ctx.BlockTime()) || votingPeriodEnd.Equal(ctx.BlockTime()) { + return nil, sdkerrors.Wrap(group.ErrExpired, "voting period has ended already") + } + + var accountInfo group.GroupAccountInfo + + // Ensure that group account hasn't been modified since the proposal submission. + address, err := sdk.AccAddressFromBech32(proposal.Address) + if err != nil { + return nil, sdkerrors.Wrap(err, "group account") + } + if err := s.groupAccountTable.GetOne(ctx, address.Bytes(), &accountInfo); err != nil { + return nil, sdkerrors.Wrap(err, "load group account") + } + if proposal.GroupAccountVersion != accountInfo.Version { + return nil, sdkerrors.Wrap(group.ErrModified, "group account was modified") + } + + // Ensure that group hasn't been modified since the proposal submission. + electorate, err := s.getGroupInfo(ctx, accountInfo.GroupId) + if err != nil { + return nil, err + } + if electorate.Version != proposal.GroupVersion { + return nil, sdkerrors.Wrap(group.ErrModified, "group was modified") + } + + // Count and store votes. + voterAddr := req.Voter + voter := group.GroupMember{GroupId: electorate.GroupId, Member: &group.Member{Address: voterAddr}} + if err := s.groupMemberTable.GetOne(ctx, voter.PrimaryKey(), &voter); err != nil { + return nil, sdkerrors.Wrapf(err, "address: %s", voterAddr) + } + newVote := group.Vote{ + ProposalId: id, + Voter: voterAddr, + Choice: choice, + Metadata: metadata, + SubmittedAt: *blockTime, + } + if err := proposal.VoteState.Add(newVote, voter.Member.Weight); err != nil { + return nil, sdkerrors.Wrap(err, "add new vote") + } + + // The ORM will return an error if the vote already exists, + // making sure than a voter hasn't already voted. + if err := s.voteTable.Create(ctx, &newVote); err != nil { + return nil, sdkerrors.Wrap(err, "store vote") + } + + // Run tally with new votes to close early. + if err := doTally(ctx, &proposal, electorate, accountInfo); err != nil { + return nil, err + } + + if err = s.proposalTable.Save(ctx, id, &proposal); err != nil { + return nil, err + } + + err = ctx.EventManager().EmitTypedEvent(&group.EventVote{ProposalId: id}) + if err != nil { + return nil, err + } + + return &group.MsgVoteResponse{}, nil +} + +// doTally updates the proposal status and tally if necessary based on the group account's decision policy. +func doTally(ctx types.Context, p *group.Proposal, electorate group.GroupInfo, accountInfo group.GroupAccountInfo) error { + policy := accountInfo.GetDecisionPolicy() + submittedAt, err := gogotypes.TimestampFromProto(&p.SubmittedAt) + if err != nil { + return err + } + switch result, err := policy.Allow(p.VoteState, electorate.TotalWeight, ctx.BlockTime().Sub(submittedAt)); { + case err != nil: + return sdkerrors.Wrap(err, "policy execution") + case result.Allow && result.Final: + p.Result = group.ProposalResultAccepted + p.Status = group.ProposalStatusClosed + case !result.Allow && result.Final: + p.Result = group.ProposalResultRejected + p.Status = group.ProposalStatusClosed + } + return nil +} + +// Exec executes the messages from a proposal. +func (s serverImpl) Exec(ctx types.Context, req *group.MsgExecRequest) (*group.MsgExecResponse, error) { + id := req.ProposalId + + proposal, err := s.getProposal(ctx, id) + if err != nil { + return nil, err + } + + if proposal.Status != group.ProposalStatusSubmitted && proposal.Status != group.ProposalStatusClosed { + return nil, sdkerrors.Wrapf(group.ErrInvalid, "not possible with proposal status %s", proposal.Status.String()) + } + + var accountInfo group.GroupAccountInfo + address, err := sdk.AccAddressFromBech32(proposal.Address) + if err != nil { + return nil, sdkerrors.Wrap(err, "group account") + } + if err := s.groupAccountTable.GetOne(ctx, address.Bytes(), &accountInfo); err != nil { + return nil, sdkerrors.Wrap(err, "load group account") + } + + storeUpdates := func() (*group.MsgExecResponse, error) { + if err := s.proposalTable.Save(ctx, id, &proposal); err != nil { + return nil, err + } + return &group.MsgExecResponse{}, nil + } + + if proposal.Status == group.ProposalStatusSubmitted { + // Ensure that group account hasn't been modified before tally. + if proposal.GroupAccountVersion != accountInfo.Version { + proposal.Result = group.ProposalResultUnfinalized + proposal.Status = group.ProposalStatusAborted + return storeUpdates() + } + + electorate, err := s.getGroupInfo(ctx, accountInfo.GroupId) + if err != nil { + return nil, sdkerrors.Wrap(err, "load group") + } + + // Ensure that group hasn't been modified before tally. + if electorate.Version != proposal.GroupVersion { + proposal.Result = group.ProposalResultUnfinalized + proposal.Status = group.ProposalStatusAborted + return storeUpdates() + } + if err := doTally(ctx, &proposal, electorate, accountInfo); err != nil { + return nil, err + } + } + + // Execute proposal payload. + if proposal.Status == group.ProposalStatusClosed && proposal.Result == group.ProposalResultAccepted && proposal.ExecutorResult != group.ProposalExecutorResultSuccess { + logger := ctx.Logger().With("module", fmt.Sprintf("x/%s", group.ModuleName)) + // Cashing context so that we don't update the store in case of failure. + ctx, flush := ctx.CacheContext() + address, err := sdk.AccAddressFromBech32(accountInfo.Address) + if err != nil { + return nil, sdkerrors.Wrap(err, "group account") + } + _, err = DoExecuteMsgs(ctx, s.router, address, proposal.GetMsgs()) + if err != nil { + proposal.ExecutorResult = group.ProposalExecutorResultFailure + proposalType := reflect.TypeOf(proposal).String() + logger.Info("proposal execution failed", "cause", err, "type", proposalType, "proposalID", id) + } else { + proposal.ExecutorResult = group.ProposalExecutorResultSuccess + flush() + } + } + + // Update proposal in proposalTable + res, err := storeUpdates() + if err != nil { + return nil, err + } + + err = ctx.EventManager().EmitTypedEvent(&group.EventExec{ProposalId: id}) + if err != nil { + return nil, err + } + + return res, nil +} + +type authNGroupReq interface { + GetGroupID() uint64 + GetAdmin() string +} + +type actionFn func(m *group.GroupInfo) error +type groupAccountActionFn func(m *group.GroupAccountInfo) error + +// doUpdateGroupAccount first makes sure that the group account admin initiated the group account update, +// before performing the group account update and emitting an event. +func (s serverImpl) doUpdateGroupAccount(ctx types.Context, groupAccount string, admin string, action groupAccountActionFn, note string) error { + groupAccountAddress, err := sdk.AccAddressFromBech32(groupAccount) + if err != nil { + return sdkerrors.Wrap(err, "group admin") + } + + var groupAccountInfo group.GroupAccountInfo + err = s.groupAccountTable.GetOne(ctx, groupAccountAddress.Bytes(), &groupAccountInfo) + if err != nil { + return sdkerrors.Wrap(err, "load group account") + } + + groupAccountAdmin, err := sdk.AccAddressFromBech32(admin) + if err != nil { + return sdkerrors.Wrap(err, "group account admin") + } + + // Only current group account admin is authorized to update a group account. + if groupAccountAdmin.String() != groupAccountInfo.Admin { + return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "not group admin") + } + + if err := action(&groupAccountInfo); err != nil { + return sdkerrors.Wrap(err, note) + } + + err = ctx.EventManager().EmitTypedEvent(&group.EventUpdateGroupAccount{Address: admin}) + if err != nil { + return err + } + + return nil +} + +// doUpdateGroup first makes sure that the group admin initiated the group update, +// before performing the group update and emitting an event. +func (s serverImpl) doUpdateGroup(ctx types.Context, req authNGroupReq, action actionFn, note string) error { + err := s.doAuthenticated(ctx, req, action, note) + if err != nil { + return err + } + + err = ctx.EventManager().EmitTypedEvent(&group.EventUpdateGroup{GroupId: req.GetGroupID()}) + if err != nil { + return err + } + + return nil +} + +// doAuthenticated makes sure that the group admin initiated the request, +// and perform the provided action on the group. +func (s serverImpl) doAuthenticated(ctx types.Context, req authNGroupReq, action actionFn, note string) error { + group, err := s.getGroupInfo(ctx, req.GetGroupID()) + if err != nil { + return err + } + admin, err := sdk.AccAddressFromBech32(group.Admin) + if err != nil { + return sdkerrors.Wrap(err, "group admin") + } + reqAdmin, err := sdk.AccAddressFromBech32(req.GetAdmin()) + if err != nil { + return sdkerrors.Wrap(err, "request admin") + } + if !admin.Equals(reqAdmin) { + return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "not group admin") + } + if err := action(&group); err != nil { + return sdkerrors.Wrap(err, note) + } + return nil +} + +// assertMetadataLength returns an error if given metadata length +// is greater than a fixed maxMetadataLength. +func assertMetadataLength(metadata []byte, description string) error { + if len(metadata) > group.MaxMetadataLength { + return sdkerrors.Wrap(group.ErrMaxLimit, description) + } + return nil +} diff --git a/x/group/server/proposal_executor.go b/x/group/server/proposal_executor.go new file mode 100644 index 0000000000..1a2f2b230a --- /dev/null +++ b/x/group/server/proposal_executor.go @@ -0,0 +1,42 @@ +package server + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/regen-network/regen-ledger/x/group" +) + +// ensureMsgAuthZ checks that if a message requires signers that all of them are equal to the given group account. +func ensureMsgAuthZ(msgs []sdk.Msg, groupAccount sdk.AccAddress) error { + for i := range msgs { + for _, acct := range msgs[i].GetSigners() { + if !groupAccount.Equals(acct) { + return errors.Wrap(errors.ErrUnauthorized, "msg does not have group account authorization") + } + } + } + return nil +} + +// DoExecuteMsgs routes the messages to the registered handlers. Messages are limited to those that require no authZ or +// by the group account only. Otherwise this gives access to other peoples accounts as the sdk ant handler is bypassed +func DoExecuteMsgs(ctx sdk.Context, router sdk.Router, groupAccount sdk.AccAddress, msgs []sdk.Msg) ([]sdk.Result, error) { + results := make([]sdk.Result, len(msgs)) + if err := ensureMsgAuthZ(msgs, groupAccount); err != nil { + return nil, err + } + for i, msg := range msgs { + handler := router.Route(ctx, msg.Route()) + if handler == nil { + return nil, errors.Wrapf(group.ErrInvalid, "no message handler found for %q", msg.Route()) + } + r, err := handler(ctx, msg) + if err != nil { + return nil, errors.Wrapf(err, "message %q at position %d", msg.Type(), i) + } + if r != nil { + results[i] = *r + } + } + return results, nil +} diff --git a/x/group/server/query_server.go b/x/group/server/query_server.go new file mode 100644 index 0000000000..b9e80c2554 --- /dev/null +++ b/x/group/server/query_server.go @@ -0,0 +1,254 @@ +package server + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/regen-network/regen-ledger/orm" + "github.com/regen-network/regen-ledger/types" + "github.com/regen-network/regen-ledger/x/group" +) + +func (s serverImpl) GroupInfo(ctx types.Context, request *group.QueryGroupInfoRequest) (*group.QueryGroupInfoResponse, error) { + groupID := request.GroupId + groupInfo, err := s.getGroupInfo(ctx, groupID) + if err != nil { + return nil, err + } + + return &group.QueryGroupInfoResponse{Info: &groupInfo}, nil +} + +func (s serverImpl) getGroupInfo(ctx types.Context, id uint64) (group.GroupInfo, error) { + var obj group.GroupInfo + return obj, s.groupTable.GetOne(ctx, group.ID(id).Bytes(), &obj) +} + +func (s serverImpl) GroupAccountInfo(ctx types.Context, request *group.QueryGroupAccountInfoRequest) (*group.QueryGroupAccountInfoResponse, error) { + addr, err := sdk.AccAddressFromBech32(request.Address) + if err != nil { + return nil, err + } + groupAccountInfo, err := s.getGroupAccountInfo(ctx, addr) + if err != nil { + return nil, err + } + + return &group.QueryGroupAccountInfoResponse{Info: &groupAccountInfo}, nil +} + +func (s serverImpl) getGroupAccountInfo(ctx types.Context, accountAddress sdk.AccAddress) (group.GroupAccountInfo, error) { + var obj group.GroupAccountInfo + return obj, s.groupAccountTable.GetOne(ctx, accountAddress.Bytes(), &obj) +} + +func (s serverImpl) GroupMembers(ctx types.Context, request *group.QueryGroupMembersRequest) (*group.QueryGroupMembersResponse, error) { + groupID := request.GroupId + it, err := s.getGroupMembers(ctx, groupID, request.Pagination) + if err != nil { + return nil, err + } + + var members []*group.GroupMember + pageRes, err := orm.Paginate(it, request.Pagination, &members) + if err != nil { + return nil, err + } + + return &group.QueryGroupMembersResponse{ + Members: members, + Pagination: pageRes, + }, nil +} + +func (s serverImpl) getGroupMembers(ctx types.Context, id uint64, pageRequest *query.PageRequest) (orm.Iterator, error) { + return s.groupMemberByGroupIndex.GetPaginated(ctx, id, pageRequest) +} + +func (s serverImpl) GroupsByAdmin(ctx types.Context, request *group.QueryGroupsByAdminRequest) (*group.QueryGroupsByAdminResponse, error) { + addr, err := sdk.AccAddressFromBech32(request.Admin) + if err != nil { + return nil, err + } + it, err := s.getGroupsByAdmin(ctx, addr, request.Pagination) + if err != nil { + return nil, err + } + + var groups []*group.GroupInfo + pageRes, err := orm.Paginate(it, request.Pagination, &groups) + if err != nil { + return nil, err + } + + return &group.QueryGroupsByAdminResponse{ + Groups: groups, + Pagination: pageRes, + }, nil +} + +func (s serverImpl) getGroupsByAdmin(ctx types.Context, admin sdk.AccAddress, pageRequest *query.PageRequest) (orm.Iterator, error) { + return s.groupByAdminIndex.GetPaginated(ctx, admin.Bytes(), pageRequest) +} + +func (s serverImpl) GroupAccountsByGroup(ctx types.Context, request *group.QueryGroupAccountsByGroupRequest) (*group.QueryGroupAccountsByGroupResponse, error) { + groupID := request.GroupId + it, err := s.getGroupAccountsByGroup(ctx, groupID, request.Pagination) + if err != nil { + return nil, err + } + + var accounts []*group.GroupAccountInfo + pageRes, err := orm.Paginate(it, request.Pagination, &accounts) + if err != nil { + return nil, err + } + + return &group.QueryGroupAccountsByGroupResponse{ + GroupAccounts: accounts, + Pagination: pageRes, + }, nil +} + +func (s serverImpl) getGroupAccountsByGroup(ctx types.Context, id uint64, pageRequest *query.PageRequest) (orm.Iterator, error) { + return s.groupAccountByGroupIndex.GetPaginated(ctx, id, pageRequest) +} + +func (s serverImpl) GroupAccountsByAdmin(ctx types.Context, request *group.QueryGroupAccountsByAdminRequest) (*group.QueryGroupAccountsByAdminResponse, error) { + addr, err := sdk.AccAddressFromBech32(request.Admin) + if err != nil { + return nil, err + } + it, err := s.getGroupAccountsByAdmin(ctx, addr, request.Pagination) + if err != nil { + return nil, err + } + + var accounts []*group.GroupAccountInfo + pageRes, err := orm.Paginate(it, request.Pagination, &accounts) + if err != nil { + return nil, err + } + + return &group.QueryGroupAccountsByAdminResponse{ + GroupAccounts: accounts, + Pagination: pageRes, + }, nil +} + +func (s serverImpl) getGroupAccountsByAdmin(ctx types.Context, admin sdk.AccAddress, pageRequest *query.PageRequest) (orm.Iterator, error) { + return s.groupAccountByAdminIndex.GetPaginated(ctx, admin.Bytes(), pageRequest) +} + +func (s serverImpl) Proposal(ctx types.Context, request *group.QueryProposalRequest) (*group.QueryProposalResponse, error) { + proposalID := request.ProposalId + proposal, err := s.getProposal(ctx, proposalID) + if err != nil { + return nil, err + } + + return &group.QueryProposalResponse{Proposal: &proposal}, nil +} + +func (s serverImpl) ProposalsByGroupAccount(ctx types.Context, request *group.QueryProposalsByGroupAccountRequest) (*group.QueryProposalsByGroupAccountResponse, error) { + addr, err := sdk.AccAddressFromBech32(request.Address) + if err != nil { + return nil, err + } + it, err := s.getProposalsByGroupAccount(ctx, addr, request.Pagination) + if err != nil { + return nil, err + } + + var proposals []*group.Proposal + pageRes, err := orm.Paginate(it, request.Pagination, &proposals) + if err != nil { + return nil, err + } + + return &group.QueryProposalsByGroupAccountResponse{ + Proposals: proposals, + Pagination: pageRes, + }, nil +} + +func (s serverImpl) getProposalsByGroupAccount(ctx types.Context, account sdk.AccAddress, pageRequest *query.PageRequest) (orm.Iterator, error) { + return s.proposalByGroupAccountIndex.GetPaginated(ctx, account.Bytes(), pageRequest) +} + +func (s serverImpl) getProposal(ctx types.Context, proposalID uint64) (group.Proposal, error) { + var p group.Proposal + if _, err := s.proposalTable.GetOne(ctx, proposalID, &p); err != nil { + return group.Proposal{}, sdkerrors.Wrap(err, "load proposal") + } + return p, nil +} + +func (s serverImpl) VoteByProposalVoter(ctx types.Context, request *group.QueryVoteByProposalVoterRequest) (*group.QueryVoteByProposalVoterResponse, error) { + addr, err := sdk.AccAddressFromBech32(request.Voter) + if err != nil { + return nil, err + } + proposalID := request.ProposalId + vote, err := s.getVote(ctx, proposalID, addr) + if err != nil { + return nil, err + } + return &group.QueryVoteByProposalVoterResponse{ + Vote: &vote, + }, nil +} + +func (s serverImpl) VotesByProposal(ctx types.Context, request *group.QueryVotesByProposalRequest) (*group.QueryVotesByProposalResponse, error) { + proposalID := request.ProposalId + it, err := s.getVotesByProposal(ctx, proposalID, request.Pagination) + if err != nil { + return nil, err + } + + var votes []*group.Vote + pageRes, err := orm.Paginate(it, request.Pagination, &votes) + if err != nil { + return nil, err + } + + return &group.QueryVotesByProposalResponse{ + Votes: votes, + Pagination: pageRes, + }, nil +} + +func (s serverImpl) VotesByVoter(ctx types.Context, request *group.QueryVotesByVoterRequest) (*group.QueryVotesByVoterResponse, error) { + addr, err := sdk.AccAddressFromBech32(request.Voter) + if err != nil { + return nil, err + } + it, err := s.getVotesByVoter(ctx, addr, request.Pagination) + if err != nil { + return nil, err + } + + var votes []*group.Vote + pageRes, err := orm.Paginate(it, request.Pagination, &votes) + if err != nil { + return nil, err + } + + return &group.QueryVotesByVoterResponse{ + Votes: votes, + Pagination: pageRes, + }, nil +} + +func (s serverImpl) getVote(ctx types.Context, proposalID uint64, voter sdk.AccAddress) (group.Vote, error) { + var v group.Vote + return v, s.voteTable.GetOne(ctx, group.Vote{ProposalId: proposalID, Voter: voter.String()}.PrimaryKey(), &v) +} + +func (s serverImpl) getVotesByProposal(ctx types.Context, proposalID uint64, pageRequest *query.PageRequest) (orm.Iterator, error) { + return s.voteByProposalIndex.GetPaginated(ctx, proposalID, pageRequest) +} + +func (s serverImpl) getVotesByVoter(ctx types.Context, voter sdk.AccAddress, pageRequest *query.PageRequest) (orm.Iterator, error) { + return s.voteByVoterIndex.GetPaginated(ctx, voter.Bytes(), pageRequest) +} diff --git a/x/group/server/server.go b/x/group/server/server.go new file mode 100644 index 0000000000..326e7866fa --- /dev/null +++ b/x/group/server/server.go @@ -0,0 +1,168 @@ +package server + +import ( + "github.com/regen-network/regen-ledger/orm" + servermodule "github.com/regen-network/regen-ledger/types/module/server" + "github.com/regen-network/regen-ledger/x/group" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // Group Table + GroupTablePrefix byte = 0x0 + GroupTableSeqPrefix byte = 0x1 + GroupByAdminIndexPrefix byte = 0x2 + + // Group Member Table + GroupMemberTablePrefix byte = 0x10 + GroupMemberByGroupIndexPrefix byte = 0x11 + GroupMemberByMemberIndexPrefix byte = 0x12 + + // Group Account Table + GroupAccountTablePrefix byte = 0x20 + GroupAccountTableSeqPrefix byte = 0x21 + GroupAccountByGroupIndexPrefix byte = 0x22 + GroupAccountByAdminIndexPrefix byte = 0x23 + + // Proposal Table + ProposalTablePrefix byte = 0x30 + ProposalTableSeqPrefix byte = 0x31 + ProposalByGroupAccountIndexPrefix byte = 0x32 + ProposalByProposerIndexPrefix byte = 0x33 + + // Vote Table + VoteTablePrefix byte = 0x40 + VoteByProposalIndexPrefix byte = 0x41 + VoteByVoterIndexPrefix byte = 0x42 +) + +type serverImpl struct { + key servermodule.RootModuleKey + router sdk.Router + + accKeeper AccountKeeper + + // Group Table + groupSeq orm.Sequence + groupTable orm.Table + groupByAdminIndex orm.Index + + // Group Member Table + groupMemberTable orm.PrimaryKeyTable + groupMemberByGroupIndex orm.UInt64Index + groupMemberByMemberIndex orm.Index + + // Group Account Table + groupAccountSeq orm.Sequence + groupAccountTable orm.PrimaryKeyTable + groupAccountByGroupIndex orm.UInt64Index + groupAccountByAdminIndex orm.Index + + // Proposal Table + proposalTable orm.AutoUInt64Table + proposalByGroupAccountIndex orm.Index + proposalByProposerIndex orm.Index + + // Vote Table + voteTable orm.PrimaryKeyTable + voteByProposalIndex orm.UInt64Index + voteByVoterIndex orm.Index +} + +func newServer(storeKey servermodule.RootModuleKey, router sdk.Router, accKeeper AccountKeeper, cdc codec.Marshaler) serverImpl { + s := serverImpl{key: storeKey, router: router, accKeeper: accKeeper} + + // Group Table + groupTableBuilder := orm.NewTableBuilder(GroupTablePrefix, storeKey, &group.GroupInfo{}, orm.FixLengthIndexKeys(orm.EncodedSeqLength), cdc) + s.groupSeq = orm.NewSequence(storeKey, GroupTableSeqPrefix) + s.groupByAdminIndex = orm.NewIndex(groupTableBuilder, GroupByAdminIndexPrefix, func(val interface{}) ([]orm.RowID, error) { + addr, err := sdk.AccAddressFromBech32(val.(*group.GroupInfo).Admin) + if err != nil { + return nil, err + } + return []orm.RowID{addr.Bytes()}, nil + }) + s.groupTable = groupTableBuilder.Build() + + // Group Member Table + groupMemberTableBuilder := orm.NewPrimaryKeyTableBuilder(GroupMemberTablePrefix, storeKey, &group.GroupMember{}, orm.Max255DynamicLengthIndexKeyCodec{}, cdc) + s.groupMemberByGroupIndex = orm.NewUInt64Index(groupMemberTableBuilder, GroupMemberByGroupIndexPrefix, func(val interface{}) ([]uint64, error) { + group := val.(*group.GroupMember).GroupId + return []uint64{group}, nil + }) + s.groupMemberByMemberIndex = orm.NewIndex(groupMemberTableBuilder, GroupMemberByMemberIndexPrefix, func(val interface{}) ([]orm.RowID, error) { + memberAddr := val.(*group.GroupMember).Member.Address + addr, err := sdk.AccAddressFromBech32(memberAddr) + if err != nil { + return nil, err + } + return []orm.RowID{addr.Bytes()}, nil + }) + s.groupMemberTable = groupMemberTableBuilder.Build() + + // Group Account Table + s.groupAccountSeq = orm.NewSequence(storeKey, GroupAccountTableSeqPrefix) + groupAccountTableBuilder := orm.NewPrimaryKeyTableBuilder(GroupAccountTablePrefix, storeKey, &group.GroupAccountInfo{}, orm.Max255DynamicLengthIndexKeyCodec{}, cdc) + s.groupAccountByGroupIndex = orm.NewUInt64Index(groupAccountTableBuilder, GroupAccountByGroupIndexPrefix, func(value interface{}) ([]uint64, error) { + group := value.(*group.GroupAccountInfo).GroupId + return []uint64{group}, nil + }) + s.groupAccountByAdminIndex = orm.NewIndex(groupAccountTableBuilder, GroupAccountByAdminIndexPrefix, func(value interface{}) ([]orm.RowID, error) { + admin := value.(*group.GroupAccountInfo).Admin + addr, err := sdk.AccAddressFromBech32(admin) + if err != nil { + return nil, err + } + return []orm.RowID{addr.Bytes()}, nil + }) + s.groupAccountTable = groupAccountTableBuilder.Build() + + // Proposal Table + proposalTableBuilder := orm.NewAutoUInt64TableBuilder(ProposalTablePrefix, ProposalTableSeqPrefix, storeKey, &group.Proposal{}, cdc) + s.proposalByGroupAccountIndex = orm.NewIndex(proposalTableBuilder, ProposalByGroupAccountIndexPrefix, func(value interface{}) ([]orm.RowID, error) { + account := value.(*group.Proposal).Address + addr, err := sdk.AccAddressFromBech32(account) + if err != nil { + return nil, err + } + return []orm.RowID{addr.Bytes()}, nil + }) + s.proposalByProposerIndex = orm.NewIndex(proposalTableBuilder, ProposalByProposerIndexPrefix, func(value interface{}) ([]orm.RowID, error) { + proposers := value.(*group.Proposal).Proposers + r := make([]orm.RowID, len(proposers)) + for i := range proposers { + addr, err := sdk.AccAddressFromBech32(proposers[i]) + if err != nil { + return nil, err + } + r[i] = addr.Bytes() + } + return r, nil + }) + s.proposalTable = proposalTableBuilder.Build() + + // Vote Table + voteTableBuilder := orm.NewPrimaryKeyTableBuilder(VoteTablePrefix, storeKey, &group.Vote{}, orm.Max255DynamicLengthIndexKeyCodec{}, cdc) + s.voteByProposalIndex = orm.NewUInt64Index(voteTableBuilder, VoteByProposalIndexPrefix, func(value interface{}) ([]uint64, error) { + return []uint64{value.(*group.Vote).ProposalId}, nil + }) + s.voteByVoterIndex = orm.NewIndex(voteTableBuilder, VoteByVoterIndexPrefix, func(value interface{}) ([]orm.RowID, error) { + addr, err := sdk.AccAddressFromBech32(value.(*group.Vote).Voter) + if err != nil { + return nil, err + } + return []orm.RowID{addr.Bytes()}, nil + }) + s.voteTable = voteTableBuilder.Build() + + return s +} + +func RegisterServices(configurator servermodule.Configurator, accountKeeper AccountKeeper) { + impl := newServer(configurator.ModuleKey(), configurator.Router(), accountKeeper, configurator.Marshaler()) + group.RegisterMsgServer(configurator.MsgServer(), impl) + group.RegisterQueryServer(configurator.QueryServer(), impl) + configurator.RegisterGenesisHandlers(impl.InitGenesis, impl.ExportGenesis) +} diff --git a/x/group/server/server_test.go b/x/group/server/server_test.go new file mode 100644 index 0000000000..9c73037c14 --- /dev/null +++ b/x/group/server/server_test.go @@ -0,0 +1,60 @@ +package server_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/bank" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + + "github.com/stretchr/testify/suite" + + "github.com/regen-network/regen-ledger/types/module" + "github.com/regen-network/regen-ledger/types/module/server" + groupmodule "github.com/regen-network/regen-ledger/x/group/module" + "github.com/regen-network/regen-ledger/x/group/server/testsuite" +) + +func TestServer(t *testing.T) { + ff := server.NewFixtureFactory(t, 6) + cdc := ff.Codec() + // Setting up bank keeper + banktypes.RegisterInterfaces(cdc.InterfaceRegistry()) + authtypes.RegisterInterfaces(cdc.InterfaceRegistry()) + + paramsKey := sdk.NewKVStoreKey(paramstypes.StoreKey) + authKey := sdk.NewKVStoreKey(authtypes.StoreKey) + bankKey := sdk.NewKVStoreKey(banktypes.StoreKey) + tkey := sdk.NewTransientStoreKey(paramstypes.TStoreKey) + amino := codec.NewLegacyAmino() + + authSubspace := paramstypes.NewSubspace(cdc, amino, paramsKey, tkey, authtypes.ModuleName) + bankSubspace := paramstypes.NewSubspace(cdc, amino, paramsKey, tkey, banktypes.ModuleName) + + accountKeeper := authkeeper.NewAccountKeeper( + cdc, authKey, authSubspace, authtypes.ProtoBaseAccount, map[string][]string{}, + ) + + bankKeeper := bankkeeper.NewBaseKeeper( + cdc, bankKey, accountKeeper, bankSubspace, map[string]bool{}, + ) + + baseApp := ff.BaseApp() + + baseApp.Router().AddRoute(sdk.NewRoute(banktypes.ModuleName, bank.NewHandler(bankKeeper))) + baseApp.MountStore(tkey, sdk.StoreTypeTransient) + baseApp.MountStore(paramsKey, sdk.StoreTypeIAVL) + baseApp.MountStore(authKey, sdk.StoreTypeIAVL) + baseApp.MountStore(bankKey, sdk.StoreTypeIAVL) + + ff.SetModules([]module.Module{groupmodule.Module{AccountKeeper: accountKeeper}}) + + s := testsuite.NewIntegrationTestSuite(ff, accountKeeper, bankKeeper) + + suite.Run(t, s) +} diff --git a/x/group/server/testsuite/genesis.go b/x/group/server/testsuite/genesis.go new file mode 100644 index 0000000000..ca71ffd6be --- /dev/null +++ b/x/group/server/testsuite/genesis.go @@ -0,0 +1,177 @@ +package testsuite + +import ( + "encoding/json" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + proto "github.com/gogo/protobuf/types" + "github.com/regen-network/regen-ledger/x/group" +) + +func (s *IntegrationTestSuite) TestInitExportGenesis() { + require := s.Require() + ctx := s.genesisCtx + cdc := s.fixture.Codec() + + now := time.Now() + submittedAt, err := proto.TimestampProto(now) + require.NoError(err) + timeout, err := proto.TimestampProto(now.Add(time.Second * 1)) + require.NoError(err) + + groupAccount := &group.GroupAccountInfo{ + Address: s.groupAccountAddr.String(), + GroupId: 1, + Admin: s.addr1.String(), + Version: 1, + Metadata: []byte("account metadata"), + } + err = groupAccount.SetDecisionPolicy(&group.ThresholdDecisionPolicy{ + Threshold: "1", + Timeout: proto.Duration{Seconds: 1}, + }) + require.NoError(err) + + proposal := &group.Proposal{ + ProposalId: 1, + Address: s.groupAccountAddr.String(), + Metadata: []byte("proposal metadata"), + GroupVersion: 1, + GroupAccountVersion: 1, + Proposers: []string{ + s.addr1.String(), + }, + SubmittedAt: *submittedAt, + Status: group.ProposalStatusClosed, + Result: group.ProposalResultAccepted, + VoteState: group.Tally{ + YesCount: "1", + NoCount: "0", + AbstainCount: "0", + VetoCount: "0", + }, + Timeout: *timeout, + ExecutorResult: group.ProposalExecutorResultSuccess, + } + err = proposal.SetMsgs([]sdk.Msg{&banktypes.MsgSend{ + FromAddress: s.groupAccountAddr.String(), + ToAddress: s.addr2.String(), + Amount: sdk.Coins{sdk.NewInt64Coin("test", 100)}, + }}) + require.NoError(err) + + genesisState := &group.GenesisState{ + GroupSeq: 2, + Groups: []*group.GroupInfo{{GroupId: 1, Admin: s.addr1.String(), Metadata: []byte("1"), Version: 1, TotalWeight: "1"}, {GroupId: 2, Admin: s.addr2.String(), Metadata: []byte("2"), Version: 2, TotalWeight: "2"}}, + GroupMembers: []*group.GroupMember{{GroupId: 1, Member: &group.Member{Address: s.addr1.String(), Weight: "1", Metadata: []byte("member metadata")}}, {GroupId: 2, Member: &group.Member{Address: s.addr1.String(), Weight: "2", Metadata: []byte("member metadata")}}}, + GroupAccountSeq: 1, + GroupAccounts: []*group.GroupAccountInfo{groupAccount}, + ProposalSeq: 1, + Proposals: []*group.Proposal{proposal}, + Votes: []*group.Vote{{ProposalId: proposal.ProposalId, Voter: s.addr1.String(), SubmittedAt: *submittedAt, Choice: group.Choice_CHOICE_YES}}, + } + + genesisBytes, err := cdc.MarshalJSON(genesisState) + require.NoError(err) + + genesisData := map[string]json.RawMessage{group.ModuleName: genesisBytes} + _, err = s.fixture.InitGenesis(ctx.Context, genesisData) + require.NoError(err) + + for i, g := range genesisState.Groups { + res, err := s.queryClient.GroupInfo(ctx, &group.QueryGroupInfoRequest{ + GroupId: g.GroupId, + }) + require.NoError(err) + require.Equal(g, res.Info) + + membersRes, err := s.queryClient.GroupMembers(ctx, &group.QueryGroupMembersRequest{ + GroupId: g.GroupId, + }) + require.NoError(err) + require.Equal(len(membersRes.Members), 1) + require.Equal(membersRes.Members[0], genesisState.GroupMembers[i]) + } + + for _, g := range genesisState.GroupAccounts { + res, err := s.queryClient.GroupAccountInfo(ctx, &group.QueryGroupAccountInfoRequest{ + Address: g.Address, + }) + require.NoError(err) + s.assertGroupAccountsEqual(g, res.Info) + } + + for _, g := range genesisState.Proposals { + res, err := s.queryClient.Proposal(ctx, &group.QueryProposalRequest{ + ProposalId: g.ProposalId, + }) + require.NoError(err) + s.assertProposalsEqual(g, res.Proposal) + + votesRes, err := s.queryClient.VotesByProposal(ctx, &group.QueryVotesByProposalRequest{ + ProposalId: g.ProposalId, + }) + require.NoError(err) + require.Equal(len(votesRes.Votes), 1) + require.Equal(votesRes.Votes[0], genesisState.Votes[0]) + } + + exported, err := s.fixture.ExportGenesis(ctx.Context) + require.NoError(err) + + var exportedGenesisState group.GenesisState + err = cdc.UnmarshalJSON(exported[group.ModuleName], &exportedGenesisState) + require.NoError(err) + + require.Equal(genesisState.Groups, exportedGenesisState.Groups) + require.Equal(genesisState.GroupMembers, exportedGenesisState.GroupMembers) + + require.Equal(len(genesisState.GroupAccounts), len(exportedGenesisState.GroupAccounts)) + for i, g := range genesisState.GroupAccounts { + res := exportedGenesisState.GroupAccounts[i] + require.NoError(err) + s.assertGroupAccountsEqual(g, res) + } + + require.Equal(len(genesisState.Proposals), len(exportedGenesisState.Proposals)) + for i, g := range genesisState.Proposals { + res := exportedGenesisState.Proposals[i] + require.NoError(err) + s.assertProposalsEqual(g, res) + } + require.Equal(genesisState.Votes, exportedGenesisState.Votes) + + require.Equal(genesisState.GroupSeq, exportedGenesisState.GroupSeq) + require.Equal(genesisState.GroupAccountSeq, exportedGenesisState.GroupAccountSeq) + require.Equal(genesisState.ProposalSeq, exportedGenesisState.ProposalSeq) + +} + +func (s *IntegrationTestSuite) assertGroupAccountsEqual(g *group.GroupAccountInfo, other *group.GroupAccountInfo) { + require := s.Require() + require.Equal(g.Address, other.Address) + require.Equal(g.GroupId, other.GroupId) + require.Equal(g.Admin, other.Admin) + require.Equal(g.Metadata, other.Metadata) + require.Equal(g.Version, other.Version) + require.Equal(g.GetDecisionPolicy(), other.GetDecisionPolicy()) +} + +func (s *IntegrationTestSuite) assertProposalsEqual(g *group.Proposal, other *group.Proposal) { + require := s.Require() + require.Equal(g.ProposalId, other.ProposalId) + require.Equal(g.Address, other.Address) + require.Equal(g.Metadata, other.Metadata) + require.Equal(g.Proposers, other.Proposers) + require.Equal(g.SubmittedAt, other.SubmittedAt) + require.Equal(g.GroupVersion, other.GroupVersion) + require.Equal(g.GroupAccountVersion, other.GroupAccountVersion) + require.Equal(g.Status, other.Status) + require.Equal(g.Result, other.Result) + require.Equal(g.VoteState, other.VoteState) + require.Equal(g.Timeout, other.Timeout) + require.Equal(g.ExecutorResult, other.ExecutorResult) + require.Equal(g.GetMsgs(), other.GetMsgs()) +} diff --git a/x/group/server/testsuite/suite.go b/x/group/server/testsuite/suite.go new file mode 100644 index 0000000000..98b301546f --- /dev/null +++ b/x/group/server/testsuite/suite.go @@ -0,0 +1,1998 @@ +package testsuite + +import ( + "bytes" + "context" + "sort" + "strings" + "time" + + "github.com/regen-network/regen-ledger/testutil" + servermodule "github.com/regen-network/regen-ledger/types/module/server" + + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + + gogotypes "github.com/gogo/protobuf/types" + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + bank "github.com/cosmos/cosmos-sdk/x/bank" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + "github.com/regen-network/regen-ledger/testutil/testdata" + "github.com/regen-network/regen-ledger/types" + "github.com/regen-network/regen-ledger/x/group" + groupserver "github.com/regen-network/regen-ledger/x/group/server" +) + +type IntegrationTestSuite struct { + suite.Suite + + fixtureFactory *servermodule.FixtureFactory + fixture testutil.Fixture + + ctx context.Context + sdkCtx sdk.Context + genesisCtx types.Context + msgClient group.MsgClient + queryClient group.QueryClient + addr1 sdk.AccAddress + addr2 sdk.AccAddress + addr3 sdk.AccAddress + addr4 sdk.AccAddress + addr5 sdk.AccAddress + addr6 sdk.AccAddress + groupAccountAddr sdk.AccAddress + groupID uint64 + + accountKeeper authkeeper.AccountKeeper + bankKeeper bankkeeper.Keeper + + blockTime time.Time +} + +func NewIntegrationTestSuite(fixtureFactory *servermodule.FixtureFactory, accountKeeper authkeeper.AccountKeeper, bankKeeper bankkeeper.BaseKeeper) *IntegrationTestSuite { + return &IntegrationTestSuite{ + fixtureFactory: fixtureFactory, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +func (s *IntegrationTestSuite) SetupSuite() { + s.fixture = s.fixtureFactory.Setup() + + s.blockTime = time.Now().UTC() + + // TODO clean up once types.Context merged upstream into sdk.Context + sdkCtx := s.fixture.Context().(types.Context).WithBlockTime(s.blockTime) + s.sdkCtx, _ = sdkCtx.CacheContext() + s.ctx = types.Context{Context: s.sdkCtx} + s.genesisCtx = types.Context{Context: sdkCtx} + + totalSupply := banktypes.NewSupply(sdk.NewCoins(sdk.NewInt64Coin("test", 400000000))) + s.bankKeeper.SetSupply(sdkCtx, totalSupply) + s.bankKeeper.SetParams(sdkCtx, banktypes.DefaultParams()) + + s.msgClient = group.NewMsgClient(s.fixture.TxConn()) + s.queryClient = group.NewQueryClient(s.fixture.QueryConn()) + + s.Require().GreaterOrEqual(len(s.fixture.Signers()), 6) + s.addr1 = s.fixture.Signers()[0] + s.addr2 = s.fixture.Signers()[1] + s.addr3 = s.fixture.Signers()[2] + s.addr4 = s.fixture.Signers()[3] + s.addr5 = s.fixture.Signers()[4] + s.addr6 = s.fixture.Signers()[5] + + // Initial group, group account and balance setup + members := []group.Member{ + {Address: s.addr2.String(), Weight: "1"}, + } + groupRes, err := s.msgClient.CreateGroup(s.ctx, &group.MsgCreateGroupRequest{ + Admin: s.addr1.String(), + Members: members, + Metadata: nil, + }) + s.Require().NoError(err) + s.groupID = groupRes.GroupId + + policy := group.NewThresholdDecisionPolicy( + "1", + gogotypes.Duration{Seconds: 1}, + ) + accountReq := &group.MsgCreateGroupAccountRequest{ + Admin: s.addr1.String(), + GroupId: s.groupID, + Metadata: nil, + } + err = accountReq.SetDecisionPolicy(policy) + s.Require().NoError(err) + accountRes, err := s.msgClient.CreateGroupAccount(s.ctx, accountReq) + s.Require().NoError(err) + addr, err := sdk.AccAddressFromBech32(accountRes.Address) + s.Require().NoError(err) + s.groupAccountAddr = addr + + s.Require().NoError(s.bankKeeper.SetBalances(s.sdkCtx, s.groupAccountAddr, sdk.Coins{sdk.NewInt64Coin("test", 10000)})) +} + +func (s *IntegrationTestSuite) TearDownSuite() { + s.fixture.Teardown() +} + +func (s *IntegrationTestSuite) TestCreateGroup() { + members := []group.Member{{ + Address: s.addr5.String(), + Weight: "1", + Metadata: nil, + }, { + Address: s.addr6.String(), + Weight: "2", + Metadata: nil, + }} + + expGroups := []*group.GroupInfo{ + { + GroupId: s.groupID, + Version: 1, + Admin: s.addr1.String(), + TotalWeight: "1", + Metadata: nil, + }, + { + GroupId: 2, + Version: 1, + Admin: s.addr1.String(), + TotalWeight: "3", + Metadata: nil, + }, + } + + specs := map[string]struct { + req *group.MsgCreateGroupRequest + expErr bool + expGroups []*group.GroupInfo + }{ + "all good": { + req: &group.MsgCreateGroupRequest{ + Admin: s.addr1.String(), + Members: members, + Metadata: nil, + }, + expGroups: expGroups, + }, + "group metadata too long": { + req: &group.MsgCreateGroupRequest{ + Admin: s.addr1.String(), + Members: members, + Metadata: bytes.Repeat([]byte{1}, 256), + }, + expErr: true, + }, + "member metadata too long": { + req: &group.MsgCreateGroupRequest{ + Admin: s.addr1.String(), + Members: []group.Member{{ + Address: s.addr3.String(), + Weight: "1", + Metadata: bytes.Repeat([]byte{1}, 256), + }}, + Metadata: nil, + }, + expErr: true, + }, + "zero member weight": { + req: &group.MsgCreateGroupRequest{ + Admin: s.addr1.String(), + Members: []group.Member{{ + Address: s.addr3.String(), + Weight: "0", + Metadata: nil, + }}, + Metadata: nil, + }, + expErr: true, + }, + } + var seq uint32 = 1 + for msg, spec := range specs { + spec := spec + s.Run(msg, func() { + res, err := s.msgClient.CreateGroup(s.ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + _, err := s.queryClient.GroupInfo(s.ctx, &group.QueryGroupInfoRequest{GroupId: uint64(seq + 1)}) + s.Require().Error(err) + return + } + s.Require().NoError(err) + id := res.GroupId + + seq++ + s.Assert().Equal(uint64(seq), id) + + // then all data persisted + loadedGroupRes, err := s.queryClient.GroupInfo(s.ctx, &group.QueryGroupInfoRequest{GroupId: id}) + s.Require().NoError(err) + s.Assert().Equal(spec.req.Admin, loadedGroupRes.Info.Admin) + s.Assert().Equal(spec.req.Metadata, loadedGroupRes.Info.Metadata) + s.Assert().Equal(id, loadedGroupRes.Info.GroupId) + s.Assert().Equal(uint64(1), loadedGroupRes.Info.Version) + + // and members are stored as well + membersRes, err := s.queryClient.GroupMembers(s.ctx, &group.QueryGroupMembersRequest{GroupId: id}) + s.Require().NoError(err) + loadedMembers := membersRes.Members + s.Require().Equal(len(members), len(loadedMembers)) + // we reorder members by address to be able to compare them + sort.Slice(members, func(i, j int) bool { return members[i].Address < members[j].Address }) + for i := range loadedMembers { + s.Assert().Equal(members[i].Metadata, loadedMembers[i].Member.Metadata) + s.Assert().Equal(members[i].Address, loadedMembers[i].Member.Address) + s.Assert().Equal(members[i].Weight, loadedMembers[i].Member.Weight) + s.Assert().Equal(id, loadedMembers[i].GroupId) + } + + // query groups by admin + groupsRes, err := s.queryClient.GroupsByAdmin(s.ctx, &group.QueryGroupsByAdminRequest{Admin: s.addr1.String()}) + s.Require().NoError(err) + loadedGroups := groupsRes.Groups + s.Require().Equal(len(spec.expGroups), len(loadedGroups)) + for i := range loadedGroups { + s.Assert().Equal(spec.expGroups[i].Metadata, loadedGroups[i].Metadata) + s.Assert().Equal(spec.expGroups[i].Admin, loadedGroups[i].Admin) + s.Assert().Equal(spec.expGroups[i].TotalWeight, loadedGroups[i].TotalWeight) + s.Assert().Equal(spec.expGroups[i].GroupId, loadedGroups[i].GroupId) + s.Assert().Equal(spec.expGroups[i].Version, loadedGroups[i].Version) + } + }) + } +} + +func (s *IntegrationTestSuite) TestUpdateGroupAdmin() { + members := []group.Member{{ + Address: s.addr1.String(), + Weight: "1", + Metadata: nil, + }} + oldAdmin := s.addr2.String() + newAdmin := s.addr3.String() + groupRes, err := s.msgClient.CreateGroup(s.ctx, &group.MsgCreateGroupRequest{ + Admin: oldAdmin, + Members: members, + Metadata: nil, + }) + s.Require().NoError(err) + groupID := groupRes.GroupId + + specs := map[string]struct { + req *group.MsgUpdateGroupAdminRequest + expStored *group.GroupInfo + expErr bool + }{ + "with correct admin": { + req: &group.MsgUpdateGroupAdminRequest{ + GroupId: groupID, + Admin: oldAdmin, + NewAdmin: newAdmin, + }, + expStored: &group.GroupInfo{ + GroupId: groupID, + Admin: newAdmin, + Metadata: nil, + TotalWeight: "1", + Version: 2, + }, + }, + "with wrong admin": { + req: &group.MsgUpdateGroupAdminRequest{ + GroupId: groupID, + Admin: s.addr4.String(), + NewAdmin: newAdmin, + }, + expErr: true, + expStored: &group.GroupInfo{ + GroupId: groupID, + Admin: oldAdmin, + Metadata: nil, + TotalWeight: "1", + Version: 1, + }, + }, + "with unknown groupID": { + req: &group.MsgUpdateGroupAdminRequest{ + GroupId: 999, + Admin: oldAdmin, + NewAdmin: newAdmin, + }, + expErr: true, + expStored: &group.GroupInfo{ + GroupId: groupID, + Admin: oldAdmin, + Metadata: nil, + TotalWeight: "1", + Version: 1, + }, + }, + } + for msg, spec := range specs { + spec := spec + s.Run(msg, func() { + _, err := s.msgClient.UpdateGroupAdmin(s.ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + + // then + res, err := s.queryClient.GroupInfo(s.ctx, &group.QueryGroupInfoRequest{GroupId: groupID}) + s.Require().NoError(err) + s.Assert().Equal(spec.expStored, res.Info) + }) + } +} + +func (s *IntegrationTestSuite) TestUpdateGroupMetadata() { + oldAdmin := s.addr1.String() + groupID := s.groupID + + specs := map[string]struct { + req *group.MsgUpdateGroupMetadataRequest + expErr bool + expStored *group.GroupInfo + }{ + "with correct admin": { + req: &group.MsgUpdateGroupMetadataRequest{ + GroupId: groupID, + Admin: oldAdmin, + Metadata: []byte{1, 2, 3}, + }, + expStored: &group.GroupInfo{ + GroupId: groupID, + Admin: oldAdmin, + Metadata: []byte{1, 2, 3}, + TotalWeight: "1", + Version: 2, + }, + }, + "with wrong admin": { + req: &group.MsgUpdateGroupMetadataRequest{ + GroupId: groupID, + Admin: s.addr3.String(), + Metadata: []byte{1, 2, 3}, + }, + expErr: true, + expStored: &group.GroupInfo{ + GroupId: groupID, + Admin: oldAdmin, + Metadata: nil, + TotalWeight: "1", + Version: 1, + }, + }, + "with unknown groupid": { + req: &group.MsgUpdateGroupMetadataRequest{ + GroupId: 999, + Admin: oldAdmin, + Metadata: []byte{1, 2, 3}, + }, + expErr: true, + expStored: &group.GroupInfo{ + GroupId: groupID, + Admin: oldAdmin, + Metadata: nil, + TotalWeight: "1", + Version: 1, + }, + }, + } + for msg, spec := range specs { + spec := spec + s.Run(msg, func() { + sdkCtx, _ := s.sdkCtx.CacheContext() + ctx := types.Context{Context: sdkCtx} + _, err := s.msgClient.UpdateGroupMetadata(ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + + // then + res, err := s.queryClient.GroupInfo(ctx, &group.QueryGroupInfoRequest{GroupId: groupID}) + s.Require().NoError(err) + s.Assert().Equal(spec.expStored, res.Info) + }) + } +} + +func (s *IntegrationTestSuite) TestUpdateGroupMembers() { + member1 := s.addr5.String() + member2 := s.addr6.String() + members := []group.Member{{ + Address: member1, + Weight: "1", + Metadata: nil, + }} + + myAdmin := s.addr4.String() + groupRes, err := s.msgClient.CreateGroup(s.ctx, &group.MsgCreateGroupRequest{ + Admin: myAdmin, + Members: members, + Metadata: nil, + }) + s.Require().NoError(err) + groupID := groupRes.GroupId + + specs := map[string]struct { + req *group.MsgUpdateGroupMembersRequest + expErr bool + expGroup *group.GroupInfo + expMembers []*group.GroupMember + }{ + "add new member": { + req: &group.MsgUpdateGroupMembersRequest{ + GroupId: groupID, + Admin: myAdmin, + MemberUpdates: []group.Member{{ + Address: member2, + Weight: "2", + Metadata: nil, + }}, + }, + expGroup: &group.GroupInfo{ + GroupId: groupID, + Admin: myAdmin, + Metadata: nil, + TotalWeight: "3", + Version: 2, + }, + expMembers: []*group.GroupMember{ + { + Member: &group.Member{ + Address: member2, + Weight: "2", + Metadata: nil, + }, + GroupId: groupID, + }, + { + Member: &group.Member{ + Address: member1, + Weight: "1", + Metadata: nil, + }, + GroupId: groupID, + }, + }, + }, + "update member": { + req: &group.MsgUpdateGroupMembersRequest{ + GroupId: groupID, + Admin: myAdmin, + MemberUpdates: []group.Member{{ + Address: member1, + Weight: "2", + Metadata: []byte{1, 2, 3}, + }}, + }, + expGroup: &group.GroupInfo{ + GroupId: groupID, + Admin: myAdmin, + Metadata: nil, + TotalWeight: "2", + Version: 2, + }, + expMembers: []*group.GroupMember{ + { + GroupId: groupID, + Member: &group.Member{ + Address: member1, + Weight: "2", + Metadata: []byte{1, 2, 3}, + }, + }, + }, + }, + "update member with same data": { + req: &group.MsgUpdateGroupMembersRequest{ + GroupId: groupID, + Admin: myAdmin, + MemberUpdates: []group.Member{{ + Address: member1, + Weight: "1", + }}, + }, + expGroup: &group.GroupInfo{ + GroupId: groupID, + Admin: myAdmin, + Metadata: nil, + TotalWeight: "1", + Version: 2, + }, + expMembers: []*group.GroupMember{ + { + GroupId: groupID, + Member: &group.Member{ + Address: member1, + Weight: "1", + }, + }, + }, + }, + "replace member": { + req: &group.MsgUpdateGroupMembersRequest{ + GroupId: groupID, + Admin: myAdmin, + MemberUpdates: []group.Member{ + { + Address: member1, + Weight: "0", + Metadata: nil, + }, + { + Address: member2, + Weight: "1", + Metadata: nil, + }, + }, + }, + expGroup: &group.GroupInfo{ + GroupId: groupID, + Admin: myAdmin, + Metadata: nil, + TotalWeight: "1", + Version: 2, + }, + expMembers: []*group.GroupMember{{ + GroupId: groupID, + Member: &group.Member{ + Address: member2, + Weight: "1", + Metadata: nil, + }, + }}, + }, + "remove existing member": { + req: &group.MsgUpdateGroupMembersRequest{ + GroupId: groupID, + Admin: myAdmin, + MemberUpdates: []group.Member{{ + Address: member1, + Weight: "0", + Metadata: nil, + }}, + }, + expGroup: &group.GroupInfo{ + GroupId: groupID, + Admin: myAdmin, + Metadata: nil, + TotalWeight: "0", + Version: 2, + }, + expMembers: []*group.GroupMember{}, + }, + "remove unknown member": { + req: &group.MsgUpdateGroupMembersRequest{ + GroupId: groupID, + Admin: myAdmin, + MemberUpdates: []group.Member{{ + Address: s.addr4.String(), + Weight: "0", + Metadata: nil, + }}, + }, + expErr: true, + expGroup: &group.GroupInfo{ + GroupId: groupID, + Admin: myAdmin, + Metadata: nil, + TotalWeight: "1", + Version: 1, + }, + expMembers: []*group.GroupMember{{ + GroupId: groupID, + Member: &group.Member{ + Address: member1, + Weight: "1", + Metadata: nil, + }, + }}, + }, + "with wrong admin": { + req: &group.MsgUpdateGroupMembersRequest{ + GroupId: groupID, + Admin: s.addr3.String(), + MemberUpdates: []group.Member{{ + Address: member1, + Weight: "2", + Metadata: nil, + }}, + }, + expErr: true, + expGroup: &group.GroupInfo{ + GroupId: groupID, + Admin: myAdmin, + Metadata: nil, + TotalWeight: "1", + Version: 1, + }, + expMembers: []*group.GroupMember{{ + GroupId: groupID, + Member: &group.Member{ + Address: member1, + Weight: "1", + }, + }}, + }, + "with unknown groupID": { + req: &group.MsgUpdateGroupMembersRequest{ + GroupId: 999, + Admin: myAdmin, + MemberUpdates: []group.Member{{ + Address: member1, + Weight: "2", + Metadata: nil, + }}, + }, + expErr: true, + expGroup: &group.GroupInfo{ + GroupId: groupID, + Admin: myAdmin, + Metadata: nil, + TotalWeight: "1", + Version: 1, + }, + expMembers: []*group.GroupMember{{ + GroupId: groupID, + Member: &group.Member{ + Address: member1, + Weight: "1", + }, + }}, + }, + } + for msg, spec := range specs { + spec := spec + s.Run(msg, func() { + sdkCtx, _ := s.sdkCtx.CacheContext() + ctx := types.Context{Context: sdkCtx} + _, err := s.msgClient.UpdateGroupMembers(ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + + // then + res, err := s.queryClient.GroupInfo(ctx, &group.QueryGroupInfoRequest{GroupId: groupID}) + s.Require().NoError(err) + s.Assert().Equal(spec.expGroup, res.Info) + + // and members persisted + membersRes, err := s.queryClient.GroupMembers(ctx, &group.QueryGroupMembersRequest{GroupId: groupID}) + s.Require().NoError(err) + loadedMembers := membersRes.Members + s.Require().Equal(len(spec.expMembers), len(loadedMembers)) + // we reorder group members by address to be able to compare them + sort.Slice(spec.expMembers, func(i, j int) bool { + return spec.expMembers[i].Member.Address < spec.expMembers[j].Member.Address + }) + for i := range loadedMembers { + s.Assert().Equal(spec.expMembers[i].Member.Metadata, loadedMembers[i].Member.Metadata) + s.Assert().Equal(spec.expMembers[i].Member.Address, loadedMembers[i].Member.Address) + s.Assert().Equal(spec.expMembers[i].Member.Weight, loadedMembers[i].Member.Weight) + s.Assert().Equal(spec.expMembers[i].GroupId, loadedMembers[i].GroupId) + } + }) + } +} + +func (s *IntegrationTestSuite) TestCreateGroupAccount() { + groupRes, err := s.msgClient.CreateGroup(s.ctx, &group.MsgCreateGroupRequest{ + Admin: s.addr1.String(), + Members: nil, + Metadata: nil, + }) + s.Require().NoError(err) + myGroupID := groupRes.GroupId + + specs := map[string]struct { + req *group.MsgCreateGroupAccountRequest + policy group.DecisionPolicy + expErr bool + }{ + "all good": { + req: &group.MsgCreateGroupAccountRequest{ + Admin: s.addr1.String(), + Metadata: nil, + GroupId: myGroupID, + }, + policy: group.NewThresholdDecisionPolicy( + "1", + gogotypes.Duration{Seconds: 1}, + ), + }, + "decision policy threshold > total group weight": { + req: &group.MsgCreateGroupAccountRequest{ + Admin: s.addr1.String(), + Metadata: nil, + GroupId: myGroupID, + }, + policy: group.NewThresholdDecisionPolicy( + "10", + gogotypes.Duration{Seconds: 1}, + ), + }, + "group id does not exists": { + req: &group.MsgCreateGroupAccountRequest{ + Admin: s.addr1.String(), + Metadata: nil, + GroupId: 9999, + }, + policy: group.NewThresholdDecisionPolicy( + "1", + gogotypes.Duration{Seconds: 1}, + ), + expErr: true, + }, + "admin not group admin": { + req: &group.MsgCreateGroupAccountRequest{ + Admin: s.addr4.String(), + Metadata: nil, + GroupId: myGroupID, + }, + policy: group.NewThresholdDecisionPolicy( + "1", + gogotypes.Duration{Seconds: 1}, + ), + expErr: true, + }, + "metadata too long": { + req: &group.MsgCreateGroupAccountRequest{ + Admin: s.addr1.String(), + Metadata: []byte(strings.Repeat("a", 256)), + GroupId: myGroupID, + }, + policy: group.NewThresholdDecisionPolicy( + "1", + gogotypes.Duration{Seconds: 1}, + ), + expErr: true, + }, + } + + for msg, spec := range specs { + spec := spec + s.Run(msg, func() { + err := spec.req.SetDecisionPolicy(spec.policy) + s.Require().NoError(err) + + res, err := s.msgClient.CreateGroupAccount(s.ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + addr := res.Address + + // then all data persisted + groupAccountRes, err := s.queryClient.GroupAccountInfo(s.ctx, &group.QueryGroupAccountInfoRequest{Address: addr}) + s.Require().NoError(err) + + groupAccount := groupAccountRes.Info + s.Assert().Equal(addr, groupAccount.Address) + s.Assert().Equal(myGroupID, groupAccount.GroupId) + s.Assert().Equal(spec.req.Admin, groupAccount.Admin) + s.Assert().Equal(spec.req.Metadata, groupAccount.Metadata) + s.Assert().Equal(uint64(1), groupAccount.Version) + s.Assert().Equal(spec.policy.(*group.ThresholdDecisionPolicy), groupAccount.GetDecisionPolicy()) + }) + } +} + +func (s *IntegrationTestSuite) TestUpdateGroupAccountAdmin() { + admin, newAdmin := s.addr1, s.addr2 + groupAccountAddr, myGroupID, policy := createGroupAndGroupAccount(admin, s) + + specs := map[string]struct { + req *group.MsgUpdateGroupAccountAdminRequest + expGroupAccount *group.GroupAccountInfo + expErr bool + }{ + "with wrong admin": { + req: &group.MsgUpdateGroupAccountAdminRequest{ + Admin: s.addr5.String(), + Address: groupAccountAddr, + NewAdmin: newAdmin.String(), + }, + expGroupAccount: &group.GroupAccountInfo{ + Admin: admin.String(), + Address: groupAccountAddr, + GroupId: myGroupID, + Metadata: nil, + Version: 2, + DecisionPolicy: nil, + }, + expErr: true, + }, + "with wrong group account": { + req: &group.MsgUpdateGroupAccountAdminRequest{ + Admin: admin.String(), + Address: s.addr5.String(), + NewAdmin: newAdmin.String(), + }, + expGroupAccount: &group.GroupAccountInfo{ + Admin: admin.String(), + Address: groupAccountAddr, + GroupId: myGroupID, + Metadata: nil, + Version: 2, + DecisionPolicy: nil, + }, + expErr: true, + }, + "correct data": { + req: &group.MsgUpdateGroupAccountAdminRequest{ + Admin: admin.String(), + Address: groupAccountAddr, + NewAdmin: newAdmin.String(), + }, + expGroupAccount: &group.GroupAccountInfo{ + Admin: newAdmin.String(), + Address: groupAccountAddr, + GroupId: myGroupID, + Metadata: nil, + Version: 2, + DecisionPolicy: nil, + }, + expErr: false, + }, + } + + for msg, spec := range specs { + spec := spec + err := spec.expGroupAccount.SetDecisionPolicy(policy) + s.Require().NoError(err) + + s.Run(msg, func() { + _, err := s.msgClient.UpdateGroupAccountAdmin(s.ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + res, err := s.queryClient.GroupAccountInfo(s.ctx, &group.QueryGroupAccountInfoRequest{ + Address: groupAccountAddr, + }) + s.Require().NoError(err) + s.Assert().Equal(spec.expGroupAccount, res.Info) + }) + } +} + +func (s *IntegrationTestSuite) TestUpdateGroupAccountMetadata() { + admin := s.addr1 + groupAccountAddr, myGroupID, policy := createGroupAndGroupAccount(admin, s) + + specs := map[string]struct { + req *group.MsgUpdateGroupAccountMetadataRequest + expGroupAccount *group.GroupAccountInfo + expErr bool + }{ + "with wrong admin": { + req: &group.MsgUpdateGroupAccountMetadataRequest{ + Admin: s.addr5.String(), + Address: groupAccountAddr, + Metadata: []byte("hello"), + }, + expGroupAccount: &group.GroupAccountInfo{}, + expErr: true, + }, + "with wrong group account": { + req: &group.MsgUpdateGroupAccountMetadataRequest{ + Admin: admin.String(), + Address: s.addr5.String(), + Metadata: []byte("hello"), + }, + expGroupAccount: &group.GroupAccountInfo{}, + expErr: true, + }, + "with comment too long": { + req: &group.MsgUpdateGroupAccountMetadataRequest{ + Admin: admin.String(), + Address: s.addr5.String(), + Metadata: []byte(strings.Repeat("a", 256)), + }, + expGroupAccount: &group.GroupAccountInfo{}, + expErr: true, + }, + "correct data": { + req: &group.MsgUpdateGroupAccountMetadataRequest{ + Admin: admin.String(), + Address: groupAccountAddr, + Metadata: []byte("hello"), + }, + expGroupAccount: &group.GroupAccountInfo{ + Admin: admin.String(), + Address: groupAccountAddr, + GroupId: myGroupID, + Metadata: []byte("hello"), + Version: 2, + DecisionPolicy: nil, + }, + expErr: false, + }, + } + + for msg, spec := range specs { + spec := spec + err := spec.expGroupAccount.SetDecisionPolicy(policy) + s.Require().NoError(err) + + s.Run(msg, func() { + _, err := s.msgClient.UpdateGroupAccountMetadata(s.ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + res, err := s.queryClient.GroupAccountInfo(s.ctx, &group.QueryGroupAccountInfoRequest{ + Address: groupAccountAddr, + }) + s.Require().NoError(err) + s.Assert().Equal(spec.expGroupAccount, res.Info) + }) + } +} + +func (s *IntegrationTestSuite) TestUpdateGroupAccountDecisionPolicy() { + admin := s.addr1 + groupAccountAddr, myGroupID, policy := createGroupAndGroupAccount(admin, s) + + specs := map[string]struct { + req *group.MsgUpdateGroupAccountDecisionPolicyRequest + policy group.DecisionPolicy + expGroupAccount *group.GroupAccountInfo + expErr bool + }{ + "with wrong admin": { + req: &group.MsgUpdateGroupAccountDecisionPolicyRequest{ + Admin: s.addr5.String(), + Address: groupAccountAddr, + }, + policy: policy, + expGroupAccount: &group.GroupAccountInfo{}, + expErr: true, + }, + "with wrong group account": { + req: &group.MsgUpdateGroupAccountDecisionPolicyRequest{ + Admin: admin.String(), + Address: s.addr5.String(), + }, + policy: policy, + expGroupAccount: &group.GroupAccountInfo{}, + expErr: true, + }, + "correct data": { + req: &group.MsgUpdateGroupAccountDecisionPolicyRequest{ + Admin: admin.String(), + Address: groupAccountAddr, + }, + policy: group.NewThresholdDecisionPolicy( + "2", + gogotypes.Duration{Seconds: 2}, + ), + expGroupAccount: &group.GroupAccountInfo{ + Admin: admin.String(), + Address: groupAccountAddr, + GroupId: myGroupID, + Metadata: nil, + Version: 2, + DecisionPolicy: nil, + }, + expErr: false, + }, + } + + for msg, spec := range specs { + spec := spec + err := spec.expGroupAccount.SetDecisionPolicy(spec.policy) + s.Require().NoError(err) + + err = spec.req.SetDecisionPolicy(spec.policy) + s.Require().NoError(err) + + s.Run(msg, func() { + _, err := s.msgClient.UpdateGroupAccountDecisionPolicy(s.ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + res, err := s.queryClient.GroupAccountInfo(s.ctx, &group.QueryGroupAccountInfoRequest{ + Address: groupAccountAddr, + }) + s.Require().NoError(err) + s.Assert().Equal(spec.expGroupAccount, res.Info) + }) + } +} + +func (s *IntegrationTestSuite) TestGroupAccountsByAdminOrGroup() { + admin := s.addr2 + groupRes, err := s.msgClient.CreateGroup(s.ctx, &group.MsgCreateGroupRequest{ + Admin: admin.String(), + Members: nil, + Metadata: nil, + }) + s.Require().NoError(err) + myGroupID := groupRes.GroupId + + policies := []group.DecisionPolicy{ + group.NewThresholdDecisionPolicy( + "1", + gogotypes.Duration{Seconds: 1}, + ), + group.NewThresholdDecisionPolicy( + "10", + gogotypes.Duration{Seconds: 1}, + ), + } + + count := 2 + expectAccs := make([]*group.GroupAccountInfo, count) + for i := range expectAccs { + req := &group.MsgCreateGroupAccountRequest{ + Admin: admin.String(), + Metadata: nil, + GroupId: myGroupID, + } + err := req.SetDecisionPolicy(policies[i]) + s.Require().NoError(err) + res, err := s.msgClient.CreateGroupAccount(s.ctx, req) + s.Require().NoError(err) + + expectAcc := &group.GroupAccountInfo{ + Address: res.Address, + Admin: admin.String(), + Metadata: nil, + GroupId: myGroupID, + Version: uint64(1), + } + err = expectAcc.SetDecisionPolicy(policies[i]) + s.Require().NoError(err) + expectAccs[i] = expectAcc + } + sort.Slice(expectAccs, func(i, j int) bool { return expectAccs[i].Address < expectAccs[j].Address }) + + // query group account by group + accountsByGroupRes, err := s.queryClient.GroupAccountsByGroup(s.ctx, &group.QueryGroupAccountsByGroupRequest{ + GroupId: myGroupID, + }) + s.Require().NoError(err) + accounts := accountsByGroupRes.GroupAccounts + s.Require().Equal(len(accounts), count) + // we reorder accounts by address to be able to compare them + sort.Slice(accounts, func(i, j int) bool { return accounts[i].Address < accounts[j].Address }) + for i := range accounts { + s.Assert().Equal(accounts[i].Address, expectAccs[i].Address) + s.Assert().Equal(accounts[i].GroupId, expectAccs[i].GroupId) + s.Assert().Equal(accounts[i].Admin, expectAccs[i].Admin) + s.Assert().Equal(accounts[i].Metadata, expectAccs[i].Metadata) + s.Assert().Equal(accounts[i].Version, expectAccs[i].Version) + s.Assert().Equal(accounts[i].GetDecisionPolicy(), expectAccs[i].GetDecisionPolicy()) + } + + // query group account by admin + accountsByAdminRes, err := s.queryClient.GroupAccountsByAdmin(s.ctx, &group.QueryGroupAccountsByAdminRequest{ + Admin: admin.String(), + }) + s.Require().NoError(err) + accounts = accountsByAdminRes.GroupAccounts + s.Require().Equal(len(accounts), count) + // we reorder accounts by address to be able to compare them + sort.Slice(accounts, func(i, j int) bool { return accounts[i].Address < accounts[j].Address }) + for i := range accounts { + s.Assert().Equal(accounts[i].Address, expectAccs[i].Address) + s.Assert().Equal(accounts[i].GroupId, expectAccs[i].GroupId) + s.Assert().Equal(accounts[i].Admin, expectAccs[i].Admin) + s.Assert().Equal(accounts[i].Metadata, expectAccs[i].Metadata) + s.Assert().Equal(accounts[i].Version, expectAccs[i].Version) + s.Assert().Equal(accounts[i].GetDecisionPolicy(), expectAccs[i].GetDecisionPolicy()) + } +} + +func (s *IntegrationTestSuite) TestCreateProposal() { + myGroupID := s.groupID + + accountReq := &group.MsgCreateGroupAccountRequest{ + Admin: s.addr1.String(), + GroupId: myGroupID, + Metadata: nil, + } + accountAddr := s.groupAccountAddr + + policy := group.NewThresholdDecisionPolicy( + "100", + gogotypes.Duration{Seconds: 1}, + ) + err := accountReq.SetDecisionPolicy(policy) + s.Require().NoError(err) + bigThresholdRes, err := s.msgClient.CreateGroupAccount(s.ctx, accountReq) + s.Require().NoError(err) + bigThresholdAddr := bigThresholdRes.Address + + specs := map[string]struct { + req *group.MsgCreateProposalRequest + msgs []sdk.Msg + expErr bool + }{ + "all good with minimal fields set": { + req: &group.MsgCreateProposalRequest{ + Address: accountAddr.String(), + Proposers: []string{s.addr2.String()}, + }, + }, + "all good with good msg payload": { + req: &group.MsgCreateProposalRequest{ + Address: accountAddr.String(), + Proposers: []string{s.addr2.String()}, + }, + msgs: []sdk.Msg{&banktypes.MsgSend{ + FromAddress: accountAddr.String(), + ToAddress: s.addr2.String(), + Amount: sdk.Coins{sdk.NewInt64Coin("token", 100)}, + }}, + }, + "metadata too long": { + req: &group.MsgCreateProposalRequest{ + Address: accountAddr.String(), + Metadata: bytes.Repeat([]byte{1}, 256), + Proposers: []string{s.addr2.String()}, + }, + expErr: true, + }, + "group account required": { + req: &group.MsgCreateProposalRequest{ + Metadata: nil, + Proposers: []string{s.addr2.String()}, + }, + expErr: true, + }, + "existing group account required": { + req: &group.MsgCreateProposalRequest{ + Address: s.addr1.String(), + Proposers: []string{s.addr2.String()}, + }, + expErr: true, + }, + "impossible case: decision policy threshold > total group weight": { + req: &group.MsgCreateProposalRequest{ + Address: bigThresholdAddr, + Proposers: []string{s.addr2.String()}, + }, + expErr: true, + }, + "only group members can create a proposal": { + req: &group.MsgCreateProposalRequest{ + Address: accountAddr.String(), + Proposers: []string{s.addr3.String()}, + }, + expErr: true, + }, + "all proposers must be in group": { + req: &group.MsgCreateProposalRequest{ + Address: accountAddr.String(), + Proposers: []string{s.addr2.String(), s.addr4.String()}, + }, + expErr: true, + }, + "proposers must not be empty": { + req: &group.MsgCreateProposalRequest{ + Address: accountAddr.String(), + Proposers: []string{s.addr2.String(), ""}, + }, + expErr: true, + }, + "admin that is not a group member can not create proposal": { + req: &group.MsgCreateProposalRequest{ + Address: accountAddr.String(), + Metadata: nil, + Proposers: []string{s.addr1.String()}, + }, + expErr: true, + }, + "reject msgs that are not authz by group account": { + req: &group.MsgCreateProposalRequest{ + Address: accountAddr.String(), + Metadata: nil, + Proposers: []string{s.addr2.String()}, + }, + msgs: []sdk.Msg{&testdata.MsgAuthenticated{Signers: []sdk.AccAddress{s.addr1}}}, + expErr: true, + }, + } + for msg, spec := range specs { + spec := spec + s.Run(msg, func() { + err := spec.req.SetMsgs(spec.msgs) + s.Require().NoError(err) + + res, err := s.msgClient.CreateProposal(s.ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + id := res.ProposalId + + // then all data persisted + proposalRes, err := s.queryClient.Proposal(s.ctx, &group.QueryProposalRequest{ProposalId: id}) + s.Require().NoError(err) + proposal := proposalRes.Proposal + + s.Assert().Equal(accountAddr.String(), proposal.Address) + s.Assert().Equal(spec.req.Metadata, proposal.Metadata) + s.Assert().Equal(spec.req.Proposers, proposal.Proposers) + + submittedAt, err := gogotypes.TimestampFromProto(&proposal.SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + + s.Assert().Equal(uint64(1), proposal.GroupVersion) + s.Assert().Equal(uint64(1), proposal.GroupAccountVersion) + s.Assert().Equal(group.ProposalStatusSubmitted, proposal.Status) + s.Assert().Equal(group.ProposalResultUnfinalized, proposal.Result) + s.Assert().Equal(group.Tally{ + YesCount: "0", + NoCount: "0", + AbstainCount: "0", + VetoCount: "0", + }, proposal.VoteState) + + timeout, err := gogotypes.TimestampFromProto(&proposal.Timeout) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime.Add(time.Second), timeout) + + if spec.msgs == nil { // then empty list is ok + s.Assert().Len(proposal.GetMsgs(), 0) + } else { + s.Assert().Equal(spec.msgs, proposal.GetMsgs()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestVote() { + members := []group.Member{ + {Address: s.addr2.String(), Weight: "1"}, + {Address: s.addr3.String(), Weight: "2"}, + } + groupRes, err := s.msgClient.CreateGroup(s.ctx, &group.MsgCreateGroupRequest{ + Admin: s.addr1.String(), + Members: members, + Metadata: nil, + }) + s.Require().NoError(err) + myGroupID := groupRes.GroupId + + policy := group.NewThresholdDecisionPolicy( + "2", + gogotypes.Duration{Seconds: 1}, + ) + accountReq := &group.MsgCreateGroupAccountRequest{ + Admin: s.addr1.String(), + GroupId: myGroupID, + Metadata: nil, + } + err = accountReq.SetDecisionPolicy(policy) + s.Require().NoError(err) + accountRes, err := s.msgClient.CreateGroupAccount(s.ctx, accountReq) + s.Require().NoError(err) + accountAddr := accountRes.Address + groupAccount, err := sdk.AccAddressFromBech32(accountAddr) + s.Require().NoError(err) + s.Require().NotNil(groupAccount) + + req := &group.MsgCreateProposalRequest{ + Address: accountAddr, + Metadata: nil, + Proposers: []string{s.addr2.String()}, + Msgs: nil, + } + proposalRes, err := s.msgClient.CreateProposal(s.ctx, req) + s.Require().NoError(err) + myProposalID := proposalRes.ProposalId + + // proposals by group account + proposalsRes, err := s.queryClient.ProposalsByGroupAccount(s.ctx, &group.QueryProposalsByGroupAccountRequest{ + Address: accountAddr, + }) + s.Require().NoError(err) + proposals := proposalsRes.Proposals + s.Require().Equal(len(proposals), 1) + s.Assert().Equal(req.Address, proposals[0].Address) + s.Assert().Equal(req.Metadata, proposals[0].Metadata) + s.Assert().Equal(req.Proposers, proposals[0].Proposers) + + submittedAt, err := gogotypes.TimestampFromProto(&proposals[0].SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + + s.Assert().Equal(uint64(1), proposals[0].GroupVersion) + s.Assert().Equal(uint64(1), proposals[0].GroupAccountVersion) + s.Assert().Equal(group.ProposalStatusSubmitted, proposals[0].Status) + s.Assert().Equal(group.ProposalResultUnfinalized, proposals[0].Result) + s.Assert().Equal(group.Tally{ + YesCount: "0", + NoCount: "0", + AbstainCount: "0", + VetoCount: "0", + }, proposals[0].VoteState) + + specs := map[string]struct { + req *group.MsgVoteRequest + srcCtx sdk.Context + doBefore func(ctx context.Context) + expErr bool + expVoteState group.Tally + expProposalStatus group.Proposal_Status + expResult group.Proposal_Result + }{ + "vote yes": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr2.String(), + Choice: group.Choice_CHOICE_YES, + }, + expVoteState: group.Tally{ + YesCount: "1", + NoCount: "0", + AbstainCount: "0", + VetoCount: "0", + }, + expProposalStatus: group.ProposalStatusSubmitted, + expResult: group.ProposalResultUnfinalized, + }, + "vote no": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr2.String(), + Choice: group.Choice_CHOICE_NO, + }, + expVoteState: group.Tally{ + YesCount: "0", + NoCount: "1", + AbstainCount: "0", + VetoCount: "0", + }, + expProposalStatus: group.ProposalStatusSubmitted, + expResult: group.ProposalResultUnfinalized, + }, + "vote abstain": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr2.String(), + Choice: group.Choice_CHOICE_ABSTAIN, + }, + expVoteState: group.Tally{ + YesCount: "0", + NoCount: "0", + AbstainCount: "1", + VetoCount: "0", + }, + expProposalStatus: group.ProposalStatusSubmitted, + expResult: group.ProposalResultUnfinalized, + }, + "vote veto": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr2.String(), + Choice: group.Choice_CHOICE_VETO, + }, + expVoteState: group.Tally{ + YesCount: "0", + NoCount: "0", + AbstainCount: "0", + VetoCount: "1", + }, + expProposalStatus: group.ProposalStatusSubmitted, + expResult: group.ProposalResultUnfinalized, + }, + "apply decision policy early": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr3.String(), + Choice: group.Choice_CHOICE_YES, + }, + expVoteState: group.Tally{ + YesCount: "2", + NoCount: "0", + AbstainCount: "0", + VetoCount: "0", + }, + expProposalStatus: group.ProposalStatusClosed, + expResult: group.ProposalResultAccepted, + }, + "reject new votes when final decision is made already": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr2.String(), + Choice: group.Choice_CHOICE_YES, + }, + doBefore: func(ctx context.Context) { + _, err := s.msgClient.Vote(ctx, &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr3.String(), + Choice: group.Choice_CHOICE_VETO, + }) + s.Require().NoError(err) + }, + expErr: true, + }, + "metadata too long": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr2.String(), + Metadata: bytes.Repeat([]byte{1}, 256), + Choice: group.Choice_CHOICE_NO, + }, + expErr: true, + }, + "existing proposal required": { + req: &group.MsgVoteRequest{ + ProposalId: 999, + Voter: s.addr2.String(), + Choice: group.Choice_CHOICE_NO, + }, + expErr: true, + }, + "empty choice": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr2.String(), + }, + expErr: true, + }, + "invalid choice": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr2.String(), + Choice: 5, + }, + expErr: true, + }, + "voter must be in group": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr4.String(), + Choice: group.Choice_CHOICE_NO, + }, + expErr: true, + }, + "voter must not be empty": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: "", + Choice: group.Choice_CHOICE_NO, + }, + expErr: true, + }, + "voters must not be nil": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Choice: group.Choice_CHOICE_NO, + }, + expErr: true, + }, + "admin that is not a group member can not vote": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr1.String(), + Choice: group.Choice_CHOICE_NO, + }, + expErr: true, + }, + "on timeout": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr2.String(), + Choice: group.Choice_CHOICE_NO, + }, + srcCtx: s.sdkCtx.WithBlockTime(s.blockTime.Add(time.Second)), + expErr: true, + }, + "closed already": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr2.String(), + Choice: group.Choice_CHOICE_NO, + }, + doBefore: func(ctx context.Context) { + _, err := s.msgClient.Vote(ctx, &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr3.String(), + Choice: group.Choice_CHOICE_YES, + }) + s.Require().NoError(err) + }, + expErr: true, + }, + "voted already": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr2.String(), + Choice: group.Choice_CHOICE_NO, + }, + doBefore: func(ctx context.Context) { + _, err := s.msgClient.Vote(ctx, &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr2.String(), + Choice: group.Choice_CHOICE_YES, + }) + s.Require().NoError(err) + }, + expErr: true, + }, + "with group modified": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr2.String(), + Choice: group.Choice_CHOICE_NO, + }, + doBefore: func(ctx context.Context) { + _, err = s.msgClient.UpdateGroupMetadata(ctx, &group.MsgUpdateGroupMetadataRequest{ + GroupId: myGroupID, + Admin: s.addr1.String(), + Metadata: []byte{1, 2, 3}, + }) + s.Require().NoError(err) + }, + expErr: true, + }, + "with policy modified": { + req: &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: s.addr2.String(), + Choice: group.Choice_CHOICE_NO, + }, + doBefore: func(ctx context.Context) { + m, err := group.NewMsgUpdateGroupAccountDecisionPolicyRequest( + s.addr1, + groupAccount, + &group.ThresholdDecisionPolicy{ + Threshold: "1", + Timeout: gogotypes.Duration{Seconds: 1}, + }, + ) + s.Require().NoError(err) + + _, err = s.msgClient.UpdateGroupAccountDecisionPolicy(ctx, m) + s.Require().NoError(err) + }, + expErr: true, + }, + } + for msg, spec := range specs { + spec := spec + s.Run(msg, func() { + sdkCtx := s.sdkCtx + if !spec.srcCtx.IsZero() { + sdkCtx = spec.srcCtx + } + sdkCtx, _ = sdkCtx.CacheContext() + ctx := types.Context{Context: sdkCtx} + + if spec.doBefore != nil { + spec.doBefore(ctx) + } + _, err := s.msgClient.Vote(ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + + s.Require().NoError(err) + // vote is stored and all data persisted + res, err := s.queryClient.VoteByProposalVoter(ctx, &group.QueryVoteByProposalVoterRequest{ + ProposalId: spec.req.ProposalId, + Voter: spec.req.Voter, + }) + s.Require().NoError(err) + loaded := res.Vote + s.Assert().Equal(spec.req.ProposalId, loaded.ProposalId) + s.Assert().Equal(spec.req.Voter, loaded.Voter) + s.Assert().Equal(spec.req.Choice, loaded.Choice) + s.Assert().Equal(spec.req.Metadata, loaded.Metadata) + submittedAt, err := gogotypes.TimestampFromProto(&loaded.SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + + // query votes by proposal + votesByProposalRes, err := s.queryClient.VotesByProposal(ctx, &group.QueryVotesByProposalRequest{ + ProposalId: spec.req.ProposalId, + }) + s.Require().NoError(err) + votesByProposal := votesByProposalRes.Votes + s.Require().Equal(1, len(votesByProposal)) + vote := votesByProposal[0] + s.Assert().Equal(spec.req.ProposalId, vote.ProposalId) + s.Assert().Equal(spec.req.Voter, vote.Voter) + s.Assert().Equal(spec.req.Choice, vote.Choice) + s.Assert().Equal(spec.req.Metadata, vote.Metadata) + submittedAt, err = gogotypes.TimestampFromProto(&vote.SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + + // query votes by voter + voter := spec.req.Voter + votesByVoterRes, err := s.queryClient.VotesByVoter(ctx, &group.QueryVotesByVoterRequest{ + Voter: voter, + }) + s.Require().NoError(err) + votesByVoter := votesByVoterRes.Votes + s.Require().Equal(1, len(votesByVoter)) + s.Assert().Equal(spec.req.ProposalId, votesByVoter[0].ProposalId) + s.Assert().Equal(voter, votesByVoter[0].Voter) + s.Assert().Equal(spec.req.Choice, votesByVoter[0].Choice) + s.Assert().Equal(spec.req.Metadata, votesByVoter[0].Metadata) + submittedAt, err = gogotypes.TimestampFromProto(&votesByVoter[0].SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + + // and proposal is updated + proposalRes, err := s.queryClient.Proposal(ctx, &group.QueryProposalRequest{ + ProposalId: spec.req.ProposalId, + }) + s.Require().NoError(err) + proposal := proposalRes.Proposal + s.Assert().Equal(spec.expVoteState, proposal.VoteState) + s.Assert().Equal(spec.expResult, proposal.Result) + s.Assert().Equal(spec.expProposalStatus, proposal.Status) + }) + } +} + +func (s *IntegrationTestSuite) TestDoExecuteMsgs() { + msgSend := &banktypes.MsgSend{ + FromAddress: s.groupAccountAddr.String(), + ToAddress: s.addr2.String(), + Amount: sdk.Coins{sdk.NewInt64Coin("test", 100)}, + } + + unauthzMsgSend := &banktypes.MsgSend{ + FromAddress: s.addr1.String(), + ToAddress: s.addr2.String(), + Amount: sdk.Coins{sdk.NewInt64Coin("test", 100)}, + } + + specs := map[string]struct { + srcMsgs []sdk.Msg + srcHandler sdk.Handler + expErr bool + }{ + "all good": { + srcMsgs: []sdk.Msg{msgSend}, + }, + "not authz by group account": { + srcMsgs: []sdk.Msg{unauthzMsgSend}, + expErr: true, + }, + "mixed group account msgs": { + srcMsgs: []sdk.Msg{ + msgSend, + unauthzMsgSend, + }, + expErr: true, + }, + "no handler": { + srcMsgs: []sdk.Msg{&testdata.MsgAuthenticated{Signers: []sdk.AccAddress{s.groupAccountAddr}}}, + expErr: true, + }, + "not panic on nil result": { + srcMsgs: []sdk.Msg{&testdata.MsgAuthenticated{Signers: []sdk.AccAddress{s.groupAccountAddr}}}, + srcHandler: func(ctx sdk.Context, msg sdk.Msg) (result *sdk.Result, err error) { + return nil, nil + }, + }, + } + for msg, spec := range specs { + spec := spec + s.Run(msg, func() { + ctx, _ := s.sdkCtx.CacheContext() + + var router sdk.Router + if spec.srcHandler != nil { + router = baseapp.NewRouter().AddRoute(sdk.NewRoute("MsgAuthenticated", spec.srcHandler)) + } else { + router = baseapp.NewRouter().AddRoute(sdk.NewRoute(banktypes.ModuleName, bank.NewHandler(s.bankKeeper))) + } + _, err := groupserver.DoExecuteMsgs(ctx, router, s.groupAccountAddr, spec.srcMsgs) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + }) + } +} + +func (s *IntegrationTestSuite) TestExecProposal() { + msgSend := &banktypes.MsgSend{ + FromAddress: s.groupAccountAddr.String(), + ToAddress: s.addr2.String(), + Amount: sdk.Coins{sdk.NewInt64Coin("test", 100)}, + } + proposers := []string{s.addr2.String()} + + specs := map[string]struct { + srcBlockTime time.Time + setupProposal func(ctx context.Context) uint64 + expErr bool + expProposalStatus group.Proposal_Status + expProposalResult group.Proposal_Result + expExecutorResult group.Proposal_ExecutorResult + expFromBalances sdk.Coins + expToBalances sdk.Coins + }{ + "proposal executed when accepted": { + setupProposal: func(ctx context.Context) uint64 { + msgs := []sdk.Msg{msgSend} + return createProposalAndVote(ctx, s, msgs, proposers, group.Choice_CHOICE_YES) + }, + expProposalStatus: group.ProposalStatusClosed, + expProposalResult: group.ProposalResultAccepted, + expExecutorResult: group.ProposalExecutorResultSuccess, + expFromBalances: sdk.Coins{sdk.NewInt64Coin("test", 9900)}, + expToBalances: sdk.Coins{sdk.NewInt64Coin("test", 100)}, + }, + "proposal with multiple messages executed when accepted": { + setupProposal: func(ctx context.Context) uint64 { + msgs := []sdk.Msg{msgSend, msgSend} + return createProposalAndVote(ctx, s, msgs, proposers, group.Choice_CHOICE_YES) + }, + expProposalStatus: group.ProposalStatusClosed, + expProposalResult: group.ProposalResultAccepted, + expExecutorResult: group.ProposalExecutorResultSuccess, + expFromBalances: sdk.Coins{sdk.NewInt64Coin("test", 9800)}, + expToBalances: sdk.Coins{sdk.NewInt64Coin("test", 200)}, + }, + "proposal not executed when rejected": { + setupProposal: func(ctx context.Context) uint64 { + msgs := []sdk.Msg{msgSend} + return createProposalAndVote(ctx, s, msgs, proposers, group.Choice_CHOICE_NO) + }, + expProposalStatus: group.ProposalStatusClosed, + expProposalResult: group.ProposalResultRejected, + expExecutorResult: group.ProposalExecutorResultNotRun, + }, + "open proposal must not fail": { + setupProposal: func(ctx context.Context) uint64 { + return createProposal(ctx, s, []sdk.Msg{msgSend}, proposers) + }, + expProposalStatus: group.ProposalStatusSubmitted, + expProposalResult: group.ProposalResultUnfinalized, + expExecutorResult: group.ProposalExecutorResultNotRun, + }, + "existing proposal required": { + setupProposal: func(ctx context.Context) uint64 { + return 9999 + }, + expErr: true, + }, + "Decision policy also applied on timeout": { + setupProposal: func(ctx context.Context) uint64 { + msgs := []sdk.Msg{msgSend} + return createProposalAndVote(ctx, s, msgs, proposers, group.Choice_CHOICE_NO) + }, + srcBlockTime: s.blockTime.Add(time.Second), + expProposalStatus: group.ProposalStatusClosed, + expProposalResult: group.ProposalResultRejected, + expExecutorResult: group.ProposalExecutorResultNotRun, + }, + "Decision policy also applied after timeout": { + setupProposal: func(ctx context.Context) uint64 { + msgs := []sdk.Msg{msgSend} + return createProposalAndVote(ctx, s, msgs, proposers, group.Choice_CHOICE_NO) + }, + srcBlockTime: s.blockTime.Add(time.Second).Add(time.Millisecond), + expProposalStatus: group.ProposalStatusClosed, + expProposalResult: group.ProposalResultRejected, + expExecutorResult: group.ProposalExecutorResultNotRun, + }, + "with group modified before tally": { + setupProposal: func(ctx context.Context) uint64 { + myProposalID := createProposal(ctx, s, []sdk.Msg{msgSend}, proposers) + + // then modify group + _, err := s.msgClient.UpdateGroupMetadata(ctx, &group.MsgUpdateGroupMetadataRequest{ + Admin: s.addr1.String(), + GroupId: s.groupID, + Metadata: []byte{1, 2, 3}, + }) + s.Require().NoError(err) + return myProposalID + }, + expProposalStatus: group.ProposalStatusAborted, + expProposalResult: group.ProposalResultUnfinalized, + expExecutorResult: group.ProposalExecutorResultNotRun, + }, + "with group account modified before tally": { + setupProposal: func(ctx context.Context) uint64 { + myProposalID := createProposal(ctx, s, []sdk.Msg{msgSend}, proposers) + _, err := s.msgClient.UpdateGroupAccountMetadata(ctx, &group.MsgUpdateGroupAccountMetadataRequest{ + Admin: s.addr1.String(), + Address: s.groupAccountAddr.String(), + Metadata: []byte("group account modified before tally"), + }) + s.Require().NoError(err) + return myProposalID + }, + expProposalStatus: group.ProposalStatusAborted, + expProposalResult: group.ProposalResultUnfinalized, + expExecutorResult: group.ProposalExecutorResultNotRun, + }, + "prevent double execution when successful": { + setupProposal: func(ctx context.Context) uint64 { + myProposalID := createProposalAndVote(ctx, s, []sdk.Msg{msgSend}, proposers, group.Choice_CHOICE_YES) + + _, err := s.msgClient.Exec(ctx, &group.MsgExecRequest{Signer: s.addr1.String(), ProposalId: myProposalID}) + s.Require().NoError(err) + return myProposalID + }, + expProposalStatus: group.ProposalStatusClosed, + expProposalResult: group.ProposalResultAccepted, + expExecutorResult: group.ProposalExecutorResultSuccess, + expFromBalances: sdk.Coins{sdk.NewInt64Coin("test", 9900)}, + expToBalances: sdk.Coins{sdk.NewInt64Coin("test", 100)}, + }, + "rollback all msg updates on failure": { + setupProposal: func(ctx context.Context) uint64 { + msgs := []sdk.Msg{ + msgSend, &banktypes.MsgSend{ + FromAddress: s.groupAccountAddr.String(), + ToAddress: s.addr2.String(), + Amount: sdk.Coins{sdk.NewInt64Coin("test", 10001)}}, + } + return createProposalAndVote(ctx, s, msgs, proposers, group.Choice_CHOICE_YES) + }, + expProposalStatus: group.ProposalStatusClosed, + expProposalResult: group.ProposalResultAccepted, + expExecutorResult: group.ProposalExecutorResultFailure, + }, + "executable when failed before": { + setupProposal: func(ctx context.Context) uint64 { + msgs := []sdk.Msg{ + &banktypes.MsgSend{ + FromAddress: s.groupAccountAddr.String(), + ToAddress: s.addr2.String(), + Amount: sdk.Coins{sdk.NewInt64Coin("test", 10001)}}, + } + myProposalID := createProposalAndVote(ctx, s, msgs, proposers, group.Choice_CHOICE_YES) + + _, err := s.msgClient.Exec(ctx, &group.MsgExecRequest{Signer: s.addr1.String(), ProposalId: myProposalID}) + s.Require().NoError(err) + s.Require().NoError(s.bankKeeper.SetBalances(ctx.(types.Context).Context, s.groupAccountAddr, sdk.Coins{sdk.NewInt64Coin("test", 10002)})) + return myProposalID + }, + expProposalStatus: group.ProposalStatusClosed, + expProposalResult: group.ProposalResultAccepted, + expExecutorResult: group.ProposalExecutorResultSuccess, + }, + } + for msg, spec := range specs { + spec := spec + s.Run(msg, func() { + sdkCtx, _ := s.sdkCtx.CacheContext() + ctx := types.Context{Context: sdkCtx} + + proposalID := spec.setupProposal(ctx) + + if !spec.srcBlockTime.IsZero() { + sdkCtx = sdkCtx.WithBlockTime(spec.srcBlockTime) + ctx = types.Context{Context: sdkCtx} + } + + _, err := s.msgClient.Exec(ctx, &group.MsgExecRequest{Signer: s.addr1.String(), ProposalId: proposalID}) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + + // and proposal is updated + res, err := s.queryClient.Proposal(ctx, &group.QueryProposalRequest{ProposalId: proposalID}) + s.Require().NoError(err) + proposal := res.Proposal + + exp := group.Proposal_Result_name[int32(spec.expProposalResult)] + got := group.Proposal_Result_name[int32(proposal.Result)] + s.Assert().Equal(exp, got) + + exp = group.Proposal_Status_name[int32(spec.expProposalStatus)] + got = group.Proposal_Status_name[int32(proposal.Status)] + s.Assert().Equal(exp, got) + + exp = group.Proposal_ExecutorResult_name[int32(spec.expExecutorResult)] + got = group.Proposal_ExecutorResult_name[int32(proposal.ExecutorResult)] + s.Assert().Equal(exp, got) + + if spec.expFromBalances != nil { + fromBalances := s.bankKeeper.GetAllBalances(sdkCtx, s.groupAccountAddr) + s.Require().Equal(spec.expFromBalances, fromBalances) + } + if spec.expToBalances != nil { + toBalances := s.bankKeeper.GetAllBalances(sdkCtx, s.addr2) + s.Require().Equal(spec.expToBalances, toBalances) + } + }) + } +} + +func createProposal( + ctx context.Context, s *IntegrationTestSuite, msgs []sdk.Msg, + proposers []string) uint64 { + proposalReq := &group.MsgCreateProposalRequest{ + Address: s.groupAccountAddr.String(), + Proposers: proposers, + Metadata: nil, + } + err := proposalReq.SetMsgs(msgs) + s.Require().NoError(err) + + proposalRes, err := s.msgClient.CreateProposal(ctx, proposalReq) + s.Require().NoError(err) + return proposalRes.ProposalId +} + +func createProposalAndVote( + ctx context.Context, s *IntegrationTestSuite, msgs []sdk.Msg, + proposers []string, choice group.Choice) uint64 { + s.Require().Greater(len(proposers), 0) + myProposalID := createProposal(ctx, s, msgs, proposers) + + _, err := s.msgClient.Vote(ctx, &group.MsgVoteRequest{ + ProposalId: myProposalID, + Voter: proposers[0], + Choice: choice, + }) + s.Require().NoError(err) + return myProposalID +} + +func createGroupAndGroupAccount( + admin sdk.AccAddress, + s *IntegrationTestSuite, +) (string, uint64, group.DecisionPolicy) { + groupRes, err := s.msgClient.CreateGroup(s.ctx, &group.MsgCreateGroupRequest{ + Admin: admin.String(), + Members: nil, + Metadata: nil, + }) + s.Require().NoError(err) + + myGroupID := groupRes.GroupId + groupAccount := &group.MsgCreateGroupAccountRequest{ + Admin: admin.String(), + GroupId: myGroupID, + Metadata: nil, + } + + policy := group.NewThresholdDecisionPolicy( + "1", + gogotypes.Duration{Seconds: 1}, + ) + err = groupAccount.SetDecisionPolicy(policy) + s.Require().NoError(err) + + groupAccountRes, err := s.msgClient.CreateGroupAccount(s.ctx, groupAccount) + s.Require().NoError(err) + + return groupAccountRes.Address, myGroupID, policy +} diff --git a/x/group/spec/01_concepts.md b/x/group/spec/01_concepts.md new file mode 100644 index 0000000000..804a2fce9e --- /dev/null +++ b/x/group/spec/01_concepts.md @@ -0,0 +1,70 @@ + + +# Concepts + +## Group + +A group is simply an aggregation of accounts with associated weights. It is not +an account and doesn't have a balance. It doesn't in and of itself have any +sort of voting or decision weight. It does have an "administrator" which has +the ability to add, remove and update members in the group. Note that a +group account could be an administrator of a group. + +## Group Account + +A group account is an account associated with a group and a decision policy. +Group accounts are abstracted from groups because a single group may have +multiple decision policies for different types of actions. Managing group +membership separately from decision policies results in the least overhead +and keeps membership consistent across different policies. The pattern that +is recommended is to have a single master group account for a given group, +and then to create separate group accounts with different decision policies +and delegate the desired permissions from the master account to +those "sub-accounts" using the `x/authz` module. + +## Decision Policy + +A decision policy is the mechanism by which members of a group can vote on +proposals. + +All decision policies generally would have a minimum and maximum voting window. +The minimum voting window is the minimum amount of time that must pass in order +for a proposal to potentially pass, and it may be set to 0. The maximum voting +window is the maximum time that a proposal may be voted on before it is closed. +Both of these values must be less than a chain-wide max voting window parameter. + +### Threshold decision policy + +A threshold decision policy defines a threshold of yes votes (based on a tally +of voter weights) that must be achieved in order for a proposal to pass. For +this decision policy, abstain and veto are simply treated as no's. + +## Proposal + +Any member of a group can submit a proposal for a group account to decide upon. +A proposal consists of a set of messages that will be executed if the proposal +passes as well as any metadata associated with the proposal. + +## Voting + +There are four choices to choose while voting - yes, no, abstain and veto. Not +all decision policies will support them. Votes can contain some optional metadata. +During the voting window, accounts that have already voted may change their vote. +In the current implementation, the voting window begins as soon as a proposal +is submitted. + +## Executing Proposals + +Proposals will not be automatically executed by the chain in this current design, +but rather a user must submit a `Msg/Exec` transaction to attempt to execute the +proposal based on the current votes and decision policy. A future upgrade could +automate this and have the group account (or a fee granter) pay. + +### Changing Group Membership + +In the current implementation, changing a group's membership (adding or removing members or changing their weight) +will cause all existing proposals for group accounts linked to this group +to be invalidated. They will simply fail if someone calls `Msg/Exec` and will +eventually be garbage collected. \ No newline at end of file diff --git a/x/group/spec/02_state.md b/x/group/spec/02_state.md new file mode 100644 index 0000000000..b9607e22f5 --- /dev/null +++ b/x/group/spec/02_state.md @@ -0,0 +1,104 @@ + + +# State + +The `group` module uses the `orm` package which provides table storage with support for +primary keys and secondary indexes. `orm` also defines `Sequence` which is a persistent unique key generator based on a counter that can be used along with `Table`s. + +Here's the list of tables and associated sequences and indexes stored as part of the `group` module. + +## Group Table + +The `groupTable` stores `GroupInfo`: `0x0 | []byte(GroupId) -> ProtocolBuffer(GroupInfo)`. + +### groupSeq + +The value of `groupSeq` is incremented when creating a new group and corresponds to the new `GroupId`: `0x1 | 0x1 -> BigEndian`. + +The second `0x1` corresponds to the ORM `sequenceStorageKey`. + +### groupByAdminIndex + +`groupByAdminIndex` allows to retrieve groups by admin address: +`0x2 | []byte(group.Admin) | []byte(GroupId) -> []byte()`. + +## Group Member Table + +The `groupMemberTable` stores `GroupMember`s: `0x10 | []byte(GroupId) | []byte(member.Address) -> ProtocolBuffer(GroupMember)`. + +The `groupMemberTable` is a primary key table and its `PrimaryKey` is given by +`[]byte(GroupId) | []byte(member.Address)` which is used by the following indexes. + +### groupMemberByGroupIndex + +`groupMemberByGroupIndex` allows to retrieve group members by group id: +`0x11 | []byte(GroupId) | PrimaryKey | byte(len(PrimaryKey)) -> []byte()`. + +### groupMemberByMemberIndex + +`groupMemberByMemberIndex` allows to retrieve group members by member address: +`0x12 | []byte(member.Address) | PrimaryKey | byte(len(PrimaryKey)) -> []byte()`. + +## Group Account Table + +The `groupAccountTable` stores `GroupAccountInfo`: `0x20 | []byte(Address) -> ProtocolBuffer(GroupAccountInfo)`. + +The `groupAccountTable` is a primary key table and its `PrimaryKey` is given by +`[]byte(Address)` which is used by the following indexes. + +### groupAccountSeq + +The value of `groupAccountSeq` is incremented when creating a new group account and is used to generate the new group account `Address`: +`0x21 | 0x1 -> BigEndian`. + +The second `0x1` corresponds to the ORM `sequenceStorageKey`. + +### groupAccountByGroupIndex + +`groupAccountByGroupIndex` allows to retrieve group accounts by group id: +`0x22 | []byte(GroupId) | PrimaryKey | byte(len(PrimaryKey)) -> []byte()`. + +### groupAccountByAdminIndex + +`groupAccountByAdminIndex` allows to retrieve group accounts by admin address: +`0x23 | []byte(Address) | PrimaryKey | byte(len(PrimaryKey)) -> []byte()`. + +## Proposal Table + +The `proposalTable` stores `Proposal`s: `0x30 | []byte(ProposalId) -> ProtocolBuffer(Proposal)`. + +### proposalSeq + +The value of `proposalSeq` is incremented when creating a new proposal and corresponds to the new `ProposalId`: `0x31 | 0x1 -> BigEndian`. + +The second `0x1` corresponds to the ORM `sequenceStorageKey`. + +### proposalByGroupAccountIndex + +`proposalByGroupAccountIndex` allows to retrieve proposals by group account address: +`0x32 | []byte(account.Address) | []byte(ProposalId) -> []byte()`. + +### proposalByProposerIndex + +`proposalByProposerIndex` allows to retrieve proposals by proposer address: +`0x33 | []byte(proposer.Address) | []byte(ProposalId) -> []byte()`. + +## Vote Table + +The `voteTable` stores `Vote`s: `0x40 | []byte(ProposalId) | []byte(voter.Address) -> ProtocolBuffer(Vote)`. + +The `voteTable` is a primary key table and its `PrimaryKey` is given by +`[]byte(ProposalId) | []byte(voter.Address)` which is used by the following indexes. + +### voteByProposalIndex + +`voteByProposalIndex` allows to retrieve votes by proposal id: +`0x41 | []byte(ProposalId) | PrimaryKey | byte(len(PrimaryKey)) -> []byte()`. + +### voteByVoterIndex + +`voteByVoterIndex` allows to retrieve votes by voter address: +`0x42 | []byte(voter.Address) | PrimaryKey | byte(len(PrimaryKey)) -> []byte()`. + diff --git a/x/group/spec/03_messages.md b/x/group/spec/03_messages.md new file mode 100644 index 0000000000..a83447db49 --- /dev/null +++ b/x/group/spec/03_messages.md @@ -0,0 +1,104 @@ + + +# Msg Service + +## Msg/CreateGroup + +A new group can be created with the `MsgCreateGroupRequest`, which has an admin address, a list of members and some optional metadata bytes. + ++++ https://github.com/regen-network/regen-ledger/blob/24290a0f2b219ac831482006952cb7a11d173ecf/proto/regen/group/v1alpha1/tx.proto#L53-L64 + +It's expecting to fail if metadata length is greater than some `MaxMetadataLength`. + +## Msg/UpdateGroupMembers + +Group members can be updated with the `UpdateGroupMembersRequest`. + ++++ https://github.com/regen-network/regen-ledger/blob/24290a0f2b219ac831482006952cb7a11d173ecf/proto/regen/group/v1alpha1/tx.proto#L73-L85 + +In the list of `MemberUpdates`, an existing member can be removed by setting its weight to 0. + +It's expecting to fail if the signer is not the admin of the group. + +## Msg/UpdateGroupAdmin + +The `UpdateGroupAdminRequest` can be used to update a group admin. + ++++ https://github.com/regen-network/regen-ledger/blob/24290a0f2b219ac831482006952cb7a11d173ecf/proto/regen/group/v1alpha1/tx.proto#L90-L101 + +It's expecting to fail if the signer is not the admin of the group. + +## Msg/UpdateGroupMetadata + +The `UpdateGroupMetadataRequest` can be used to update a group metadata. + ++++ https://github.com/regen-network/regen-ledger/blob/24290a0f2b219ac831482006952cb7a11d173ecf/proto/regen/group/v1alpha1/tx.proto#L106-L117 + +It's expecting to fail if: +- new metadata length is greater than some `MaxMetadataLength`. +- the signer is not the admin of the group. + +## Msg/CreateGroupAccount + +A new group account can be created with the `MsgCreateGroupAccountRequest`, which has an admin address, a group id, a decision policy and some optional metadata bytes. + ++++ https://github.com/regen-network/regen-ledger/blob/24290a0f2b219ac831482006952cb7a11d173ecf/proto/regen/group/v1alpha1/tx.proto#L126-L141 + +It's expecting to fail if metadata length is greater than some `MaxMetadataLength`. + +## Msg/UpdateGroupAccountAdmin + +The `UpdateGroupAccountAdminRequest` can be used to update a group account admin. + ++++ https://github.com/regen-network/regen-ledger/blob/24290a0f2b219ac831482006952cb7a11d173ecf/proto/regen/group/v1alpha1/tx.proto#L150-L161 + +It's expecting to fail if the signer is not the admin of the group account. + +## Msg/UpdateGroupAccountDecisionPolicy + +The `UpdateGroupAccountDecisionPolicyRequest` can be used to update a decision policy. + ++++ https://github.com/regen-network/regen-ledger/blob/24290a0f2b219ac831482006952cb7a11d173ecf/proto/regen/group/v1alpha1/tx.proto#L166-L178 + +It's expecting to fail if the signer is not the admin of the group account. + +## Msg/UpdateGroupAccountMetadata + +The `UpdateGroupAccountMetadataRequest` can be used to update a group account metadata. + ++++ https://github.com/regen-network/regen-ledger/blob/24290a0f2b219ac831482006952cb7a11d173ecf/proto/regen/group/v1alpha1/tx.proto#L183-L194 + +It's expecting to fail if: +- new metadata length is greater than some `MaxMetadataLength`. +- the signer is not the admin of the group. + +## Msg/CreateProposal + +A new group account can be created with the `MsgCreateProposalRequest`, which has a group account address, a list of proposers addresses, a list of messages to execute if the proposal is accepted and some optional metadata bytes. + ++++ https://github.com/regen-network/regen-ledger/blob/24290a0f2b219ac831482006952cb7a11d173ecf/proto/regen/group/v1alpha1/tx.proto#L203-L219 + +It's expecting to fail if metadata length is greater than some `MaxMetadataLength`. + +## Msg/Vote + +A new vote can be created with the `MsgVoteRequest`, given a proposal id, a voter address, a choice (yes, no, veto or abstain) and some optional metadata bytes. + ++++ https://github.com/regen-network/regen-ledger/blob/24290a0f2b219ac831482006952cb7a11d173ecf/proto/regen/group/v1alpha1/tx.proto#L228-L242 + +It's expecting to fail if metadata length is greater than some `MaxMetadataLength`. + +## Msg/Exec + +A proposal can be executed with the `MsgExecRequest`. + ++++ https://github.com/regen-network/regen-ledger/blob/24290a0f2b219ac831482006952cb7a11d173ecf/proto/regen/group/v1alpha1/tx.proto#L247-L255 + +The messages that are part of this proposal won't be executed if: +- the group has been modified before tally. +- the group account has been modified before tally. +- the proposal has not been accepted. +- the proposal status is not closed. +- the proposal has already been successfully executed. \ No newline at end of file diff --git a/x/group/spec/04_events.md b/x/group/spec/04_events.md new file mode 100644 index 0000000000..6f5f0b2108 --- /dev/null +++ b/x/group/spec/04_events.md @@ -0,0 +1,56 @@ + + +# Events + +The group module emits the following events: + +## EventCreateGroup + +| Type | Attribute Key | Attribute Value | +|---------------------------------------|---------------|---------------------------------------| +| message | action | /regen.group.v1alpha1.Msg/CreateGroup | +| regen.group.v1alpha1.EventCreateGroup | group_id | {groupId} | + +## EventUpdateGroup + +| Type | Attribute Key | Attribute Value | +|---------------------------------------|---------------|-----------------------------------------------------------------| +| message | action | /regen.group.v1alpha1.Msg/UpdateGroup{Admin\|Metadata\|Members} | +| regen.group.v1alpha1.EventUpdateGroup | group_id | {groupId} | + +## EventCreateGroupAccount + +| Type | Attribute Key | Attribute Value | +|----------------------------------------------|---------------|----------------------------------------------| +| message | action | /regen.group.v1alpha1.Msg/CreateGroupAccount | +| regen.group.v1alpha1.EventCreateGroupAccount | address | {groupAccountAddress} | + +## EventUpdateGroupAccount + +| Type | Attribute Key | Attribute Value | +|----------------------------------------------|---------------|-------------------------------------------------------------------------------| +| message | action | /regen.group.v1alpha1.Msg/UpdateGroupAccount{Admin\|Metadata\|DecisionPolicy} | +| regen.group.v1alpha1.EventUpdateGroupAccount | address | {groupAccountAddress} | + +## EventCreateProposal + +| Type | Attribute Key | Attribute Value | +|------------------------------------------|---------------|------------------------------------------| +| message | action | /regen.group.v1alpha1.Msg/CreateProposal | +| regen.group.v1alpha1.EventCreateProposal | proposal_id | {proposalId} | + +## EventVote + +| Type | Attribute Key | Attribute Value | +|--------------------------------|---------------|--------------------------------| +| message | action | /regen.group.v1alpha1.Msg/Vote | +| regen.group.v1alpha1.EventVote | proposal_id | {proposalId} | + +## EventExec + +| Type | Attribute Key | Attribute Value | +|--------------------------------|---------------|--------------------------------| +| message | action | /regen.group.v1alpha1.Msg/Exec | +| regen.group.v1alpha1.EventExec | proposal_id | {proposalId} | \ No newline at end of file diff --git a/x/group/spec/README.md b/x/group/spec/README.md new file mode 100644 index 0000000000..f821330ed5 --- /dev/null +++ b/x/group/spec/README.md @@ -0,0 +1,49 @@ + + +## Abstract + +This document specifies the group module. + +This module allows the creation and management of on-chain multisig accounts and enables voting for message execution based on configurable decision policies. + +## Contents + +1. **[Concepts](01_concepts.md)** + - [Group](01_concepts.md#group) + - [Group Account](01_concepts.md#group-account) + - [Decision Policy](01_concepts.md#decision-policy) + - [Proposal](01_concepts.md#proposal) + - [Voting](01_concepts.md#voting) + - [Executing Proposals](01_concepts.md#executing-proposals) +2. **[State](02_state.md)** + - [Group Table](02_state.md#group-table) + - [Group Member Table](02_state.md#group-member-table) + - [Group Account Table](02_state.md#group-account-table) + - [Proposal](02_state.md#proposal-table) + - [Vote Table](02_state.md#vote-table) +3. **[Msg Service](03_messages.md)** + - [Msg/CreateGroup](03_messages.md#msgcreategroup) + - [Msg/UpdateGroupMembers](03_messages.md#msgupdategroupmembers) + - [Msg/UpdateGroupAdmin](03_messages.md#msgupdategroupadmin) + - [Msg/UpdateGroupMetadata](03_messages.md#msgupdategroupmetadata) + - [Msg/CreateGroupAccount](03_messages.md#msgcreategroupaccount) + - [Msg/UpdateGroupAccountAdmin](03_messages.md#msgupdategroupaccountadmin) + - [Msg/UpdateGroupAccountDecisionPolicy](03_messages.md#msgupdategroupaccountdecisionpolicy) + - [Msg/UpdateGroupAccountMetadata](03_messages.md#msgupdategroupaccountmetadata) + - [Msg/CreateProposal](03_messages.md#msgcreateproposal) + - [Msg/Vote](03_messages.md#msgvote) + - [Msg/Exec](03_messages.md#msgexec) +4. **[Events](04_events.md)** + - [EventCreateGroup](04_events.md#eventcreategroup) + - [EventUpdateGroup](04_events.md#eventupdategroup) + - [EventCreateGroupAccount](04_events.md#eventcreategroupaccount) + - [EventUpdateGroupAccount](04_events.md#eventupdategroupaccount) + - [EventCreateProposal](04_events.md#eventcreateproposal) + - [EventVote](04_events.md#eventvote) + - [EventExec](04_events.md#eventexec) + diff --git a/x/group/tx.pb.go b/x/group/tx.pb.go new file mode 100644 index 0000000000..1265bec245 --- /dev/null +++ b/x/group/tx.pb.go @@ -0,0 +1,4734 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: regen/group/v1alpha1/tx.proto + +package group + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "github.com/regen-network/cosmos-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 + +// MsgCreateGroupRequest is the Msg/CreateGroup request type. +type MsgCreateGroupRequest struct { + // admin is the account address of the group admin. + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // members defines the group members. + Members []Member `protobuf:"bytes,2,rep,name=members,proto3" json:"members"` + // metadata is any arbitrary metadata to attached to the group. + Metadata []byte `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (m *MsgCreateGroupRequest) Reset() { *m = MsgCreateGroupRequest{} } +func (m *MsgCreateGroupRequest) String() string { return proto.CompactTextString(m) } +func (*MsgCreateGroupRequest) ProtoMessage() {} +func (*MsgCreateGroupRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{0} +} +func (m *MsgCreateGroupRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateGroupRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateGroupRequest.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 *MsgCreateGroupRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateGroupRequest.Merge(m, src) +} +func (m *MsgCreateGroupRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateGroupRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateGroupRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateGroupRequest proto.InternalMessageInfo + +func (m *MsgCreateGroupRequest) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func (m *MsgCreateGroupRequest) GetMembers() []Member { + if m != nil { + return m.Members + } + return nil +} + +func (m *MsgCreateGroupRequest) GetMetadata() []byte { + if m != nil { + return m.Metadata + } + return nil +} + +// MsgCreateGroupResponse is the Msg/CreateGroup response type. +type MsgCreateGroupResponse struct { + // group_id is the unique ID of the newly created group. + GroupId uint64 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` +} + +func (m *MsgCreateGroupResponse) Reset() { *m = MsgCreateGroupResponse{} } +func (m *MsgCreateGroupResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateGroupResponse) ProtoMessage() {} +func (*MsgCreateGroupResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{1} +} +func (m *MsgCreateGroupResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateGroupResponse.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 *MsgCreateGroupResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateGroupResponse.Merge(m, src) +} +func (m *MsgCreateGroupResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateGroupResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateGroupResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateGroupResponse proto.InternalMessageInfo + +func (m *MsgCreateGroupResponse) GetGroupId() uint64 { + if m != nil { + return m.GroupId + } + return 0 +} + +// MsgUpdateGroupMembersRequest is the Msg/UpdateGroupMembers request type. +type MsgUpdateGroupMembersRequest struct { + // admin is the account address of the group admin. + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // group_id is the unique ID of the group. + GroupId uint64 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + // member_updates is the list of members to update, + // set weight to 0 to remove a member. + MemberUpdates []Member `protobuf:"bytes,3,rep,name=member_updates,json=memberUpdates,proto3" json:"member_updates"` +} + +func (m *MsgUpdateGroupMembersRequest) Reset() { *m = MsgUpdateGroupMembersRequest{} } +func (m *MsgUpdateGroupMembersRequest) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateGroupMembersRequest) ProtoMessage() {} +func (*MsgUpdateGroupMembersRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{2} +} +func (m *MsgUpdateGroupMembersRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateGroupMembersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateGroupMembersRequest.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 *MsgUpdateGroupMembersRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateGroupMembersRequest.Merge(m, src) +} +func (m *MsgUpdateGroupMembersRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateGroupMembersRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateGroupMembersRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateGroupMembersRequest proto.InternalMessageInfo + +func (m *MsgUpdateGroupMembersRequest) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func (m *MsgUpdateGroupMembersRequest) GetGroupId() uint64 { + if m != nil { + return m.GroupId + } + return 0 +} + +func (m *MsgUpdateGroupMembersRequest) GetMemberUpdates() []Member { + if m != nil { + return m.MemberUpdates + } + return nil +} + +// MsgUpdateGroupMembersResponse is the Msg/UpdateGroupMembers response type. +type MsgUpdateGroupMembersResponse struct { +} + +func (m *MsgUpdateGroupMembersResponse) Reset() { *m = MsgUpdateGroupMembersResponse{} } +func (m *MsgUpdateGroupMembersResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateGroupMembersResponse) ProtoMessage() {} +func (*MsgUpdateGroupMembersResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{3} +} +func (m *MsgUpdateGroupMembersResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateGroupMembersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateGroupMembersResponse.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 *MsgUpdateGroupMembersResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateGroupMembersResponse.Merge(m, src) +} +func (m *MsgUpdateGroupMembersResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateGroupMembersResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateGroupMembersResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateGroupMembersResponse proto.InternalMessageInfo + +// MsgUpdateGroupAdminRequest is the Msg/UpdateGroupAdmin request type. +type MsgUpdateGroupAdminRequest struct { + // admin is the current account address of the group admin. + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // group_id is the unique ID of the group. + GroupId uint64 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + // new_admin is the group new admin account address. + NewAdmin string `protobuf:"bytes,3,opt,name=new_admin,json=newAdmin,proto3" json:"new_admin,omitempty"` +} + +func (m *MsgUpdateGroupAdminRequest) Reset() { *m = MsgUpdateGroupAdminRequest{} } +func (m *MsgUpdateGroupAdminRequest) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateGroupAdminRequest) ProtoMessage() {} +func (*MsgUpdateGroupAdminRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{4} +} +func (m *MsgUpdateGroupAdminRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateGroupAdminRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateGroupAdminRequest.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 *MsgUpdateGroupAdminRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateGroupAdminRequest.Merge(m, src) +} +func (m *MsgUpdateGroupAdminRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateGroupAdminRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateGroupAdminRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateGroupAdminRequest proto.InternalMessageInfo + +func (m *MsgUpdateGroupAdminRequest) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func (m *MsgUpdateGroupAdminRequest) GetGroupId() uint64 { + if m != nil { + return m.GroupId + } + return 0 +} + +func (m *MsgUpdateGroupAdminRequest) GetNewAdmin() string { + if m != nil { + return m.NewAdmin + } + return "" +} + +// MsgUpdateGroupAdminResponse is the Msg/UpdateGroupAdmin response type. +type MsgUpdateGroupAdminResponse struct { +} + +func (m *MsgUpdateGroupAdminResponse) Reset() { *m = MsgUpdateGroupAdminResponse{} } +func (m *MsgUpdateGroupAdminResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateGroupAdminResponse) ProtoMessage() {} +func (*MsgUpdateGroupAdminResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{5} +} +func (m *MsgUpdateGroupAdminResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateGroupAdminResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateGroupAdminResponse.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 *MsgUpdateGroupAdminResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateGroupAdminResponse.Merge(m, src) +} +func (m *MsgUpdateGroupAdminResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateGroupAdminResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateGroupAdminResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateGroupAdminResponse proto.InternalMessageInfo + +// MsgUpdateGroupMetadataRequest is the Msg/UpdateGroupMetadata request type. +type MsgUpdateGroupMetadataRequest struct { + // admin is the account address of the group admin. + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // group_id is the unique ID of the group. + GroupId uint64 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + // metadata is the updated group's metadata. + Metadata []byte `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (m *MsgUpdateGroupMetadataRequest) Reset() { *m = MsgUpdateGroupMetadataRequest{} } +func (m *MsgUpdateGroupMetadataRequest) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateGroupMetadataRequest) ProtoMessage() {} +func (*MsgUpdateGroupMetadataRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{6} +} +func (m *MsgUpdateGroupMetadataRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateGroupMetadataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateGroupMetadataRequest.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 *MsgUpdateGroupMetadataRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateGroupMetadataRequest.Merge(m, src) +} +func (m *MsgUpdateGroupMetadataRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateGroupMetadataRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateGroupMetadataRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateGroupMetadataRequest proto.InternalMessageInfo + +func (m *MsgUpdateGroupMetadataRequest) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func (m *MsgUpdateGroupMetadataRequest) GetGroupId() uint64 { + if m != nil { + return m.GroupId + } + return 0 +} + +func (m *MsgUpdateGroupMetadataRequest) GetMetadata() []byte { + if m != nil { + return m.Metadata + } + return nil +} + +// MsgUpdateGroupMetadataResponse is the Msg/UpdateGroupMetadata response type. +type MsgUpdateGroupMetadataResponse struct { +} + +func (m *MsgUpdateGroupMetadataResponse) Reset() { *m = MsgUpdateGroupMetadataResponse{} } +func (m *MsgUpdateGroupMetadataResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateGroupMetadataResponse) ProtoMessage() {} +func (*MsgUpdateGroupMetadataResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{7} +} +func (m *MsgUpdateGroupMetadataResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateGroupMetadataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateGroupMetadataResponse.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 *MsgUpdateGroupMetadataResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateGroupMetadataResponse.Merge(m, src) +} +func (m *MsgUpdateGroupMetadataResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateGroupMetadataResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateGroupMetadataResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateGroupMetadataResponse proto.InternalMessageInfo + +// MsgCreateGroupAccountRequest is the Msg/CreateGroupAccount request type. +type MsgCreateGroupAccountRequest struct { + // admin is the account address of the group admin. + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // group_id is the unique ID of the group. + GroupId uint64 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + // metadata is any arbitrary metadata to attached to the group account. + Metadata []byte `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` + // decision_policy specifies the group account's decision policy. + DecisionPolicy *types.Any `protobuf:"bytes,4,opt,name=decision_policy,json=decisionPolicy,proto3" json:"decision_policy,omitempty"` +} + +func (m *MsgCreateGroupAccountRequest) Reset() { *m = MsgCreateGroupAccountRequest{} } +func (m *MsgCreateGroupAccountRequest) String() string { return proto.CompactTextString(m) } +func (*MsgCreateGroupAccountRequest) ProtoMessage() {} +func (*MsgCreateGroupAccountRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{8} +} +func (m *MsgCreateGroupAccountRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateGroupAccountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateGroupAccountRequest.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 *MsgCreateGroupAccountRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateGroupAccountRequest.Merge(m, src) +} +func (m *MsgCreateGroupAccountRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateGroupAccountRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateGroupAccountRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateGroupAccountRequest proto.InternalMessageInfo + +// MsgCreateGroupAccountResponse is the Msg/CreateGroupAccount response type. +type MsgCreateGroupAccountResponse struct { + // address is the account address of the newly created group account. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *MsgCreateGroupAccountResponse) Reset() { *m = MsgCreateGroupAccountResponse{} } +func (m *MsgCreateGroupAccountResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateGroupAccountResponse) ProtoMessage() {} +func (*MsgCreateGroupAccountResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{9} +} +func (m *MsgCreateGroupAccountResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateGroupAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateGroupAccountResponse.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 *MsgCreateGroupAccountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateGroupAccountResponse.Merge(m, src) +} +func (m *MsgCreateGroupAccountResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateGroupAccountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateGroupAccountResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateGroupAccountResponse proto.InternalMessageInfo + +func (m *MsgCreateGroupAccountResponse) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +// MsgUpdateGroupAccountAdminRequest is the Msg/UpdateGroupAccountAdmin request type. +type MsgUpdateGroupAccountAdminRequest struct { + // admin is the account address of the group admin. + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // address is the group account address. + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + // new_admin is the new group account admin. + NewAdmin string `protobuf:"bytes,3,opt,name=new_admin,json=newAdmin,proto3" json:"new_admin,omitempty"` +} + +func (m *MsgUpdateGroupAccountAdminRequest) Reset() { *m = MsgUpdateGroupAccountAdminRequest{} } +func (m *MsgUpdateGroupAccountAdminRequest) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateGroupAccountAdminRequest) ProtoMessage() {} +func (*MsgUpdateGroupAccountAdminRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{10} +} +func (m *MsgUpdateGroupAccountAdminRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateGroupAccountAdminRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateGroupAccountAdminRequest.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 *MsgUpdateGroupAccountAdminRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateGroupAccountAdminRequest.Merge(m, src) +} +func (m *MsgUpdateGroupAccountAdminRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateGroupAccountAdminRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateGroupAccountAdminRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateGroupAccountAdminRequest proto.InternalMessageInfo + +func (m *MsgUpdateGroupAccountAdminRequest) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func (m *MsgUpdateGroupAccountAdminRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *MsgUpdateGroupAccountAdminRequest) GetNewAdmin() string { + if m != nil { + return m.NewAdmin + } + return "" +} + +// MsgUpdateGroupAccountAdminResponse is the Msg/UpdateGroupAccountAdmin response type. +type MsgUpdateGroupAccountAdminResponse struct { +} + +func (m *MsgUpdateGroupAccountAdminResponse) Reset() { *m = MsgUpdateGroupAccountAdminResponse{} } +func (m *MsgUpdateGroupAccountAdminResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateGroupAccountAdminResponse) ProtoMessage() {} +func (*MsgUpdateGroupAccountAdminResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{11} +} +func (m *MsgUpdateGroupAccountAdminResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateGroupAccountAdminResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateGroupAccountAdminResponse.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 *MsgUpdateGroupAccountAdminResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateGroupAccountAdminResponse.Merge(m, src) +} +func (m *MsgUpdateGroupAccountAdminResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateGroupAccountAdminResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateGroupAccountAdminResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateGroupAccountAdminResponse proto.InternalMessageInfo + +// MsgUpdateGroupAccountDecisionPolicyRequest is the Msg/UpdateGroupAccountDecisionPolicy request type. +type MsgUpdateGroupAccountDecisionPolicyRequest struct { + // admin is the account address of the group admin. + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // address is the group account address. + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + // decision_policy is the updated group account decision policy. + DecisionPolicy *types.Any `protobuf:"bytes,3,opt,name=decision_policy,json=decisionPolicy,proto3" json:"decision_policy,omitempty"` +} + +func (m *MsgUpdateGroupAccountDecisionPolicyRequest) Reset() { + *m = MsgUpdateGroupAccountDecisionPolicyRequest{} +} +func (m *MsgUpdateGroupAccountDecisionPolicyRequest) String() string { + return proto.CompactTextString(m) +} +func (*MsgUpdateGroupAccountDecisionPolicyRequest) ProtoMessage() {} +func (*MsgUpdateGroupAccountDecisionPolicyRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{12} +} +func (m *MsgUpdateGroupAccountDecisionPolicyRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateGroupAccountDecisionPolicyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateGroupAccountDecisionPolicyRequest.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 *MsgUpdateGroupAccountDecisionPolicyRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateGroupAccountDecisionPolicyRequest.Merge(m, src) +} +func (m *MsgUpdateGroupAccountDecisionPolicyRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateGroupAccountDecisionPolicyRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateGroupAccountDecisionPolicyRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateGroupAccountDecisionPolicyRequest proto.InternalMessageInfo + +// MsgUpdateGroupAccountDecisionPolicyResponse is the Msg/UpdateGroupAccountDecisionPolicy response type. +type MsgUpdateGroupAccountDecisionPolicyResponse struct { +} + +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) Reset() { + *m = MsgUpdateGroupAccountDecisionPolicyResponse{} +} +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) String() string { + return proto.CompactTextString(m) +} +func (*MsgUpdateGroupAccountDecisionPolicyResponse) ProtoMessage() {} +func (*MsgUpdateGroupAccountDecisionPolicyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{13} +} +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateGroupAccountDecisionPolicyResponse.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 *MsgUpdateGroupAccountDecisionPolicyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateGroupAccountDecisionPolicyResponse.Merge(m, src) +} +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateGroupAccountDecisionPolicyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateGroupAccountDecisionPolicyResponse proto.InternalMessageInfo + +// MsgUpdateGroupAccountMetadataRequest is the Msg/UpdateGroupAccountMetadata request type. +type MsgUpdateGroupAccountMetadataRequest struct { + // admin is the account address of the group admin. + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // address is the group account address. + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + // metadata is the updated group account metadata. + Metadata []byte `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (m *MsgUpdateGroupAccountMetadataRequest) Reset() { *m = MsgUpdateGroupAccountMetadataRequest{} } +func (m *MsgUpdateGroupAccountMetadataRequest) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateGroupAccountMetadataRequest) ProtoMessage() {} +func (*MsgUpdateGroupAccountMetadataRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{14} +} +func (m *MsgUpdateGroupAccountMetadataRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateGroupAccountMetadataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateGroupAccountMetadataRequest.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 *MsgUpdateGroupAccountMetadataRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateGroupAccountMetadataRequest.Merge(m, src) +} +func (m *MsgUpdateGroupAccountMetadataRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateGroupAccountMetadataRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateGroupAccountMetadataRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateGroupAccountMetadataRequest proto.InternalMessageInfo + +func (m *MsgUpdateGroupAccountMetadataRequest) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func (m *MsgUpdateGroupAccountMetadataRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *MsgUpdateGroupAccountMetadataRequest) GetMetadata() []byte { + if m != nil { + return m.Metadata + } + return nil +} + +// MsgUpdateGroupAccountMetadataResponse is the Msg/UpdateGroupAccountMetadata response type. +type MsgUpdateGroupAccountMetadataResponse struct { +} + +func (m *MsgUpdateGroupAccountMetadataResponse) Reset() { *m = MsgUpdateGroupAccountMetadataResponse{} } +func (m *MsgUpdateGroupAccountMetadataResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateGroupAccountMetadataResponse) ProtoMessage() {} +func (*MsgUpdateGroupAccountMetadataResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{15} +} +func (m *MsgUpdateGroupAccountMetadataResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateGroupAccountMetadataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateGroupAccountMetadataResponse.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 *MsgUpdateGroupAccountMetadataResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateGroupAccountMetadataResponse.Merge(m, src) +} +func (m *MsgUpdateGroupAccountMetadataResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateGroupAccountMetadataResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateGroupAccountMetadataResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateGroupAccountMetadataResponse proto.InternalMessageInfo + +// MsgCreateProposalRequest is the Msg/CreateProposal request type. +type MsgCreateProposalRequest struct { + // address is the group account address. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // proposers are the account addresses of the proposers. + // Proposers signatures will be counted as yes votes. + Proposers []string `protobuf:"bytes,2,rep,name=proposers,proto3" json:"proposers,omitempty"` + // metadata is any arbitrary metadata to attached to the proposal. + Metadata []byte `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` + // msgs is a list of Msgs that will be executed if the proposal passes. + Msgs []*types.Any `protobuf:"bytes,4,rep,name=msgs,proto3" json:"msgs,omitempty"` +} + +func (m *MsgCreateProposalRequest) Reset() { *m = MsgCreateProposalRequest{} } +func (m *MsgCreateProposalRequest) String() string { return proto.CompactTextString(m) } +func (*MsgCreateProposalRequest) ProtoMessage() {} +func (*MsgCreateProposalRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{16} +} +func (m *MsgCreateProposalRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateProposalRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateProposalRequest.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 *MsgCreateProposalRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateProposalRequest.Merge(m, src) +} +func (m *MsgCreateProposalRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateProposalRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateProposalRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateProposalRequest proto.InternalMessageInfo + +// MsgCreateProposalResponse is the Msg/CreateProposal response type. +type MsgCreateProposalResponse struct { + // proposal is the unique ID of the proposal. + ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` +} + +func (m *MsgCreateProposalResponse) Reset() { *m = MsgCreateProposalResponse{} } +func (m *MsgCreateProposalResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateProposalResponse) ProtoMessage() {} +func (*MsgCreateProposalResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{17} +} +func (m *MsgCreateProposalResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateProposalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateProposalResponse.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 *MsgCreateProposalResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateProposalResponse.Merge(m, src) +} +func (m *MsgCreateProposalResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateProposalResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateProposalResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateProposalResponse proto.InternalMessageInfo + +func (m *MsgCreateProposalResponse) GetProposalId() uint64 { + if m != nil { + return m.ProposalId + } + return 0 +} + +// MsgVoteRequest is the Msg/Vote request type. +type MsgVoteRequest struct { + // proposal is the unique ID of the proposal. + ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` + // voter is the voter account address. + Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"` + // choice is the voter's choice on the proposal. + Choice Choice `protobuf:"varint,3,opt,name=choice,proto3,enum=regen.group.v1alpha1.Choice" json:"choice,omitempty"` + // metadata is any arbitrary metadata to attached to the vote. + Metadata []byte `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (m *MsgVoteRequest) Reset() { *m = MsgVoteRequest{} } +func (m *MsgVoteRequest) String() string { return proto.CompactTextString(m) } +func (*MsgVoteRequest) ProtoMessage() {} +func (*MsgVoteRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{18} +} +func (m *MsgVoteRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVoteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVoteRequest.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 *MsgVoteRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVoteRequest.Merge(m, src) +} +func (m *MsgVoteRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgVoteRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVoteRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgVoteRequest proto.InternalMessageInfo + +func (m *MsgVoteRequest) GetProposalId() uint64 { + if m != nil { + return m.ProposalId + } + return 0 +} + +func (m *MsgVoteRequest) GetVoter() string { + if m != nil { + return m.Voter + } + return "" +} + +func (m *MsgVoteRequest) GetChoice() Choice { + if m != nil { + return m.Choice + } + return Choice_CHOICE_UNSPECIFIED +} + +func (m *MsgVoteRequest) GetMetadata() []byte { + if m != nil { + return m.Metadata + } + return nil +} + +// MsgVoteResponse is the Msg/Vote response type. +type MsgVoteResponse struct { +} + +func (m *MsgVoteResponse) Reset() { *m = MsgVoteResponse{} } +func (m *MsgVoteResponse) String() string { return proto.CompactTextString(m) } +func (*MsgVoteResponse) ProtoMessage() {} +func (*MsgVoteResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{19} +} +func (m *MsgVoteResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVoteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVoteResponse.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 *MsgVoteResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVoteResponse.Merge(m, src) +} +func (m *MsgVoteResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgVoteResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVoteResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgVoteResponse proto.InternalMessageInfo + +// MsgExecRequest is the Msg/Exec request type. +type MsgExecRequest struct { + // proposal is the unique ID of the proposal. + ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` + // signer is the account address used to execute the proposal. + Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgExecRequest) Reset() { *m = MsgExecRequest{} } +func (m *MsgExecRequest) String() string { return proto.CompactTextString(m) } +func (*MsgExecRequest) ProtoMessage() {} +func (*MsgExecRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{20} +} +func (m *MsgExecRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExecRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExecRequest.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 *MsgExecRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExecRequest.Merge(m, src) +} +func (m *MsgExecRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgExecRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExecRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExecRequest proto.InternalMessageInfo + +func (m *MsgExecRequest) GetProposalId() uint64 { + if m != nil { + return m.ProposalId + } + return 0 +} + +func (m *MsgExecRequest) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +// MsgExecResponse is the Msg/Exec request type. +type MsgExecResponse struct { +} + +func (m *MsgExecResponse) Reset() { *m = MsgExecResponse{} } +func (m *MsgExecResponse) String() string { return proto.CompactTextString(m) } +func (*MsgExecResponse) ProtoMessage() {} +func (*MsgExecResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{21} +} +func (m *MsgExecResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExecResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExecResponse.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 *MsgExecResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExecResponse.Merge(m, src) +} +func (m *MsgExecResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgExecResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExecResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExecResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgCreateGroupRequest)(nil), "regen.group.v1alpha1.MsgCreateGroupRequest") + proto.RegisterType((*MsgCreateGroupResponse)(nil), "regen.group.v1alpha1.MsgCreateGroupResponse") + proto.RegisterType((*MsgUpdateGroupMembersRequest)(nil), "regen.group.v1alpha1.MsgUpdateGroupMembersRequest") + proto.RegisterType((*MsgUpdateGroupMembersResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupMembersResponse") + proto.RegisterType((*MsgUpdateGroupAdminRequest)(nil), "regen.group.v1alpha1.MsgUpdateGroupAdminRequest") + proto.RegisterType((*MsgUpdateGroupAdminResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupAdminResponse") + proto.RegisterType((*MsgUpdateGroupMetadataRequest)(nil), "regen.group.v1alpha1.MsgUpdateGroupMetadataRequest") + proto.RegisterType((*MsgUpdateGroupMetadataResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupMetadataResponse") + proto.RegisterType((*MsgCreateGroupAccountRequest)(nil), "regen.group.v1alpha1.MsgCreateGroupAccountRequest") + proto.RegisterType((*MsgCreateGroupAccountResponse)(nil), "regen.group.v1alpha1.MsgCreateGroupAccountResponse") + proto.RegisterType((*MsgUpdateGroupAccountAdminRequest)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountAdminRequest") + proto.RegisterType((*MsgUpdateGroupAccountAdminResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountAdminResponse") + proto.RegisterType((*MsgUpdateGroupAccountDecisionPolicyRequest)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountDecisionPolicyRequest") + proto.RegisterType((*MsgUpdateGroupAccountDecisionPolicyResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountDecisionPolicyResponse") + proto.RegisterType((*MsgUpdateGroupAccountMetadataRequest)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountMetadataRequest") + proto.RegisterType((*MsgUpdateGroupAccountMetadataResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountMetadataResponse") + proto.RegisterType((*MsgCreateProposalRequest)(nil), "regen.group.v1alpha1.MsgCreateProposalRequest") + proto.RegisterType((*MsgCreateProposalResponse)(nil), "regen.group.v1alpha1.MsgCreateProposalResponse") + proto.RegisterType((*MsgVoteRequest)(nil), "regen.group.v1alpha1.MsgVoteRequest") + proto.RegisterType((*MsgVoteResponse)(nil), "regen.group.v1alpha1.MsgVoteResponse") + proto.RegisterType((*MsgExecRequest)(nil), "regen.group.v1alpha1.MsgExecRequest") + proto.RegisterType((*MsgExecResponse)(nil), "regen.group.v1alpha1.MsgExecResponse") +} + +func init() { proto.RegisterFile("regen/group/v1alpha1/tx.proto", fileDescriptor_b4673626e7797578) } + +var fileDescriptor_b4673626e7797578 = []byte{ + // 936 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4f, 0x6f, 0xe3, 0x44, + 0x14, 0xcf, 0x34, 0xa6, 0x7f, 0x5e, 0x21, 0x0b, 0x43, 0x59, 0x5c, 0x6f, 0x9b, 0x06, 0xab, 0x2b, + 0x22, 0x96, 0xda, 0xb4, 0x5d, 0x09, 0x58, 0xf6, 0x40, 0xbb, 0xa0, 0x55, 0x0f, 0x91, 0x16, 0x23, + 0x38, 0x70, 0x89, 0x5c, 0x7b, 0x70, 0x0d, 0x89, 0xc7, 0xeb, 0x71, 0xb6, 0xcd, 0x01, 0x89, 0x1b, + 0x1c, 0x38, 0x70, 0xe1, 0x00, 0x07, 0xc4, 0x8d, 0x2f, 0x00, 0xdf, 0x80, 0xc3, 0x8a, 0x53, 0x6f, + 0x70, 0x42, 0xa8, 0xfd, 0x22, 0x28, 0x33, 0xe3, 0xc4, 0x49, 0x6c, 0xc7, 0x09, 0x70, 0xcb, 0xf3, + 0xbc, 0xf7, 0x9b, 0xdf, 0xfb, 0x33, 0xbf, 0xa7, 0xc0, 0x76, 0x44, 0x3c, 0x12, 0x98, 0x5e, 0x44, + 0x7b, 0xa1, 0xf9, 0x64, 0xdf, 0xee, 0x84, 0x67, 0xf6, 0xbe, 0x19, 0x5f, 0x18, 0x61, 0x44, 0x63, + 0x8a, 0x37, 0xf8, 0xb1, 0xc1, 0x8f, 0x8d, 0xe4, 0x58, 0xdb, 0xf0, 0xa8, 0x47, 0xb9, 0x83, 0x39, + 0xf8, 0x25, 0x7c, 0xb5, 0x4d, 0x87, 0xb2, 0x2e, 0x65, 0x6d, 0x71, 0x20, 0x8c, 0xe4, 0xc8, 0xa3, + 0xd4, 0xeb, 0x10, 0x93, 0x5b, 0xa7, 0xbd, 0x4f, 0x4d, 0x3b, 0xe8, 0xcb, 0xa3, 0x46, 0x36, 0x81, + 0x7e, 0x48, 0x64, 0xb0, 0xfe, 0x15, 0x82, 0x97, 0x5a, 0xcc, 0x7b, 0x10, 0x11, 0x3b, 0x26, 0x0f, + 0x07, 0x7e, 0x16, 0x79, 0xdc, 0x23, 0x2c, 0xc6, 0x1b, 0xf0, 0x8c, 0xed, 0x76, 0xfd, 0x40, 0x45, + 0x0d, 0xd4, 0x5c, 0xb3, 0x84, 0x81, 0xef, 0xc3, 0x4a, 0x97, 0x74, 0x4f, 0x49, 0xc4, 0xd4, 0xa5, + 0x46, 0xb5, 0xb9, 0x7e, 0xb0, 0x65, 0x64, 0x65, 0x61, 0xb4, 0xb8, 0xd3, 0xb1, 0xf2, 0xf4, 0xaf, + 0x9d, 0x8a, 0x95, 0x84, 0x60, 0x0d, 0x56, 0xbb, 0x24, 0xb6, 0x5d, 0x3b, 0xb6, 0xd5, 0x6a, 0x03, + 0x35, 0x9f, 0xb5, 0x86, 0xb6, 0x7e, 0x08, 0x37, 0x27, 0x89, 0xb0, 0x90, 0x06, 0x8c, 0xe0, 0x4d, + 0x58, 0xe5, 0xe8, 0x6d, 0xdf, 0xe5, 0x64, 0x14, 0x6b, 0x85, 0xdb, 0x27, 0xae, 0xfe, 0x03, 0x82, + 0xad, 0x16, 0xf3, 0x3e, 0x0a, 0xdd, 0x24, 0x4a, 0x5c, 0xcc, 0x8a, 0xb3, 0x48, 0x23, 0x2e, 0x8d, + 0x21, 0xe2, 0x13, 0xa8, 0x09, 0xb6, 0xed, 0x1e, 0x07, 0x65, 0x6a, 0xb5, 0x74, 0x9e, 0xcf, 0x89, + 0x48, 0xc1, 0x86, 0xe9, 0x3b, 0xb0, 0x9d, 0xc3, 0x4d, 0x24, 0xa6, 0x7f, 0x06, 0xda, 0xb8, 0xc3, + 0xd1, 0x80, 0xdd, 0xc2, 0xd4, 0x6f, 0xc1, 0x5a, 0x40, 0xce, 0xdb, 0x22, 0xa8, 0xca, 0x83, 0x56, + 0x03, 0x72, 0xce, 0x41, 0xf5, 0x6d, 0xb8, 0x95, 0x79, 0x97, 0xa4, 0xd2, 0x99, 0xe6, 0x2a, 0xfa, + 0xb2, 0x30, 0x9b, 0xa2, 0x5e, 0x37, 0xa0, 0x9e, 0x77, 0x9b, 0xe4, 0xf3, 0x9b, 0x68, 0x6c, 0x6a, + 0x1c, 0x8e, 0x1c, 0x87, 0xf6, 0x82, 0xf8, 0xff, 0xe0, 0x83, 0x3f, 0x80, 0x1b, 0x2e, 0x71, 0x7c, + 0xe6, 0xd3, 0xa0, 0x1d, 0xd2, 0x8e, 0xef, 0xf4, 0x55, 0xa5, 0x81, 0x9a, 0xeb, 0x07, 0x1b, 0x86, + 0x78, 0x5c, 0x46, 0xf2, 0xb8, 0x8c, 0xa3, 0xa0, 0x7f, 0x8c, 0x7f, 0xff, 0x65, 0xaf, 0xf6, 0x9e, + 0x0c, 0x78, 0xc4, 0xfd, 0xad, 0x9a, 0x3b, 0x66, 0xdf, 0x53, 0xbe, 0xfe, 0x69, 0xa7, 0xa2, 0xbf, + 0xcd, 0xcb, 0x9a, 0x95, 0x85, 0x9c, 0x6d, 0x15, 0x56, 0x6c, 0xd7, 0x8d, 0x08, 0x63, 0x32, 0x91, + 0xc4, 0xd4, 0x43, 0x78, 0x65, 0xa2, 0x61, 0x22, 0xb4, 0xc4, 0x8c, 0xa4, 0x40, 0x97, 0xc6, 0x40, + 0x8b, 0x47, 0x64, 0x17, 0xf4, 0xa2, 0x1b, 0x65, 0x67, 0x7e, 0x45, 0xf0, 0x5a, 0xa6, 0xdb, 0x44, + 0x41, 0x16, 0x64, 0x98, 0xd1, 0x8a, 0xea, 0x7f, 0xd2, 0x8a, 0x3d, 0xb8, 0x53, 0x8a, 0xb6, 0x4c, + 0x33, 0x82, 0xdd, 0x4c, 0xf7, 0x72, 0xef, 0x22, 0x3f, 0xbf, 0xa2, 0x67, 0xf1, 0x2a, 0xdc, 0x9e, + 0x71, 0xa7, 0x24, 0xf7, 0x23, 0x02, 0x75, 0x38, 0x57, 0x8f, 0x22, 0x1a, 0x52, 0x66, 0x77, 0x12, + 0x46, 0xb9, 0x23, 0x85, 0xb7, 0x60, 0x2d, 0xe4, 0xce, 0x89, 0x7c, 0xaf, 0x59, 0xa3, 0x0f, 0x85, + 0x0f, 0xa4, 0x09, 0x4a, 0x97, 0x79, 0x4c, 0x55, 0xb8, 0x16, 0x66, 0xb6, 0xc2, 0xe2, 0x1e, 0xb2, + 0xd8, 0xf7, 0x61, 0x33, 0x83, 0x9f, 0x9c, 0xf9, 0x1d, 0x58, 0x0f, 0xe5, 0xb7, 0x91, 0xa4, 0x43, + 0xf2, 0xe9, 0xc4, 0xd5, 0xbf, 0x47, 0x50, 0x6b, 0x31, 0xef, 0x63, 0x1a, 0x93, 0x24, 0xa9, 0x59, + 0x31, 0x83, 0x3e, 0x3c, 0xa1, 0x31, 0x89, 0x64, 0xbd, 0x85, 0x81, 0xef, 0xc2, 0xb2, 0x73, 0x46, + 0x7d, 0x87, 0xf0, 0x8c, 0x6a, 0x79, 0x2a, 0xfe, 0x80, 0xfb, 0x58, 0xd2, 0x77, 0xac, 0x12, 0xca, + 0x44, 0x8f, 0x5e, 0x80, 0x1b, 0x43, 0x6a, 0xb2, 0x1b, 0x27, 0x9c, 0xed, 0xfb, 0x17, 0xc4, 0x29, + 0xcd, 0xf6, 0x26, 0x2c, 0x33, 0xdf, 0x0b, 0x86, 0x74, 0xa5, 0x25, 0xd1, 0x05, 0x94, 0x40, 0x3f, + 0xf8, 0x03, 0xa0, 0xda, 0x62, 0x1e, 0x3e, 0x83, 0xf5, 0x94, 0x8e, 0xe0, 0x3b, 0x39, 0xfb, 0x28, + 0x6b, 0x97, 0x6b, 0xaf, 0x97, 0x73, 0x96, 0xfd, 0xf9, 0x02, 0xf0, 0xf4, 0xd2, 0xc2, 0x07, 0xb9, + 0x18, 0xb9, 0xdb, 0x57, 0x3b, 0x9c, 0x2b, 0x46, 0x5e, 0x7f, 0x0e, 0xcf, 0x4f, 0xae, 0x29, 0xfc, + 0x46, 0x19, 0xa0, 0xb4, 0x32, 0x6a, 0xfb, 0x73, 0x44, 0xc8, 0x8b, 0xbf, 0x44, 0xf0, 0x62, 0xc6, + 0x4e, 0xc2, 0x25, 0xb3, 0x18, 0xd3, 0x05, 0xed, 0xee, 0x7c, 0x41, 0xa3, 0xd2, 0x4f, 0x2f, 0x8b, + 0x82, 0xd2, 0xe7, 0xee, 0xc7, 0x82, 0xd2, 0x17, 0x6c, 0xa3, 0x6f, 0x10, 0xbc, 0x9c, 0xa3, 0xff, + 0xf8, 0xcd, 0x52, 0x05, 0x9d, 0xde, 0x51, 0xda, 0x5b, 0xf3, 0x07, 0x4a, 0x3a, 0x3f, 0x23, 0x68, + 0xcc, 0x12, 0x6c, 0xfc, 0xee, 0x1c, 0xf0, 0x99, 0x2b, 0x4a, 0x3b, 0xfa, 0x17, 0x08, 0x92, 0xe9, + 0x77, 0x08, 0xb4, 0x7c, 0xdd, 0xc6, 0xf7, 0xe6, 0xb8, 0x61, 0x72, 0x90, 0xde, 0x59, 0x28, 0x56, + 0xf2, 0x7a, 0x0c, 0xb5, 0x71, 0x11, 0xc6, 0xc6, 0x8c, 0xb9, 0x98, 0xd8, 0x26, 0x9a, 0x59, 0xda, + 0x5f, 0x5e, 0xf9, 0x21, 0x28, 0x03, 0x75, 0xc4, 0xbb, 0xb9, 0x81, 0x29, 0x5d, 0xd7, 0x6e, 0xcf, + 0xf0, 0x1a, 0x81, 0x0e, 0x44, 0xb1, 0x00, 0x34, 0x25, 0xbf, 0x05, 0xa0, 0x69, 0x65, 0x3d, 0x7e, + 0xf8, 0xf4, 0xaa, 0x8e, 0x2e, 0xaf, 0xea, 0xe8, 0xef, 0xab, 0x3a, 0xfa, 0xf6, 0xba, 0x5e, 0xb9, + 0xbc, 0xae, 0x57, 0xfe, 0xbc, 0xae, 0x57, 0x3e, 0xd9, 0xf3, 0xfc, 0xf8, 0xac, 0x77, 0x6a, 0x38, + 0xb4, 0x6b, 0x72, 0xa8, 0xbd, 0x80, 0xc4, 0xe7, 0x34, 0xfa, 0x5c, 0x5a, 0x1d, 0xe2, 0x7a, 0x24, + 0x32, 0x2f, 0xc4, 0x3f, 0xab, 0xd3, 0x65, 0xbe, 0x07, 0x0f, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, + 0xa9, 0x53, 0x7a, 0x00, 0xf0, 0x0d, 0x00, 0x00, +} + +func (m *MsgCreateGroupRequest) 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 *MsgCreateGroupRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateGroupRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x1a + } + if len(m.Members) > 0 { + for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Members[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateGroupResponse) 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 *MsgCreateGroupResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.GroupId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupMembersRequest) 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 *MsgUpdateGroupMembersRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupMembersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.MemberUpdates) > 0 { + for iNdEx := len(m.MemberUpdates) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.MemberUpdates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.GroupId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupMembersResponse) 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 *MsgUpdateGroupMembersResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupMembersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupAdminRequest) 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 *MsgUpdateGroupAdminRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupAdminRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NewAdmin) > 0 { + i -= len(m.NewAdmin) + copy(dAtA[i:], m.NewAdmin) + i = encodeVarintTx(dAtA, i, uint64(len(m.NewAdmin))) + i-- + dAtA[i] = 0x1a + } + if m.GroupId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupAdminResponse) 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 *MsgUpdateGroupAdminResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupMetadataRequest) 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 *MsgUpdateGroupMetadataRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupMetadataRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x1a + } + if m.GroupId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupMetadataResponse) 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 *MsgUpdateGroupMetadataResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgCreateGroupAccountRequest) 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 *MsgCreateGroupAccountRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateGroupAccountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.DecisionPolicy != nil { + { + size, err := m.DecisionPolicy.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x1a + } + if m.GroupId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateGroupAccountResponse) 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 *MsgCreateGroupAccountResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateGroupAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupAccountAdminRequest) 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 *MsgUpdateGroupAccountAdminRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupAccountAdminRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NewAdmin) > 0 { + i -= len(m.NewAdmin) + copy(dAtA[i:], m.NewAdmin) + i = encodeVarintTx(dAtA, i, uint64(len(m.NewAdmin))) + i-- + dAtA[i] = 0x1a + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupAccountAdminResponse) 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 *MsgUpdateGroupAccountAdminResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupAccountAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupAccountDecisionPolicyRequest) 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 *MsgUpdateGroupAccountDecisionPolicyRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupAccountDecisionPolicyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.DecisionPolicy != nil { + { + size, err := m.DecisionPolicy.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) 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 *MsgUpdateGroupAccountDecisionPolicyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupAccountMetadataRequest) 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 *MsgUpdateGroupAccountMetadataRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupAccountMetadataRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x1a + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateGroupAccountMetadataResponse) 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 *MsgUpdateGroupAccountMetadataResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateGroupAccountMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgCreateProposalRequest) 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 *MsgCreateProposalRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateProposalRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Msgs) > 0 { + for iNdEx := len(m.Msgs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Msgs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x1a + } + if len(m.Proposers) > 0 { + for iNdEx := len(m.Proposers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Proposers[iNdEx]) + copy(dAtA[i:], m.Proposers[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Proposers[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateProposalResponse) 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 *MsgCreateProposalResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ProposalId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgVoteRequest) 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 *MsgVoteRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVoteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x22 + } + if m.Choice != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Choice)) + i-- + dAtA[i] = 0x18 + } + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x12 + } + if m.ProposalId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgVoteResponse) 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 *MsgVoteResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgExecRequest) 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 *MsgExecRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x12 + } + if m.ProposalId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgExecResponse) 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 *MsgExecResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCreateGroupRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Members) > 0 { + for _, e := range m.Members { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateGroupResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovTx(uint64(m.GroupId)) + } + return n +} + +func (m *MsgUpdateGroupMembersRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.GroupId != 0 { + n += 1 + sovTx(uint64(m.GroupId)) + } + if len(m.MemberUpdates) > 0 { + for _, e := range m.MemberUpdates { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgUpdateGroupMembersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateGroupAdminRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.GroupId != 0 { + n += 1 + sovTx(uint64(m.GroupId)) + } + l = len(m.NewAdmin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateGroupAdminResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateGroupMetadataRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.GroupId != 0 { + n += 1 + sovTx(uint64(m.GroupId)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateGroupMetadataResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCreateGroupAccountRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.GroupId != 0 { + n += 1 + sovTx(uint64(m.GroupId)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.DecisionPolicy != nil { + l = m.DecisionPolicy.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateGroupAccountResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateGroupAccountAdminRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.NewAdmin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateGroupAccountAdminResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateGroupAccountDecisionPolicyRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.DecisionPolicy != nil { + l = m.DecisionPolicy.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateGroupAccountMetadataRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateGroupAccountMetadataResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCreateProposalRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Proposers) > 0 { + for _, s := range m.Proposers { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Msgs) > 0 { + for _, e := range m.Msgs { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgCreateProposalResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovTx(uint64(m.ProposalId)) + } + return n +} + +func (m *MsgVoteRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovTx(uint64(m.ProposalId)) + } + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Choice != 0 { + n += 1 + sovTx(uint64(m.Choice)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgVoteResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgExecRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovTx(uint64(m.ProposalId)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgExecResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreateGroupRequest) 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 ErrIntOverflowTx + } + 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: MsgCreateGroupRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateGroupRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Members = append(m.Members, Member{}) + if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateGroupResponse) 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 ErrIntOverflowTx + } + 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: MsgCreateGroupResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateGroupResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupMembersRequest) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupMembersRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupMembersRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MemberUpdates", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MemberUpdates = append(m.MemberUpdates, Member{}) + if err := m.MemberUpdates[len(m.MemberUpdates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupMembersResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupMembersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupMembersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupAdminRequest) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupAdminRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupAdminRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewAdmin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NewAdmin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupAdminResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupAdminResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupMetadataRequest) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupMetadataRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupMetadataRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupMetadataResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupMetadataResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateGroupAccountRequest) 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 ErrIntOverflowTx + } + 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: MsgCreateGroupAccountRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateGroupAccountRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DecisionPolicy", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DecisionPolicy == nil { + m.DecisionPolicy = &types.Any{} + } + if err := m.DecisionPolicy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateGroupAccountResponse) 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 ErrIntOverflowTx + } + 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: MsgCreateGroupAccountResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateGroupAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupAccountAdminRequest) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupAccountAdminRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupAccountAdminRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewAdmin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NewAdmin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupAccountAdminResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupAccountAdminResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupAccountAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupAccountDecisionPolicyRequest) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupAccountDecisionPolicyRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupAccountDecisionPolicyRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DecisionPolicy", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DecisionPolicy == nil { + m.DecisionPolicy = &types.Any{} + } + if err := m.DecisionPolicy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupAccountDecisionPolicyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupAccountDecisionPolicyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupAccountMetadataRequest) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupAccountMetadataRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupAccountMetadataRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupAccountMetadataResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupAccountMetadataResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupAccountMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateProposalRequest) 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 ErrIntOverflowTx + } + 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: MsgCreateProposalRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateProposalRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proposers", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proposers = append(m.Proposers, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msgs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Msgs = append(m.Msgs, &types.Any{}) + if err := m.Msgs[len(m.Msgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateProposalResponse) 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 ErrIntOverflowTx + } + 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: MsgCreateProposalResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateProposalResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgVoteRequest) 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 ErrIntOverflowTx + } + 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: MsgVoteRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgVoteRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Voter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Choice", wireType) + } + m.Choice = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Choice |= Choice(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgVoteResponse) 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 ErrIntOverflowTx + } + 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: MsgVoteResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgVoteResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgExecRequest) 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 ErrIntOverflowTx + } + 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: MsgExecRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgExecResponse) 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 ErrIntOverflowTx + } + 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: MsgExecResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/group/tx_cosmos.pb.go b/x/group/tx_cosmos.pb.go new file mode 100644 index 0000000000..f57f3f34a9 --- /dev/null +++ b/x/group/tx_cosmos.pb.go @@ -0,0 +1,610 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package group + +import ( + context "context" + types "github.com/regen-network/regen-ledger/types" + grpc "google.golang.org/grpc" +) + +// 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.SupportPackageIsVersion7 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type MsgClient interface { + // CreateGroup creates a new group with an admin account address, a list of members and some optional metadata. + CreateGroup(ctx context.Context, in *MsgCreateGroupRequest, opts ...grpc.CallOption) (*MsgCreateGroupResponse, error) + // UpdateGroupMembers updates the group members with given group id and admin address. + UpdateGroupMembers(ctx context.Context, in *MsgUpdateGroupMembersRequest, opts ...grpc.CallOption) (*MsgUpdateGroupMembersResponse, error) + // UpdateGroupAdmin updates the group admin with given group id and previous admin address. + UpdateGroupAdmin(ctx context.Context, in *MsgUpdateGroupAdminRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAdminResponse, error) + // UpdateGroupMetadata updates the group metadata with given group id and admin address. + UpdateGroupMetadata(ctx context.Context, in *MsgUpdateGroupMetadataRequest, opts ...grpc.CallOption) (*MsgUpdateGroupMetadataResponse, error) + // CreateGroupAccount creates a new group account using given DecisionPolicy. + CreateGroupAccount(ctx context.Context, in *MsgCreateGroupAccountRequest, opts ...grpc.CallOption) (*MsgCreateGroupAccountResponse, error) + // UpdateGroupAccountAdmin updates a group account admin. + UpdateGroupAccountAdmin(ctx context.Context, in *MsgUpdateGroupAccountAdminRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAccountAdminResponse, error) + // UpdateGroupAccountDecisionPolicy allows a group account decision policy to be updated. + UpdateGroupAccountDecisionPolicy(ctx context.Context, in *MsgUpdateGroupAccountDecisionPolicyRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAccountDecisionPolicyResponse, error) + // UpdateGroupAccountMetadata updates a group account metadata. + UpdateGroupAccountMetadata(ctx context.Context, in *MsgUpdateGroupAccountMetadataRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAccountMetadataResponse, error) + // CreateProposal submits a new proposal. + CreateProposal(ctx context.Context, in *MsgCreateProposalRequest, opts ...grpc.CallOption) (*MsgCreateProposalResponse, error) + // Vote allows a voter to vote on a proposal. + Vote(ctx context.Context, in *MsgVoteRequest, opts ...grpc.CallOption) (*MsgVoteResponse, error) + // Exec executes a proposal. + Exec(ctx context.Context, in *MsgExecRequest, opts ...grpc.CallOption) (*MsgExecResponse, error) +} + +type msgClient struct { + cc grpc.ClientConnInterface + _CreateGroup types.Invoker + _UpdateGroupMembers types.Invoker + _UpdateGroupAdmin types.Invoker + _UpdateGroupMetadata types.Invoker + _CreateGroupAccount types.Invoker + _UpdateGroupAccountAdmin types.Invoker + _UpdateGroupAccountDecisionPolicy types.Invoker + _UpdateGroupAccountMetadata types.Invoker + _CreateProposal types.Invoker + _Vote types.Invoker + _Exec types.Invoker +} + +func NewMsgClient(cc grpc.ClientConnInterface) MsgClient { + return &msgClient{cc: cc} +} + +func (c *msgClient) CreateGroup(ctx context.Context, in *MsgCreateGroupRequest, opts ...grpc.CallOption) (*MsgCreateGroupResponse, error) { + if invoker := c._CreateGroup; invoker != nil { + var out MsgCreateGroupResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._CreateGroup, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/CreateGroup") + if err != nil { + var out MsgCreateGroupResponse + err = c._CreateGroup(ctx, in, &out) + return &out, err + } + } + out := new(MsgCreateGroupResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/CreateGroup", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateGroupMembers(ctx context.Context, in *MsgUpdateGroupMembersRequest, opts ...grpc.CallOption) (*MsgUpdateGroupMembersResponse, error) { + if invoker := c._UpdateGroupMembers; invoker != nil { + var out MsgUpdateGroupMembersResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._UpdateGroupMembers, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/UpdateGroupMembers") + if err != nil { + var out MsgUpdateGroupMembersResponse + err = c._UpdateGroupMembers(ctx, in, &out) + return &out, err + } + } + out := new(MsgUpdateGroupMembersResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupMembers", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateGroupAdmin(ctx context.Context, in *MsgUpdateGroupAdminRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAdminResponse, error) { + if invoker := c._UpdateGroupAdmin; invoker != nil { + var out MsgUpdateGroupAdminResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._UpdateGroupAdmin, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/UpdateGroupAdmin") + if err != nil { + var out MsgUpdateGroupAdminResponse + err = c._UpdateGroupAdmin(ctx, in, &out) + return &out, err + } + } + out := new(MsgUpdateGroupAdminResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAdmin", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateGroupMetadata(ctx context.Context, in *MsgUpdateGroupMetadataRequest, opts ...grpc.CallOption) (*MsgUpdateGroupMetadataResponse, error) { + if invoker := c._UpdateGroupMetadata; invoker != nil { + var out MsgUpdateGroupMetadataResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._UpdateGroupMetadata, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/UpdateGroupMetadata") + if err != nil { + var out MsgUpdateGroupMetadataResponse + err = c._UpdateGroupMetadata(ctx, in, &out) + return &out, err + } + } + out := new(MsgUpdateGroupMetadataResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupMetadata", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) CreateGroupAccount(ctx context.Context, in *MsgCreateGroupAccountRequest, opts ...grpc.CallOption) (*MsgCreateGroupAccountResponse, error) { + if invoker := c._CreateGroupAccount; invoker != nil { + var out MsgCreateGroupAccountResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._CreateGroupAccount, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/CreateGroupAccount") + if err != nil { + var out MsgCreateGroupAccountResponse + err = c._CreateGroupAccount(ctx, in, &out) + return &out, err + } + } + out := new(MsgCreateGroupAccountResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/CreateGroupAccount", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateGroupAccountAdmin(ctx context.Context, in *MsgUpdateGroupAccountAdminRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAccountAdminResponse, error) { + if invoker := c._UpdateGroupAccountAdmin; invoker != nil { + var out MsgUpdateGroupAccountAdminResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._UpdateGroupAccountAdmin, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/UpdateGroupAccountAdmin") + if err != nil { + var out MsgUpdateGroupAccountAdminResponse + err = c._UpdateGroupAccountAdmin(ctx, in, &out) + return &out, err + } + } + out := new(MsgUpdateGroupAccountAdminResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAccountAdmin", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateGroupAccountDecisionPolicy(ctx context.Context, in *MsgUpdateGroupAccountDecisionPolicyRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAccountDecisionPolicyResponse, error) { + if invoker := c._UpdateGroupAccountDecisionPolicy; invoker != nil { + var out MsgUpdateGroupAccountDecisionPolicyResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._UpdateGroupAccountDecisionPolicy, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/UpdateGroupAccountDecisionPolicy") + if err != nil { + var out MsgUpdateGroupAccountDecisionPolicyResponse + err = c._UpdateGroupAccountDecisionPolicy(ctx, in, &out) + return &out, err + } + } + out := new(MsgUpdateGroupAccountDecisionPolicyResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAccountDecisionPolicy", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateGroupAccountMetadata(ctx context.Context, in *MsgUpdateGroupAccountMetadataRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAccountMetadataResponse, error) { + if invoker := c._UpdateGroupAccountMetadata; invoker != nil { + var out MsgUpdateGroupAccountMetadataResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._UpdateGroupAccountMetadata, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/UpdateGroupAccountMetadata") + if err != nil { + var out MsgUpdateGroupAccountMetadataResponse + err = c._UpdateGroupAccountMetadata(ctx, in, &out) + return &out, err + } + } + out := new(MsgUpdateGroupAccountMetadataResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAccountMetadata", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) CreateProposal(ctx context.Context, in *MsgCreateProposalRequest, opts ...grpc.CallOption) (*MsgCreateProposalResponse, error) { + if invoker := c._CreateProposal; invoker != nil { + var out MsgCreateProposalResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._CreateProposal, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/CreateProposal") + if err != nil { + var out MsgCreateProposalResponse + err = c._CreateProposal(ctx, in, &out) + return &out, err + } + } + out := new(MsgCreateProposalResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/CreateProposal", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Vote(ctx context.Context, in *MsgVoteRequest, opts ...grpc.CallOption) (*MsgVoteResponse, error) { + if invoker := c._Vote; invoker != nil { + var out MsgVoteResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._Vote, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/Vote") + if err != nil { + var out MsgVoteResponse + err = c._Vote(ctx, in, &out) + return &out, err + } + } + out := new(MsgVoteResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/Vote", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Exec(ctx context.Context, in *MsgExecRequest, opts ...grpc.CallOption) (*MsgExecResponse, error) { + if invoker := c._Exec; invoker != nil { + var out MsgExecResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._Exec, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/Exec") + if err != nil { + var out MsgExecResponse + err = c._Exec(ctx, in, &out) + return &out, err + } + } + out := new(MsgExecResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/Exec", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // CreateGroup creates a new group with an admin account address, a list of members and some optional metadata. + CreateGroup(types.Context, *MsgCreateGroupRequest) (*MsgCreateGroupResponse, error) + // UpdateGroupMembers updates the group members with given group id and admin address. + UpdateGroupMembers(types.Context, *MsgUpdateGroupMembersRequest) (*MsgUpdateGroupMembersResponse, error) + // UpdateGroupAdmin updates the group admin with given group id and previous admin address. + UpdateGroupAdmin(types.Context, *MsgUpdateGroupAdminRequest) (*MsgUpdateGroupAdminResponse, error) + // UpdateGroupMetadata updates the group metadata with given group id and admin address. + UpdateGroupMetadata(types.Context, *MsgUpdateGroupMetadataRequest) (*MsgUpdateGroupMetadataResponse, error) + // CreateGroupAccount creates a new group account using given DecisionPolicy. + CreateGroupAccount(types.Context, *MsgCreateGroupAccountRequest) (*MsgCreateGroupAccountResponse, error) + // UpdateGroupAccountAdmin updates a group account admin. + UpdateGroupAccountAdmin(types.Context, *MsgUpdateGroupAccountAdminRequest) (*MsgUpdateGroupAccountAdminResponse, error) + // UpdateGroupAccountDecisionPolicy allows a group account decision policy to be updated. + UpdateGroupAccountDecisionPolicy(types.Context, *MsgUpdateGroupAccountDecisionPolicyRequest) (*MsgUpdateGroupAccountDecisionPolicyResponse, error) + // UpdateGroupAccountMetadata updates a group account metadata. + UpdateGroupAccountMetadata(types.Context, *MsgUpdateGroupAccountMetadataRequest) (*MsgUpdateGroupAccountMetadataResponse, error) + // CreateProposal submits a new proposal. + CreateProposal(types.Context, *MsgCreateProposalRequest) (*MsgCreateProposalResponse, error) + // Vote allows a voter to vote on a proposal. + Vote(types.Context, *MsgVoteRequest) (*MsgVoteResponse, error) + // Exec executes a proposal. + Exec(types.Context, *MsgExecRequest) (*MsgExecResponse, error) +} + +func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) { + s.RegisterService(&Msg_ServiceDesc, srv) +} + +func _Msg_CreateGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateGroupRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateGroup(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/CreateGroup", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateGroup(types.UnwrapSDKContext(ctx), req.(*MsgCreateGroupRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateGroupMembers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateGroupMembersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateGroupMembers(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupMembers", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateGroupMembers(types.UnwrapSDKContext(ctx), req.(*MsgUpdateGroupMembersRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateGroupAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateGroupAdminRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateGroupAdmin(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAdmin", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateGroupAdmin(types.UnwrapSDKContext(ctx), req.(*MsgUpdateGroupAdminRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateGroupMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateGroupMetadataRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateGroupMetadata(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupMetadata", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateGroupMetadata(types.UnwrapSDKContext(ctx), req.(*MsgUpdateGroupMetadataRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_CreateGroupAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateGroupAccountRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateGroupAccount(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/CreateGroupAccount", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateGroupAccount(types.UnwrapSDKContext(ctx), req.(*MsgCreateGroupAccountRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateGroupAccountAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateGroupAccountAdminRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateGroupAccountAdmin(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAccountAdmin", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateGroupAccountAdmin(types.UnwrapSDKContext(ctx), req.(*MsgUpdateGroupAccountAdminRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateGroupAccountDecisionPolicy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateGroupAccountDecisionPolicyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateGroupAccountDecisionPolicy(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAccountDecisionPolicy", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateGroupAccountDecisionPolicy(types.UnwrapSDKContext(ctx), req.(*MsgUpdateGroupAccountDecisionPolicyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateGroupAccountMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateGroupAccountMetadataRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateGroupAccountMetadata(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAccountMetadata", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateGroupAccountMetadata(types.UnwrapSDKContext(ctx), req.(*MsgUpdateGroupAccountMetadataRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_CreateProposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateProposalRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateProposal(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/CreateProposal", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateProposal(types.UnwrapSDKContext(ctx), req.(*MsgCreateProposalRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Vote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgVoteRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Vote(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/Vote", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Vote(types.UnwrapSDKContext(ctx), req.(*MsgVoteRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Exec_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgExecRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Exec(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/Exec", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Exec(types.UnwrapSDKContext(ctx), req.(*MsgExecRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Msg_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "regen.group.v1alpha1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateGroup", + Handler: _Msg_CreateGroup_Handler, + }, + { + MethodName: "UpdateGroupMembers", + Handler: _Msg_UpdateGroupMembers_Handler, + }, + { + MethodName: "UpdateGroupAdmin", + Handler: _Msg_UpdateGroupAdmin_Handler, + }, + { + MethodName: "UpdateGroupMetadata", + Handler: _Msg_UpdateGroupMetadata_Handler, + }, + { + MethodName: "CreateGroupAccount", + Handler: _Msg_CreateGroupAccount_Handler, + }, + { + MethodName: "UpdateGroupAccountAdmin", + Handler: _Msg_UpdateGroupAccountAdmin_Handler, + }, + { + MethodName: "UpdateGroupAccountDecisionPolicy", + Handler: _Msg_UpdateGroupAccountDecisionPolicy_Handler, + }, + { + MethodName: "UpdateGroupAccountMetadata", + Handler: _Msg_UpdateGroupAccountMetadata_Handler, + }, + { + MethodName: "CreateProposal", + Handler: _Msg_CreateProposal_Handler, + }, + { + MethodName: "Vote", + Handler: _Msg_Vote_Handler, + }, + { + MethodName: "Exec", + Handler: _Msg_Exec_Handler, + }, + }, + Metadata: "regen/group/v1alpha1/tx.proto", +} + +const ( + MsgCreateGroupMethod = "/regen.group.v1alpha1.Msg/CreateGroup" + MsgUpdateGroupMembersMethod = "/regen.group.v1alpha1.Msg/UpdateGroupMembers" + MsgUpdateGroupAdminMethod = "/regen.group.v1alpha1.Msg/UpdateGroupAdmin" + MsgUpdateGroupMetadataMethod = "/regen.group.v1alpha1.Msg/UpdateGroupMetadata" + MsgCreateGroupAccountMethod = "/regen.group.v1alpha1.Msg/CreateGroupAccount" + MsgUpdateGroupAccountAdminMethod = "/regen.group.v1alpha1.Msg/UpdateGroupAccountAdmin" + MsgUpdateGroupAccountDecisionPolicyMethod = "/regen.group.v1alpha1.Msg/UpdateGroupAccountDecisionPolicy" + MsgUpdateGroupAccountMetadataMethod = "/regen.group.v1alpha1.Msg/UpdateGroupAccountMetadata" + MsgCreateProposalMethod = "/regen.group.v1alpha1.Msg/CreateProposal" + MsgVoteMethod = "/regen.group.v1alpha1.Msg/Vote" + MsgExecMethod = "/regen.group.v1alpha1.Msg/Exec" +) diff --git a/x/group/types.go b/x/group/types.go new file mode 100644 index 0000000000..eab5d8c85d --- /dev/null +++ b/x/group/types.go @@ -0,0 +1,504 @@ +package group + +import ( + "fmt" + "time" + + "github.com/cockroachdb/apd/v2" + proto "github.com/gogo/protobuf/proto" + "github.com/gogo/protobuf/types" + "github.com/regen-network/regen-ledger/math" + "github.com/regen-network/regen-ledger/orm" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +type ID uint64 + +func (g ID) Uint64() uint64 { + return uint64(g) +} + +func (g ID) Empty() bool { + return g == 0 +} + +func (g ID) Bytes() []byte { + return orm.EncodeSequence(uint64(g)) +} + +type ProposalID uint64 + +func (p ProposalID) Bytes() []byte { + return orm.EncodeSequence(uint64(p)) +} + +func (p ProposalID) Uint64() uint64 { + return uint64(p) +} +func (p ProposalID) Empty() bool { + return p == 0 +} + +type DecisionPolicyResult struct { + Allow bool + Final bool +} + +// DecisionPolicy is the persistent set of rules to determine the result of election on a proposal. +type DecisionPolicy interface { + codec.ProtoMarshaler + + orm.Validateable + GetTimeout() types.Duration + Allow(tally Tally, totalPower string, votingDuration time.Duration) (DecisionPolicyResult, error) + Validate(g GroupInfo) error +} + +// Implements DecisionPolicy Interface +var _ DecisionPolicy = &ThresholdDecisionPolicy{} + +// NewThresholdDecisionPolicy creates a threshold DecisionPolicy +func NewThresholdDecisionPolicy(threshold string, timeout types.Duration) DecisionPolicy { + return &ThresholdDecisionPolicy{threshold, timeout} +} + +// Allow allows a proposal to pass when the tally of yes votes equals or exceeds the threshold before the timeout. +func (p ThresholdDecisionPolicy) Allow(tally Tally, totalPower string, votingDuration time.Duration) (DecisionPolicyResult, error) { + timeout, err := types.DurationFromProto(&p.Timeout) + if err != nil { + return DecisionPolicyResult{}, err + } + if timeout <= votingDuration { + return DecisionPolicyResult{Allow: false, Final: true}, nil + } + + threshold, err := math.ParsePositiveDecimal(p.Threshold) + if err != nil { + return DecisionPolicyResult{}, err + } + yesCount, err := math.ParseNonNegativeDecimal(tally.YesCount) + if err != nil { + return DecisionPolicyResult{}, err + } + if yesCount.Cmp(threshold) >= 0 { + return DecisionPolicyResult{Allow: true, Final: true}, nil + } + + totalPowerDec, err := math.ParseNonNegativeDecimal(totalPower) + if err != nil { + return DecisionPolicyResult{}, err + } + totalCounts, err := tally.TotalCounts() + if err != nil { + return DecisionPolicyResult{}, err + } + var undecided apd.Decimal + err = math.SafeSub(&undecided, totalPowerDec, totalCounts) + if err != nil { + return DecisionPolicyResult{}, err + } + var sum apd.Decimal + err = math.Add(&sum, yesCount, &undecided) + if err != nil { + return DecisionPolicyResult{}, err + } + if sum.Cmp(threshold) < 0 { + return DecisionPolicyResult{Allow: false, Final: true}, nil + } + return DecisionPolicyResult{Allow: false, Final: false}, nil +} + +// Validate returns an error if policy threshold is greater than the total group weight +func (p *ThresholdDecisionPolicy) Validate(g GroupInfo) error { + threshold, err := math.ParsePositiveDecimal(p.Threshold) + if err != nil { + return sdkerrors.Wrap(err, "threshold") + } + totalWeight, err := math.ParseNonNegativeDecimal(g.TotalWeight) + if err != nil { + return sdkerrors.Wrap(err, "group total weight") + } + if threshold.Cmp(totalWeight) > 0 { + return sdkerrors.Wrap(ErrInvalid, "policy threshold should not be greater than the total group weight") + } + return nil +} + +func (p ThresholdDecisionPolicy) ValidateBasic() error { + if _, err := math.ParsePositiveDecimal(p.Threshold); err != nil { + return sdkerrors.Wrap(err, "threshold") + } + + timeout, err := types.DurationFromProto(&p.Timeout) + if err != nil { + return sdkerrors.Wrap(err, "timeout") + } + + if timeout <= time.Nanosecond { + return sdkerrors.Wrap(ErrInvalid, "timeout") + } + return nil +} + +func (g GroupMember) PrimaryKey() []byte { + result := make([]byte, 8, 8+len(g.Member.Address)) + copy(result[0:8], ID(g.GroupId).Bytes()) + result = append(result, g.Member.Address...) + return result +} + +func (g GroupAccountInfo) PrimaryKey() []byte { + addr, err := sdk.AccAddressFromBech32(g.Address) + if err != nil { + panic(err) + } + return addr +} + +var _ orm.Validateable = GroupAccountInfo{} + +// NewGroupAccountInfo creates a new GroupAccountInfo instance +func NewGroupAccountInfo(address sdk.AccAddress, group uint64, admin sdk.AccAddress, metadata []byte, version uint64, decisionPolicy DecisionPolicy) (GroupAccountInfo, error) { + p := GroupAccountInfo{ + Address: address.String(), + GroupId: group, + Admin: admin.String(), + Metadata: metadata, + Version: version, + } + + err := p.SetDecisionPolicy(decisionPolicy) + if err != nil { + return GroupAccountInfo{}, err + } + + return p, nil +} + +func (g *GroupAccountInfo) SetDecisionPolicy(decisionPolicy DecisionPolicy) error { + msg, ok := decisionPolicy.(proto.Message) + if !ok { + return fmt.Errorf("can't proto marshal %T", msg) + } + any, err := codectypes.NewAnyWithValue(msg) + if err != nil { + return err + } + g.DecisionPolicy = any + return nil +} + +func (g GroupAccountInfo) GetDecisionPolicy() DecisionPolicy { + decisionPolicy, ok := g.DecisionPolicy.GetCachedValue().(DecisionPolicy) + if !ok { + return nil + } + return decisionPolicy +} + +func (g GroupAccountInfo) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(g.Admin) + if err != nil { + return sdkerrors.Wrap(err, "admin") + } + + _, err = sdk.AccAddressFromBech32(g.Address) + if err != nil { + return sdkerrors.Wrap(err, "group account") + } + + if g.GroupId == 0 { + return sdkerrors.Wrap(ErrEmpty, "group") + } + if g.Version == 0 { + return sdkerrors.Wrap(ErrEmpty, "version") + } + policy := g.GetDecisionPolicy() + + if policy == nil { + return sdkerrors.Wrap(ErrEmpty, "policy") + } + if err := policy.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "policy") + } + return nil +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (g GroupAccountInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + var decisionPolicy DecisionPolicy + return unpacker.UnpackAny(g.DecisionPolicy, &decisionPolicy) +} + +func (v Vote) PrimaryKey() []byte { + result := make([]byte, 8, 8+len(v.Voter)) + copy(result[0:8], ProposalID(v.ProposalId).Bytes()) + result = append(result, v.Voter...) + return result +} + +var _ orm.Validateable = Vote{} + +func (v Vote) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(v.Voter) + if err != nil { + return sdkerrors.Wrap(err, "voter") + } + + if v.ProposalId == 0 { + return sdkerrors.Wrap(ErrEmpty, "proposal") + } + if v.Choice == Choice_CHOICE_UNSPECIFIED { + return sdkerrors.Wrap(ErrEmpty, "choice") + } + if _, ok := Choice_name[int32(v.Choice)]; !ok { + return sdkerrors.Wrap(ErrInvalid, "choice") + } + t, err := types.TimestampFromProto(&v.SubmittedAt) + if err != nil { + return sdkerrors.Wrap(err, "submitted at") + } + if t.IsZero() { + return sdkerrors.Wrap(ErrEmpty, "submitted at") + } + return nil +} + +// ChoiceFromString returns a Choice from a string. It returns an error +// if the string is invalid. +func ChoiceFromString(str string) (Choice, error) { + choice, ok := Choice_value[str] + if !ok { + return Choice_CHOICE_UNSPECIFIED, fmt.Errorf("'%s' is not a valid vote choice", str) + } + return Choice(choice), nil +} + +// MaxMetadataLength defines the max length of the metadata bytes field +// for various entities within the group module +// TODO: This could be used as params once x/params is upgraded to use protobuf +const MaxMetadataLength = 255 + +var _ orm.Validateable = GroupInfo{} + +func (g GroupInfo) ValidateBasic() error { + if g.GroupId == 0 { + return sdkerrors.Wrap(ErrEmpty, "group") + } + + _, err := sdk.AccAddressFromBech32(g.Admin) + if err != nil { + return sdkerrors.Wrap(err, "admin") + } + + if _, err := math.ParseNonNegativeDecimal(g.TotalWeight); err != nil { + return sdkerrors.Wrap(err, "total weight") + } + if g.Version == 0 { + return sdkerrors.Wrap(ErrEmpty, "version") + } + return nil +} + +func (g GroupInfo) PrimaryKey() []byte { + return orm.EncodeSequence(g.GroupId) +} + +var _ orm.Validateable = GroupMember{} + +func (g GroupMember) ValidateBasic() error { + if g.GroupId == 0 { + return sdkerrors.Wrap(ErrEmpty, "group") + } + + err := g.Member.ValidateBasic() + if err != nil { + return sdkerrors.Wrap(err, "member") + } + return nil +} + +func (t *Tally) Sub(vote Vote, weight string) error { + if err := t.operation(vote, weight, math.SafeSub); err != nil { + return err + } + return nil +} + +func (t *Tally) Add(vote Vote, weight string) error { + if err := t.operation(vote, weight, math.Add); err != nil { + return err + } + return nil +} + +type operation func(res, x, y *apd.Decimal) error + +func (t *Tally) operation(vote Vote, weight string, op operation) error { + weightDec, err := math.ParsePositiveDecimal(weight) + if err != nil { + return err + } + + yesCount, err := t.GetYesCount() + if err != nil { + return sdkerrors.Wrap(err, "yes count") + } + noCount, err := t.GetNoCount() + if err != nil { + return sdkerrors.Wrap(err, "no count") + } + abstainCount, err := t.GetAbstainCount() + if err != nil { + return sdkerrors.Wrap(err, "abstain count") + } + vetoCount, err := t.GetVetoCount() + if err != nil { + return sdkerrors.Wrap(err, "veto count") + } + + switch vote.Choice { + case Choice_CHOICE_YES: + err := op(yesCount, yesCount, weightDec) + if err != nil { + return sdkerrors.Wrap(err, "yes count") + } + t.YesCount = math.DecimalString(yesCount) + case Choice_CHOICE_NO: + err := op(noCount, noCount, weightDec) + if err != nil { + return sdkerrors.Wrap(err, "no count") + } + t.NoCount = math.DecimalString(noCount) + case Choice_CHOICE_ABSTAIN: + err := op(abstainCount, abstainCount, weightDec) + if err != nil { + return sdkerrors.Wrap(err, "abstain count") + } + t.AbstainCount = math.DecimalString(abstainCount) + case Choice_CHOICE_VETO: + err := op(vetoCount, vetoCount, weightDec) + if err != nil { + return sdkerrors.Wrap(err, "veto count") + } + t.VetoCount = math.DecimalString(vetoCount) + default: + return sdkerrors.Wrapf(ErrInvalid, "unknown choice %s", vote.Choice.String()) + } + return nil +} + +// TotalCounts is the sum of all weights. +func (t Tally) TotalCounts() (*apd.Decimal, error) { + yesCount, err := t.GetYesCount() + if err != nil { + return nil, sdkerrors.Wrap(err, "yes count") + } + noCount, err := t.GetNoCount() + if err != nil { + return nil, sdkerrors.Wrap(err, "no count") + } + abstainCount, err := t.GetAbstainCount() + if err != nil { + return nil, sdkerrors.Wrap(err, "abstain count") + } + vetoCount, err := t.GetVetoCount() + if err != nil { + return nil, sdkerrors.Wrap(err, "veto count") + } + + totalCounts := apd.New(0, 0) + err = math.Add(totalCounts, totalCounts, yesCount) + if err != nil { + return nil, err + } + err = math.Add(totalCounts, totalCounts, noCount) + if err != nil { + return nil, err + } + err = math.Add(totalCounts, totalCounts, abstainCount) + if err != nil { + return nil, err + } + err = math.Add(totalCounts, totalCounts, vetoCount) + if err != nil { + return nil, err + } + return totalCounts, nil +} + +func (t Tally) GetYesCount() (*apd.Decimal, error) { + yesCount, err := math.ParseNonNegativeDecimal(t.YesCount) + if err != nil { + return nil, err + } + return yesCount, nil +} + +func (t Tally) GetNoCount() (*apd.Decimal, error) { + noCount, err := math.ParseNonNegativeDecimal(t.NoCount) + if err != nil { + return nil, err + } + return noCount, nil +} + +func (t Tally) GetAbstainCount() (*apd.Decimal, error) { + abstainCount, err := math.ParseNonNegativeDecimal(t.AbstainCount) + if err != nil { + return nil, err + } + return abstainCount, nil +} + +func (t Tally) GetVetoCount() (*apd.Decimal, error) { + vetoCount, err := math.ParseNonNegativeDecimal(t.VetoCount) + if err != nil { + return nil, err + } + return vetoCount, nil +} + +func (t Tally) ValidateBasic() error { + if _, err := t.GetYesCount(); err != nil { + return sdkerrors.Wrap(err, "yes count") + } + if _, err := t.GetNoCount(); err != nil { + return sdkerrors.Wrap(err, "no count") + } + if _, err := t.GetAbstainCount(); err != nil { + return sdkerrors.Wrap(err, "abstain count") + } + if _, err := t.GetVetoCount(); err != nil { + return sdkerrors.Wrap(err, "veto count") + } + return nil +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (q QueryGroupAccountsByGroupResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + for _, g := range q.GroupAccounts { + err := g.UnpackInterfaces(unpacker) + if err != nil { + return err + } + } + + return nil +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (q QueryGroupAccountsByAdminResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + for _, g := range q.GroupAccounts { + err := g.UnpackInterfaces(unpacker) + if err != nil { + return err + } + } + + return nil +} diff --git a/x/group/types.pb.go b/x/group/types.pb.go new file mode 100644 index 0000000000..59d18f8de5 --- /dev/null +++ b/x/group/types.pb.go @@ -0,0 +1,3357 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: regen/group/v1alpha1/types.proto + +package group + +import ( + bytes "bytes" + fmt "fmt" + types1 "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + types "github.com/gogo/protobuf/types" + _ "github.com/regen-network/cosmos-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 + +// Choice defines available types of choices for voting. +type Choice int32 + +const ( + // CHOICE_UNSPECIFIED defines a no-op voting choice. + Choice_CHOICE_UNSPECIFIED Choice = 0 + // CHOICE_NO defines a no voting choice. + Choice_CHOICE_NO Choice = 1 + // CHOICE_YES defines a yes voting choice. + Choice_CHOICE_YES Choice = 2 + // CHOICE_ABSTAIN defines an abstaining voting choice. + Choice_CHOICE_ABSTAIN Choice = 3 + // CHOICE_VETO defines a voting choice with veto. + Choice_CHOICE_VETO Choice = 4 +) + +var Choice_name = map[int32]string{ + 0: "CHOICE_UNSPECIFIED", + 1: "CHOICE_NO", + 2: "CHOICE_YES", + 3: "CHOICE_ABSTAIN", + 4: "CHOICE_VETO", +} + +var Choice_value = map[string]int32{ + "CHOICE_UNSPECIFIED": 0, + "CHOICE_NO": 1, + "CHOICE_YES": 2, + "CHOICE_ABSTAIN": 3, + "CHOICE_VETO": 4, +} + +func (x Choice) String() string { + return proto.EnumName(Choice_name, int32(x)) +} + +func (Choice) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{0} +} + +// Status defines proposal statuses. +type Proposal_Status int32 + +const ( + // An empty value is invalid and not allowed. + ProposalStatusInvalid Proposal_Status = 0 + // Initial status of a proposal when persisted. + ProposalStatusSubmitted Proposal_Status = 1 + // Final status of a proposal when the final tally was executed. + ProposalStatusClosed Proposal_Status = 2 + // Final status of a proposal when the group was modified before the final tally. + ProposalStatusAborted Proposal_Status = 3 +) + +var Proposal_Status_name = map[int32]string{ + 0: "STATUS_UNSPECIFIED", + 1: "STATUS_SUBMITTED", + 2: "STATUS_CLOSED", + 3: "STATUS_ABORTED", +} + +var Proposal_Status_value = map[string]int32{ + "STATUS_UNSPECIFIED": 0, + "STATUS_SUBMITTED": 1, + "STATUS_CLOSED": 2, + "STATUS_ABORTED": 3, +} + +func (x Proposal_Status) String() string { + return proto.EnumName(Proposal_Status_name, int32(x)) +} + +func (Proposal_Status) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{6, 0} +} + +// Result defines types of proposal results. +type Proposal_Result int32 + +const ( + // An empty value is invalid and not allowed + ProposalResultInvalid Proposal_Result = 0 + // Until a final tally has happened the status is unfinalized + ProposalResultUnfinalized Proposal_Result = 1 + // Final result of the tally + ProposalResultAccepted Proposal_Result = 2 + // Final result of the tally + ProposalResultRejected Proposal_Result = 3 +) + +var Proposal_Result_name = map[int32]string{ + 0: "RESULT_UNSPECIFIED", + 1: "RESULT_UNFINALIZED", + 2: "RESULT_ACCEPTED", + 3: "RESULT_REJECTED", +} + +var Proposal_Result_value = map[string]int32{ + "RESULT_UNSPECIFIED": 0, + "RESULT_UNFINALIZED": 1, + "RESULT_ACCEPTED": 2, + "RESULT_REJECTED": 3, +} + +func (x Proposal_Result) String() string { + return proto.EnumName(Proposal_Result_name, int32(x)) +} + +func (Proposal_Result) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{6, 1} +} + +// ExecutorResult defines types of proposal executor results. +type Proposal_ExecutorResult int32 + +const ( + // An empty value is not allowed. + ProposalExecutorResultInvalid Proposal_ExecutorResult = 0 + // We have not yet run the executor. + ProposalExecutorResultNotRun Proposal_ExecutorResult = 1 + // The executor was successful and proposed action updated state. + ProposalExecutorResultSuccess Proposal_ExecutorResult = 2 + // The executor returned an error and proposed action didn't update state. + ProposalExecutorResultFailure Proposal_ExecutorResult = 3 +) + +var Proposal_ExecutorResult_name = map[int32]string{ + 0: "EXECUTOR_RESULT_UNSPECIFIED", + 1: "EXECUTOR_RESULT_NOT_RUN", + 2: "EXECUTOR_RESULT_SUCCESS", + 3: "EXECUTOR_RESULT_FAILURE", +} + +var Proposal_ExecutorResult_value = map[string]int32{ + "EXECUTOR_RESULT_UNSPECIFIED": 0, + "EXECUTOR_RESULT_NOT_RUN": 1, + "EXECUTOR_RESULT_SUCCESS": 2, + "EXECUTOR_RESULT_FAILURE": 3, +} + +func (x Proposal_ExecutorResult) String() string { + return proto.EnumName(Proposal_ExecutorResult_name, int32(x)) +} + +func (Proposal_ExecutorResult) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{6, 2} +} + +// Member represents a group member with an account address, +// non-zero weight and metadata. +type Member struct { + // address is the member's account address. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // weight is the member's voting weight that should be greater than 0. + Weight string `protobuf:"bytes,2,opt,name=weight,proto3" json:"weight,omitempty"` + // metadata is any arbitrary metadata to attached to the member. + Metadata []byte `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (m *Member) Reset() { *m = Member{} } +func (m *Member) String() string { return proto.CompactTextString(m) } +func (*Member) ProtoMessage() {} +func (*Member) Descriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{0} +} +func (m *Member) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Member) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Member.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 *Member) XXX_Merge(src proto.Message) { + xxx_messageInfo_Member.Merge(m, src) +} +func (m *Member) XXX_Size() int { + return m.Size() +} +func (m *Member) XXX_DiscardUnknown() { + xxx_messageInfo_Member.DiscardUnknown(m) +} + +var xxx_messageInfo_Member proto.InternalMessageInfo + +func (m *Member) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *Member) GetWeight() string { + if m != nil { + return m.Weight + } + return "" +} + +func (m *Member) GetMetadata() []byte { + if m != nil { + return m.Metadata + } + return nil +} + +// Members defines a repeated slice of Member objects. +type Members struct { + // members is the list of members. + Members []Member `protobuf:"bytes,1,rep,name=members,proto3" json:"members"` +} + +func (m *Members) Reset() { *m = Members{} } +func (m *Members) String() string { return proto.CompactTextString(m) } +func (*Members) ProtoMessage() {} +func (*Members) Descriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{1} +} +func (m *Members) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Members) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Members.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 *Members) XXX_Merge(src proto.Message) { + xxx_messageInfo_Members.Merge(m, src) +} +func (m *Members) XXX_Size() int { + return m.Size() +} +func (m *Members) XXX_DiscardUnknown() { + xxx_messageInfo_Members.DiscardUnknown(m) +} + +var xxx_messageInfo_Members proto.InternalMessageInfo + +func (m *Members) GetMembers() []Member { + if m != nil { + return m.Members + } + return nil +} + +// ThresholdDecisionPolicy implements the DecisionPolicy interface +type ThresholdDecisionPolicy struct { + // threshold is the minimum weighted sum of yes votes that must be met or exceeded for a proposal to succeed. + Threshold string `protobuf:"bytes,1,opt,name=threshold,proto3" json:"threshold,omitempty"` + // timeout is the duration from submission of a proposal to the end of voting period + // Within this times votes and exec messages can be submitted. + Timeout types.Duration `protobuf:"bytes,2,opt,name=timeout,proto3" json:"timeout"` +} + +func (m *ThresholdDecisionPolicy) Reset() { *m = ThresholdDecisionPolicy{} } +func (m *ThresholdDecisionPolicy) String() string { return proto.CompactTextString(m) } +func (*ThresholdDecisionPolicy) ProtoMessage() {} +func (*ThresholdDecisionPolicy) Descriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{2} +} +func (m *ThresholdDecisionPolicy) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ThresholdDecisionPolicy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ThresholdDecisionPolicy.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 *ThresholdDecisionPolicy) XXX_Merge(src proto.Message) { + xxx_messageInfo_ThresholdDecisionPolicy.Merge(m, src) +} +func (m *ThresholdDecisionPolicy) XXX_Size() int { + return m.Size() +} +func (m *ThresholdDecisionPolicy) XXX_DiscardUnknown() { + xxx_messageInfo_ThresholdDecisionPolicy.DiscardUnknown(m) +} + +var xxx_messageInfo_ThresholdDecisionPolicy proto.InternalMessageInfo + +func (m *ThresholdDecisionPolicy) GetThreshold() string { + if m != nil { + return m.Threshold + } + return "" +} + +func (m *ThresholdDecisionPolicy) GetTimeout() types.Duration { + if m != nil { + return m.Timeout + } + return types.Duration{} +} + +// GroupInfo represents the high-level on-chain information for a group. +type GroupInfo struct { + // group_id is the unique ID of the group. + GroupId uint64 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + // admin is the account address of the group's admin. + Admin string `protobuf:"bytes,2,opt,name=admin,proto3" json:"admin,omitempty"` + // metadata is any arbitrary metadata to attached to the group. + Metadata []byte `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` + // version is used to track changes to a group's membership structure that + // would break existing proposals. Whenever any members weight is changed, + // or any member is added or removed this version is incremented and will + // cause proposals based on older versions of this group to fail + Version uint64 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"` + // total_weight is the sum of the group members' weights. + TotalWeight string `protobuf:"bytes,5,opt,name=total_weight,json=totalWeight,proto3" json:"total_weight,omitempty"` +} + +func (m *GroupInfo) Reset() { *m = GroupInfo{} } +func (m *GroupInfo) String() string { return proto.CompactTextString(m) } +func (*GroupInfo) ProtoMessage() {} +func (*GroupInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{3} +} +func (m *GroupInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GroupInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GroupInfo.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 *GroupInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_GroupInfo.Merge(m, src) +} +func (m *GroupInfo) XXX_Size() int { + return m.Size() +} +func (m *GroupInfo) XXX_DiscardUnknown() { + xxx_messageInfo_GroupInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_GroupInfo proto.InternalMessageInfo + +func (m *GroupInfo) GetGroupId() uint64 { + if m != nil { + return m.GroupId + } + return 0 +} + +func (m *GroupInfo) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func (m *GroupInfo) GetMetadata() []byte { + if m != nil { + return m.Metadata + } + return nil +} + +func (m *GroupInfo) GetVersion() uint64 { + if m != nil { + return m.Version + } + return 0 +} + +func (m *GroupInfo) GetTotalWeight() string { + if m != nil { + return m.TotalWeight + } + return "" +} + +// GroupMember represents the relationship between a group and a member. +type GroupMember struct { + // group_id is the unique ID of the group. + GroupId uint64 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + // member is the member data. + Member *Member `protobuf:"bytes,2,opt,name=member,proto3" json:"member,omitempty"` +} + +func (m *GroupMember) Reset() { *m = GroupMember{} } +func (m *GroupMember) String() string { return proto.CompactTextString(m) } +func (*GroupMember) ProtoMessage() {} +func (*GroupMember) Descriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{4} +} +func (m *GroupMember) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GroupMember) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GroupMember.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 *GroupMember) XXX_Merge(src proto.Message) { + xxx_messageInfo_GroupMember.Merge(m, src) +} +func (m *GroupMember) XXX_Size() int { + return m.Size() +} +func (m *GroupMember) XXX_DiscardUnknown() { + xxx_messageInfo_GroupMember.DiscardUnknown(m) +} + +var xxx_messageInfo_GroupMember proto.InternalMessageInfo + +func (m *GroupMember) GetGroupId() uint64 { + if m != nil { + return m.GroupId + } + return 0 +} + +func (m *GroupMember) GetMember() *Member { + if m != nil { + return m.Member + } + return nil +} + +// GroupAccountInfo represents the high-level on-chain information for a group account. +type GroupAccountInfo struct { + // address is the group account address. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // group_id is the unique ID of the group. + GroupId uint64 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + // admin is the account address of the group admin. + Admin string `protobuf:"bytes,3,opt,name=admin,proto3" json:"admin,omitempty"` + // metadata is any arbitrary metadata to attached to the group account. + Metadata []byte `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"` + // version is used to track changes to a group's GroupAccountInfo structure that + // would create a different result on a running proposal. + Version uint64 `protobuf:"varint,5,opt,name=version,proto3" json:"version,omitempty"` + // decision_policy specifies the group account's decision policy. + DecisionPolicy *types1.Any `protobuf:"bytes,6,opt,name=decision_policy,json=decisionPolicy,proto3" json:"decision_policy,omitempty"` +} + +func (m *GroupAccountInfo) Reset() { *m = GroupAccountInfo{} } +func (m *GroupAccountInfo) String() string { return proto.CompactTextString(m) } +func (*GroupAccountInfo) ProtoMessage() {} +func (*GroupAccountInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{5} +} +func (m *GroupAccountInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GroupAccountInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GroupAccountInfo.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 *GroupAccountInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_GroupAccountInfo.Merge(m, src) +} +func (m *GroupAccountInfo) XXX_Size() int { + return m.Size() +} +func (m *GroupAccountInfo) XXX_DiscardUnknown() { + xxx_messageInfo_GroupAccountInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_GroupAccountInfo proto.InternalMessageInfo + +// Proposal defines a group proposal. Any member of a group can submit a proposal +// for a group account to decide upon. +// A proposal consists of a set of `sdk.Msg`s that will be executed if the proposal +// passes as well as some optional metadata associated with the proposal. +type Proposal struct { + // proposal_id is the unique id of the proposal. + ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` + // address is the group account address. + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + // metadata is any arbitrary metadata to attached to the proposal. + Metadata []byte `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` + // proposers are the account addresses of the proposers. + Proposers []string `protobuf:"bytes,4,rep,name=proposers,proto3" json:"proposers,omitempty"` + // submitted_at is a timestamp specifying when a proposal was submitted. + SubmittedAt types.Timestamp `protobuf:"bytes,5,opt,name=submitted_at,json=submittedAt,proto3" json:"submitted_at"` + // group_version tracks the version of the group that this proposal corresponds to. + // When group membership is changed, existing proposals from previous group versions will become invalid. + GroupVersion uint64 `protobuf:"varint,6,opt,name=group_version,json=groupVersion,proto3" json:"group_version,omitempty"` + // group_account_version tracks the version of the group account that this proposal corresponds to. + // When a decision policy is changed, existing proposals from previous policy versions will become invalid. + GroupAccountVersion uint64 `protobuf:"varint,7,opt,name=group_account_version,json=groupAccountVersion,proto3" json:"group_account_version,omitempty"` + // Status represents the high level position in the life cycle of the proposal. Initial value is Submitted. + Status Proposal_Status `protobuf:"varint,8,opt,name=status,proto3,enum=regen.group.v1alpha1.Proposal_Status" json:"status,omitempty"` + // result is the final result based on the votes and election rule. Initial value is unfinalized. + // The result is persisted so that clients can always rely on this state and not have to replicate the logic. + Result Proposal_Result `protobuf:"varint,9,opt,name=result,proto3,enum=regen.group.v1alpha1.Proposal_Result" json:"result,omitempty"` + // vote_state contains the sums of all weighted votes for this proposal. + VoteState Tally `protobuf:"bytes,10,opt,name=vote_state,json=voteState,proto3" json:"vote_state"` + // timeout is the timestamp of the block where the proposal execution times out. Header times of the votes and execution messages + // must be before this end time to be included in the election. After the timeout timestamp the proposal can not be + // executed anymore and should be considered pending delete. + Timeout types.Timestamp `protobuf:"bytes,11,opt,name=timeout,proto3" json:"timeout"` + // executor_result is the final result based on the votes and election rule. Initial value is NotRun. + ExecutorResult Proposal_ExecutorResult `protobuf:"varint,12,opt,name=executor_result,json=executorResult,proto3,enum=regen.group.v1alpha1.Proposal_ExecutorResult" json:"executor_result,omitempty"` + // msgs is a list of Msgs that will be executed if the proposal passes. + Msgs []*types1.Any `protobuf:"bytes,13,rep,name=msgs,proto3" json:"msgs,omitempty"` +} + +func (m *Proposal) Reset() { *m = Proposal{} } +func (m *Proposal) String() string { return proto.CompactTextString(m) } +func (*Proposal) ProtoMessage() {} +func (*Proposal) Descriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{6} +} +func (m *Proposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Proposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Proposal.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 *Proposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_Proposal.Merge(m, src) +} +func (m *Proposal) XXX_Size() int { + return m.Size() +} +func (m *Proposal) XXX_DiscardUnknown() { + xxx_messageInfo_Proposal.DiscardUnknown(m) +} + +var xxx_messageInfo_Proposal proto.InternalMessageInfo + +// Tally represents the sum of weighted votes. +type Tally struct { + // yes_count is the weighted sum of yes votes. + YesCount string `protobuf:"bytes,1,opt,name=yes_count,json=yesCount,proto3" json:"yes_count,omitempty"` + // no_count is the weighted sum of no votes. + NoCount string `protobuf:"bytes,2,opt,name=no_count,json=noCount,proto3" json:"no_count,omitempty"` + // abstain_count is the weighted sum of abstainers + AbstainCount string `protobuf:"bytes,3,opt,name=abstain_count,json=abstainCount,proto3" json:"abstain_count,omitempty"` + // veto_count is the weighted sum of vetoes. + VetoCount string `protobuf:"bytes,4,opt,name=veto_count,json=vetoCount,proto3" json:"veto_count,omitempty"` +} + +func (m *Tally) Reset() { *m = Tally{} } +func (m *Tally) String() string { return proto.CompactTextString(m) } +func (*Tally) ProtoMessage() {} +func (*Tally) Descriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{7} +} +func (m *Tally) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Tally) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Tally.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 *Tally) XXX_Merge(src proto.Message) { + xxx_messageInfo_Tally.Merge(m, src) +} +func (m *Tally) XXX_Size() int { + return m.Size() +} +func (m *Tally) XXX_DiscardUnknown() { + xxx_messageInfo_Tally.DiscardUnknown(m) +} + +var xxx_messageInfo_Tally proto.InternalMessageInfo + +// Vote represents a vote for a proposal. +type Vote struct { + // proposal is the unique ID of the proposal. + ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` + // voter is the account address of the voter. + Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"` + // choice is the voter's choice on the proposal. + Choice Choice `protobuf:"varint,3,opt,name=choice,proto3,enum=regen.group.v1alpha1.Choice" json:"choice,omitempty"` + // metadata is any arbitrary metadata to attached to the vote. + Metadata []byte `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"` + // submitted_at is the timestamp when the vote was submitted. + SubmittedAt types.Timestamp `protobuf:"bytes,5,opt,name=submitted_at,json=submittedAt,proto3" json:"submitted_at"` +} + +func (m *Vote) Reset() { *m = Vote{} } +func (m *Vote) String() string { return proto.CompactTextString(m) } +func (*Vote) ProtoMessage() {} +func (*Vote) Descriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{8} +} +func (m *Vote) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Vote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Vote.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 *Vote) XXX_Merge(src proto.Message) { + xxx_messageInfo_Vote.Merge(m, src) +} +func (m *Vote) XXX_Size() int { + return m.Size() +} +func (m *Vote) XXX_DiscardUnknown() { + xxx_messageInfo_Vote.DiscardUnknown(m) +} + +var xxx_messageInfo_Vote proto.InternalMessageInfo + +func (m *Vote) GetProposalId() uint64 { + if m != nil { + return m.ProposalId + } + return 0 +} + +func (m *Vote) GetVoter() string { + if m != nil { + return m.Voter + } + return "" +} + +func (m *Vote) GetChoice() Choice { + if m != nil { + return m.Choice + } + return Choice_CHOICE_UNSPECIFIED +} + +func (m *Vote) GetMetadata() []byte { + if m != nil { + return m.Metadata + } + return nil +} + +func (m *Vote) GetSubmittedAt() types.Timestamp { + if m != nil { + return m.SubmittedAt + } + return types.Timestamp{} +} + +func init() { + proto.RegisterEnum("regen.group.v1alpha1.Choice", Choice_name, Choice_value) + proto.RegisterEnum("regen.group.v1alpha1.Proposal_Status", Proposal_Status_name, Proposal_Status_value) + proto.RegisterEnum("regen.group.v1alpha1.Proposal_Result", Proposal_Result_name, Proposal_Result_value) + proto.RegisterEnum("regen.group.v1alpha1.Proposal_ExecutorResult", Proposal_ExecutorResult_name, Proposal_ExecutorResult_value) + proto.RegisterType((*Member)(nil), "regen.group.v1alpha1.Member") + proto.RegisterType((*Members)(nil), "regen.group.v1alpha1.Members") + proto.RegisterType((*ThresholdDecisionPolicy)(nil), "regen.group.v1alpha1.ThresholdDecisionPolicy") + proto.RegisterType((*GroupInfo)(nil), "regen.group.v1alpha1.GroupInfo") + proto.RegisterType((*GroupMember)(nil), "regen.group.v1alpha1.GroupMember") + proto.RegisterType((*GroupAccountInfo)(nil), "regen.group.v1alpha1.GroupAccountInfo") + proto.RegisterType((*Proposal)(nil), "regen.group.v1alpha1.Proposal") + proto.RegisterType((*Tally)(nil), "regen.group.v1alpha1.Tally") + proto.RegisterType((*Vote)(nil), "regen.group.v1alpha1.Vote") +} + +func init() { proto.RegisterFile("regen/group/v1alpha1/types.proto", fileDescriptor_9b7906b115009838) } + +var fileDescriptor_9b7906b115009838 = []byte{ + // 1257 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x41, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0xda, 0x8e, 0x13, 0x3f, 0x27, 0x8e, 0x35, 0xa4, 0xad, 0xe3, 0xa4, 0xce, 0xd6, 0x15, + 0x52, 0x04, 0x8a, 0xad, 0x04, 0x38, 0x10, 0x51, 0x84, 0xbd, 0xd9, 0x14, 0xa3, 0xd4, 0x0e, 0xbb, + 0x76, 0x80, 0x1e, 0xb0, 0xd6, 0xbb, 0x53, 0x67, 0x61, 0xbd, 0x63, 0xed, 0xce, 0xa6, 0x35, 0x3f, + 0x00, 0x15, 0x9f, 0xb8, 0x70, 0xe0, 0x60, 0xa9, 0x12, 0x7f, 0x81, 0x1f, 0x51, 0x71, 0xaa, 0x10, + 0x07, 0xc4, 0x01, 0xa1, 0xf6, 0xc2, 0x05, 0x89, 0x9f, 0x80, 0x76, 0x66, 0x36, 0xc9, 0x36, 0x8e, + 0xdb, 0x03, 0xb7, 0x7d, 0xef, 0x7d, 0xdf, 0x9b, 0xf7, 0xbe, 0x37, 0x7e, 0x63, 0x90, 0x3d, 0xdc, + 0xc7, 0x6e, 0xb5, 0xef, 0x91, 0x60, 0x58, 0x3d, 0xdd, 0x31, 0x9c, 0xe1, 0x89, 0xb1, 0x53, 0xa5, + 0xa3, 0x21, 0xf6, 0x2b, 0x43, 0x8f, 0x50, 0x82, 0x56, 0x19, 0xa2, 0xc2, 0x10, 0x95, 0x08, 0x51, + 0x5c, 0xed, 0x93, 0x3e, 0x61, 0x80, 0x6a, 0xf8, 0xc5, 0xb1, 0xc5, 0x52, 0x9f, 0x90, 0xbe, 0x83, + 0xab, 0xcc, 0xea, 0x05, 0x0f, 0xaa, 0x56, 0xe0, 0x19, 0xd4, 0x26, 0xae, 0x88, 0x6f, 0xbe, 0x1c, + 0xa7, 0xf6, 0x00, 0xfb, 0xd4, 0x18, 0x0c, 0x05, 0x60, 0xcd, 0x24, 0xfe, 0x80, 0xf8, 0x5d, 0x9e, + 0x99, 0x1b, 0x51, 0xe8, 0x65, 0xae, 0xe1, 0x8e, 0x78, 0xa8, 0x7c, 0x0c, 0xe9, 0x7b, 0x78, 0xd0, + 0xc3, 0x1e, 0x2a, 0xc0, 0x82, 0x61, 0x59, 0x1e, 0xf6, 0xfd, 0x82, 0x24, 0x4b, 0x5b, 0x19, 0x2d, + 0x32, 0xd1, 0x75, 0x48, 0x3f, 0xc4, 0x76, 0xff, 0x84, 0x16, 0x12, 0x2c, 0x20, 0x2c, 0x54, 0x84, + 0xc5, 0x01, 0xa6, 0x86, 0x65, 0x50, 0xa3, 0x90, 0x94, 0xa5, 0xad, 0x25, 0xed, 0xcc, 0x2e, 0xdf, + 0x85, 0x05, 0x9e, 0xd7, 0x47, 0x1f, 0xc0, 0xc2, 0x80, 0x7f, 0x16, 0x24, 0x39, 0xb9, 0x95, 0xdd, + 0xdd, 0xa8, 0x4c, 0xd3, 0xa5, 0xc2, 0xf1, 0xf5, 0xd4, 0xd3, 0x3f, 0x37, 0xe7, 0xb4, 0x88, 0x52, + 0xfe, 0x56, 0x82, 0x1b, 0xed, 0x13, 0x0f, 0xfb, 0x27, 0xc4, 0xb1, 0xf6, 0xb1, 0x69, 0xfb, 0x36, + 0x71, 0x8f, 0x88, 0x63, 0x9b, 0x23, 0xb4, 0x01, 0x19, 0x1a, 0x85, 0x44, 0xd1, 0xe7, 0x0e, 0xf4, + 0x3e, 0x2c, 0x84, 0x1a, 0x91, 0x80, 0xd7, 0x9d, 0xdd, 0x5d, 0xab, 0x70, 0x1d, 0x2a, 0x91, 0x0e, + 0x95, 0x7d, 0xa1, 0x71, 0x74, 0xa8, 0xc0, 0xef, 0xa1, 0x5f, 0x7f, 0xde, 0xce, 0xc5, 0x0f, 0x2b, + 0xff, 0x20, 0x41, 0xe6, 0x6e, 0x58, 0x71, 0xc3, 0x7d, 0x40, 0xd0, 0x1a, 0x2c, 0xb2, 0xf2, 0xbb, + 0x36, 0x3f, 0x39, 0xa5, 0x2d, 0x30, 0xbb, 0x61, 0xa1, 0x55, 0x98, 0x37, 0xac, 0x81, 0xed, 0x0a, + 0xb5, 0xb8, 0x31, 0x4b, 0xac, 0x50, 0xfa, 0x53, 0xec, 0x85, 0x67, 0x15, 0x52, 0x3c, 0x97, 0x30, + 0xd1, 0x2d, 0x58, 0xa2, 0x84, 0x1a, 0x4e, 0x57, 0x0c, 0x60, 0x9e, 0xa5, 0xcc, 0x32, 0xdf, 0x67, + 0xcc, 0x55, 0xfe, 0x12, 0xb2, 0xac, 0x2c, 0x31, 0xc6, 0x19, 0x85, 0xbd, 0x0b, 0x69, 0xae, 0xaa, + 0xd0, 0x63, 0xe6, 0x1c, 0x34, 0x81, 0x2d, 0xff, 0x2b, 0x41, 0x9e, 0x1d, 0x50, 0x33, 0x4d, 0x12, + 0xb8, 0x94, 0xb5, 0x7f, 0xf5, 0x65, 0xb9, 0x78, 0x7e, 0xe2, 0x0a, 0x61, 0x92, 0x57, 0x09, 0x93, + 0xba, 0x5a, 0x98, 0xf9, 0xb8, 0x30, 0x9f, 0xc2, 0x8a, 0x25, 0xe6, 0xd3, 0x1d, 0xb2, 0x01, 0x15, + 0xd2, 0xac, 0xa9, 0xd5, 0x4b, 0x43, 0xae, 0xb9, 0xa3, 0x3a, 0xfa, 0xe5, 0xd2, 0x40, 0xb5, 0x9c, + 0x15, 0xb3, 0xf7, 0x16, 0x1f, 0x3f, 0xd9, 0x9c, 0xfb, 0xfb, 0xc9, 0xa6, 0x54, 0xfe, 0x07, 0x60, + 0xf1, 0xc8, 0x23, 0x43, 0xe2, 0x1b, 0x0e, 0xda, 0x84, 0xec, 0x50, 0x7c, 0x9f, 0x6b, 0x0a, 0x91, + 0xab, 0x61, 0x5d, 0xd4, 0x22, 0x11, 0xd7, 0x62, 0xd6, 0xcc, 0x37, 0x20, 0xc3, 0x73, 0x84, 0xbf, + 0x8b, 0x94, 0x9c, 0x0c, 0xef, 0xee, 0x99, 0x03, 0x29, 0xb0, 0xe4, 0x07, 0xbd, 0x81, 0x4d, 0x29, + 0xb6, 0xba, 0x06, 0x9f, 0x7b, 0x76, 0xb7, 0x78, 0xa9, 0xb7, 0x76, 0xb4, 0x04, 0xc4, 0x0d, 0xce, + 0x9e, 0xb1, 0x6a, 0x14, 0xdd, 0x86, 0x65, 0x3e, 0x8a, 0x48, 0xc3, 0x34, 0xab, 0x7d, 0x89, 0x39, + 0x8f, 0x85, 0x90, 0xbb, 0x70, 0x8d, 0x83, 0x0c, 0x3e, 0xde, 0x33, 0xf0, 0x02, 0x03, 0xbf, 0xd1, + 0xbf, 0x30, 0xfa, 0x88, 0x73, 0x07, 0xd2, 0x3e, 0x35, 0x68, 0xe0, 0x17, 0x16, 0x65, 0x69, 0x2b, + 0xb7, 0xfb, 0xe6, 0xf4, 0x8b, 0x14, 0x49, 0x58, 0xd1, 0x19, 0x58, 0x13, 0xa4, 0x90, 0xee, 0x61, + 0x3f, 0x70, 0x68, 0x21, 0xf3, 0x5a, 0x74, 0x8d, 0x81, 0x35, 0x41, 0x42, 0x1f, 0x01, 0x9c, 0x12, + 0x8a, 0xbb, 0x61, 0x36, 0x5c, 0x00, 0xa6, 0xcc, 0xfa, 0xf4, 0x14, 0x6d, 0xc3, 0x71, 0x46, 0x42, + 0x9a, 0x4c, 0x48, 0x0a, 0x2b, 0xc1, 0x68, 0xef, 0x7c, 0x33, 0x64, 0x5f, 0x53, 0xd8, 0x88, 0x80, + 0x8e, 0x61, 0x05, 0x3f, 0xc2, 0x66, 0x40, 0x89, 0xd7, 0x15, 0x5d, 0x2c, 0xb1, 0x2e, 0xb6, 0x5f, + 0xd1, 0x85, 0x2a, 0x58, 0xa2, 0x9b, 0x1c, 0x8e, 0xd9, 0x68, 0x0b, 0x52, 0x03, 0xbf, 0xef, 0x17, + 0x96, 0xd9, 0x8a, 0x9c, 0x7a, 0x8b, 0x35, 0x86, 0x28, 0x3f, 0x93, 0x20, 0xcd, 0x15, 0x45, 0x3b, + 0x80, 0xf4, 0x76, 0xad, 0xdd, 0xd1, 0xbb, 0x9d, 0xa6, 0x7e, 0xa4, 0x2a, 0x8d, 0x83, 0x86, 0xba, + 0x9f, 0x9f, 0x2b, 0xae, 0x8d, 0x27, 0xf2, 0xb5, 0xe8, 0x64, 0x8e, 0x6d, 0xb8, 0xa7, 0x86, 0x63, + 0x5b, 0x68, 0x07, 0xf2, 0x82, 0xa2, 0x77, 0xea, 0xf7, 0x1a, 0xed, 0xb6, 0xba, 0x9f, 0x97, 0x8a, + 0xeb, 0xe3, 0x89, 0x7c, 0x23, 0x4e, 0xd0, 0xa3, 0x9b, 0x84, 0xde, 0x86, 0x65, 0x41, 0x51, 0x0e, + 0x5b, 0xba, 0xba, 0x9f, 0x4f, 0x14, 0x0b, 0xe3, 0x89, 0xbc, 0x1a, 0xc7, 0x2b, 0x0e, 0xf1, 0xb1, + 0x85, 0xb6, 0x21, 0x27, 0xc0, 0xb5, 0x7a, 0x4b, 0x0b, 0xb3, 0x27, 0xa7, 0x95, 0x53, 0xeb, 0x11, + 0x8f, 0x62, 0xab, 0x98, 0x7a, 0xfc, 0x53, 0x69, 0xae, 0xfc, 0x87, 0x04, 0x69, 0xa1, 0xc3, 0x0e, + 0x20, 0x4d, 0xd5, 0x3b, 0x87, 0xed, 0x59, 0x2d, 0x71, 0x6c, 0xd4, 0xd2, 0x7b, 0x17, 0x28, 0x07, + 0x8d, 0x66, 0xed, 0xb0, 0x71, 0x9f, 0x35, 0x75, 0x73, 0x3c, 0x91, 0xd7, 0xe2, 0x94, 0x8e, 0xfb, + 0xc0, 0x76, 0x0d, 0xc7, 0xfe, 0x06, 0x5b, 0xa8, 0x0a, 0x2b, 0x82, 0x56, 0x53, 0x14, 0xf5, 0xa8, + 0xcd, 0x1a, 0x2b, 0x8e, 0x27, 0xf2, 0xf5, 0x38, 0xa7, 0x66, 0x9a, 0x78, 0x48, 0x63, 0x04, 0x4d, + 0xfd, 0x44, 0x55, 0x78, 0x6f, 0x53, 0x08, 0x1a, 0xfe, 0x0a, 0x9b, 0xe7, 0xcd, 0xfd, 0x98, 0x80, + 0x5c, 0x7c, 0xf8, 0xa8, 0x0e, 0xeb, 0xea, 0xe7, 0xaa, 0xd2, 0x69, 0xb7, 0xb4, 0xee, 0xd4, 0x6e, + 0x6f, 0x8d, 0x27, 0xf2, 0xcd, 0x28, 0x6b, 0x9c, 0x1c, 0x75, 0x7d, 0x07, 0x6e, 0xbc, 0x9c, 0xa3, + 0xd9, 0x6a, 0x77, 0xb5, 0x4e, 0x33, 0x2f, 0x15, 0xe5, 0xf1, 0x44, 0xde, 0x98, 0xce, 0x6f, 0x12, + 0xaa, 0x05, 0x2e, 0xfa, 0xf0, 0x32, 0x5d, 0xef, 0x28, 0x8a, 0xaa, 0xeb, 0xf9, 0xc4, 0xac, 0xe3, + 0xf5, 0xc0, 0x34, 0xc3, 0xdd, 0x36, 0x85, 0x7f, 0x50, 0x6b, 0x1c, 0x76, 0x34, 0x35, 0x9f, 0x9c, + 0xc5, 0x3f, 0x30, 0x6c, 0x27, 0xf0, 0x30, 0xd7, 0x66, 0x2f, 0x15, 0xee, 0xdc, 0xf2, 0x77, 0x12, + 0xcc, 0xb3, 0x9f, 0x2a, 0x5a, 0x87, 0xcc, 0x08, 0xfb, 0x5d, 0xb6, 0x6d, 0xc4, 0xcb, 0xb2, 0x38, + 0xc2, 0xbe, 0x12, 0xda, 0xe1, 0xd3, 0xe2, 0x12, 0x11, 0x13, 0x9b, 0xd6, 0x25, 0x3c, 0x74, 0x1b, + 0x96, 0x8d, 0x9e, 0x4f, 0x0d, 0xdb, 0x15, 0x71, 0xfe, 0xc4, 0x2c, 0x09, 0x27, 0x07, 0xdd, 0x04, + 0x38, 0xc5, 0x34, 0xca, 0x90, 0xe2, 0xff, 0x17, 0x42, 0x0f, 0x0b, 0x8b, 0x5a, 0x7e, 0x93, 0x20, + 0x75, 0x4c, 0x28, 0x7e, 0xf5, 0xde, 0x5f, 0x85, 0xf9, 0x70, 0xa5, 0x78, 0xd1, 0x3b, 0xcf, 0x8c, + 0xf0, 0x91, 0x35, 0x4f, 0x88, 0x6d, 0x62, 0x56, 0x42, 0xee, 0xaa, 0x47, 0x56, 0x61, 0x18, 0x4d, + 0x60, 0x67, 0x3e, 0x82, 0xff, 0xc7, 0x5b, 0xf0, 0x96, 0x05, 0x69, 0x7e, 0x24, 0xba, 0x0e, 0x48, + 0xf9, 0xb8, 0xd5, 0x50, 0xd4, 0xf8, 0x95, 0x43, 0xcb, 0x90, 0x11, 0xfe, 0x66, 0x2b, 0x2f, 0xa1, + 0x1c, 0x80, 0x30, 0xbf, 0x50, 0xf5, 0x7c, 0x02, 0x21, 0xc8, 0x09, 0xbb, 0x56, 0xd7, 0xdb, 0xb5, + 0x46, 0x33, 0x9f, 0x44, 0x2b, 0x90, 0x15, 0xbe, 0x63, 0xb5, 0xdd, 0xca, 0xa7, 0xea, 0x77, 0x9f, + 0x3e, 0x2f, 0x49, 0xcf, 0x9e, 0x97, 0xa4, 0xbf, 0x9e, 0x97, 0xa4, 0xef, 0x5f, 0x94, 0xe6, 0x9e, + 0xbd, 0x28, 0xcd, 0xfd, 0xfe, 0xa2, 0x34, 0x77, 0x7f, 0xbb, 0x6f, 0xd3, 0x93, 0xa0, 0x57, 0x31, + 0xc9, 0xa0, 0xca, 0x04, 0xd9, 0x76, 0x31, 0x7d, 0x48, 0xbc, 0xaf, 0x85, 0xe5, 0x60, 0xab, 0x8f, + 0xbd, 0xea, 0x23, 0xfe, 0x77, 0xba, 0x97, 0x66, 0x5d, 0xbd, 0xf3, 0x5f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x65, 0x8d, 0xd3, 0x7f, 0x64, 0x0b, 0x00, 0x00, +} + +func (this *GroupAccountInfo) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*GroupAccountInfo) + if !ok { + that2, ok := that.(GroupAccountInfo) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Address != that1.Address { + return false + } + if this.GroupId != that1.GroupId { + return false + } + if this.Admin != that1.Admin { + return false + } + if !bytes.Equal(this.Metadata, that1.Metadata) { + return false + } + if this.Version != that1.Version { + return false + } + if !this.DecisionPolicy.Equal(that1.DecisionPolicy) { + return false + } + return true +} +func (m *Member) 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 *Member) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Member) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x1a + } + if len(m.Weight) > 0 { + i -= len(m.Weight) + copy(dAtA[i:], m.Weight) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Weight))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Members) 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 *Members) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Members) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Members) > 0 { + for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Members[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ThresholdDecisionPolicy) 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 *ThresholdDecisionPolicy) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ThresholdDecisionPolicy) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Timeout.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Threshold) > 0 { + i -= len(m.Threshold) + copy(dAtA[i:], m.Threshold) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Threshold))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GroupInfo) 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 *GroupInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GroupInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TotalWeight) > 0 { + i -= len(m.TotalWeight) + copy(dAtA[i:], m.TotalWeight) + i = encodeVarintTypes(dAtA, i, uint64(len(m.TotalWeight))) + i-- + dAtA[i] = 0x2a + } + if m.Version != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x20 + } + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x1a + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0x12 + } + if m.GroupId != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *GroupMember) 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 *GroupMember) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GroupMember) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Member != nil { + { + size, err := m.Member.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.GroupId != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *GroupAccountInfo) 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 *GroupAccountInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GroupAccountInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.DecisionPolicy != nil { + { + size, err := m.DecisionPolicy.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + if m.Version != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x28 + } + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x22 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0x1a + } + if m.GroupId != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Proposal) 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 *Proposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Proposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Msgs) > 0 { + for iNdEx := len(m.Msgs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Msgs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x6a + } + } + if m.ExecutorResult != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ExecutorResult)) + i-- + dAtA[i] = 0x60 + } + { + size, err := m.Timeout.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + { + size, err := m.VoteState.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + if m.Result != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Result)) + i-- + dAtA[i] = 0x48 + } + if m.Status != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x40 + } + if m.GroupAccountVersion != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.GroupAccountVersion)) + i-- + dAtA[i] = 0x38 + } + if m.GroupVersion != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.GroupVersion)) + i-- + dAtA[i] = 0x30 + } + { + size, err := m.SubmittedAt.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if len(m.Proposers) > 0 { + for iNdEx := len(m.Proposers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Proposers[iNdEx]) + copy(dAtA[i:], m.Proposers[iNdEx]) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Proposers[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x1a + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if m.ProposalId != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Tally) 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 *Tally) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Tally) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.VetoCount) > 0 { + i -= len(m.VetoCount) + copy(dAtA[i:], m.VetoCount) + i = encodeVarintTypes(dAtA, i, uint64(len(m.VetoCount))) + i-- + dAtA[i] = 0x22 + } + if len(m.AbstainCount) > 0 { + i -= len(m.AbstainCount) + copy(dAtA[i:], m.AbstainCount) + i = encodeVarintTypes(dAtA, i, uint64(len(m.AbstainCount))) + i-- + dAtA[i] = 0x1a + } + if len(m.NoCount) > 0 { + i -= len(m.NoCount) + copy(dAtA[i:], m.NoCount) + i = encodeVarintTypes(dAtA, i, uint64(len(m.NoCount))) + i-- + dAtA[i] = 0x12 + } + if len(m.YesCount) > 0 { + i -= len(m.YesCount) + copy(dAtA[i:], m.YesCount) + i = encodeVarintTypes(dAtA, i, uint64(len(m.YesCount))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Vote) 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 *Vote) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Vote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.SubmittedAt.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x22 + } + if m.Choice != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Choice)) + i-- + dAtA[i] = 0x18 + } + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x12 + } + if m.ProposalId != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { + offset -= sovTypes(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Member) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Weight) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *Members) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Members) > 0 { + for _, e := range m.Members { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *ThresholdDecisionPolicy) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Threshold) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Timeout.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *GroupInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovTypes(uint64(m.GroupId)) + } + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.Version != 0 { + n += 1 + sovTypes(uint64(m.Version)) + } + l = len(m.TotalWeight) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *GroupMember) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovTypes(uint64(m.GroupId)) + } + if m.Member != nil { + l = m.Member.Size() + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *GroupAccountInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.GroupId != 0 { + n += 1 + sovTypes(uint64(m.GroupId)) + } + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.Version != 0 { + n += 1 + sovTypes(uint64(m.Version)) + } + if m.DecisionPolicy != nil { + l = m.DecisionPolicy.Size() + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *Proposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovTypes(uint64(m.ProposalId)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if len(m.Proposers) > 0 { + for _, s := range m.Proposers { + l = len(s) + n += 1 + l + sovTypes(uint64(l)) + } + } + l = m.SubmittedAt.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.GroupVersion != 0 { + n += 1 + sovTypes(uint64(m.GroupVersion)) + } + if m.GroupAccountVersion != 0 { + n += 1 + sovTypes(uint64(m.GroupAccountVersion)) + } + if m.Status != 0 { + n += 1 + sovTypes(uint64(m.Status)) + } + if m.Result != 0 { + n += 1 + sovTypes(uint64(m.Result)) + } + l = m.VoteState.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.Timeout.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.ExecutorResult != 0 { + n += 1 + sovTypes(uint64(m.ExecutorResult)) + } + if len(m.Msgs) > 0 { + for _, e := range m.Msgs { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *Tally) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.YesCount) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.NoCount) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.AbstainCount) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.VetoCount) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *Vote) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovTypes(uint64(m.ProposalId)) + } + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.Choice != 0 { + n += 1 + sovTypes(uint64(m.Choice)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.SubmittedAt.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func sovTypes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTypes(x uint64) (n int) { + return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Member) 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 ErrIntOverflowTypes + } + 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: Member: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Member: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Weight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Weight = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Members) 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 ErrIntOverflowTypes + } + 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: Members: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Members: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Members = append(m.Members, Member{}) + if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ThresholdDecisionPolicy) 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 ErrIntOverflowTypes + } + 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: ThresholdDecisionPolicy: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ThresholdDecisionPolicy: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Threshold", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Threshold = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GroupInfo) 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 ErrIntOverflowTypes + } + 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: GroupInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GroupInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalWeight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TotalWeight = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GroupMember) 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 ErrIntOverflowTypes + } + 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: GroupMember: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GroupMember: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Member", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Member == nil { + m.Member = &Member{} + } + if err := m.Member.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GroupAccountInfo) 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 ErrIntOverflowTypes + } + 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: GroupAccountInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GroupAccountInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DecisionPolicy", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DecisionPolicy == nil { + m.DecisionPolicy = &types1.Any{} + } + if err := m.DecisionPolicy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Proposal) 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 ErrIntOverflowTypes + } + 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: Proposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Proposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proposers", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proposers = append(m.Proposers, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubmittedAt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SubmittedAt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupVersion", wireType) + } + m.GroupVersion = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupVersion |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupAccountVersion", wireType) + } + m.GroupAccountVersion = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupAccountVersion |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= Proposal_Status(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + m.Result = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Result |= Proposal_Result(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VoteState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.VoteState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecutorResult", wireType) + } + m.ExecutorResult = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecutorResult |= Proposal_ExecutorResult(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msgs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Msgs = append(m.Msgs, &types1.Any{}) + if err := m.Msgs[len(m.Msgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Tally) 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 ErrIntOverflowTypes + } + 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: Tally: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Tally: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field YesCount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.YesCount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NoCount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NoCount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AbstainCount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AbstainCount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VetoCount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VetoCount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Vote) 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 ErrIntOverflowTypes + } + 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: Vote: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Vote: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Voter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Choice", wireType) + } + m.Choice = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Choice |= Choice(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubmittedAt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SubmittedAt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTypes(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, ErrIntOverflowTypes + } + 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, ErrIntOverflowTypes + } + 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, ErrIntOverflowTypes + } + 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, ErrInvalidLengthTypes + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTypes + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTypes + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/group/types_test.go b/x/group/types_test.go new file mode 100644 index 0000000000..230a0710c5 --- /dev/null +++ b/x/group/types_test.go @@ -0,0 +1,942 @@ +package group + +import ( + "testing" + "time" + + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + proto "github.com/gogo/protobuf/types" + "github.com/regen-network/regen-ledger/math" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestThresholdDecisionPolicy(t *testing.T) { + specs := map[string]struct { + srcPolicy ThresholdDecisionPolicy + srcTally Tally + srcTotalPower string + srcVotingDuration time.Duration + expResult DecisionPolicyResult + expErr error + }{ + "accept when yes count greater than threshold": { + srcPolicy: ThresholdDecisionPolicy{ + Threshold: "1", + Timeout: proto.Duration{Seconds: 1}, + }, + srcTally: Tally{YesCount: "2"}, + srcTotalPower: "3", + srcVotingDuration: time.Millisecond, + expResult: DecisionPolicyResult{Allow: true, Final: true}, + }, + "accept when yes count equal to threshold": { + srcPolicy: ThresholdDecisionPolicy{ + Threshold: "1", + Timeout: proto.Duration{Seconds: 1}, + }, + srcTally: Tally{YesCount: "1", NoCount: "0", AbstainCount: "0", VetoCount: "0"}, + srcTotalPower: "3", + srcVotingDuration: time.Millisecond, + expResult: DecisionPolicyResult{Allow: true, Final: true}, + }, + "reject when yes count lower to threshold": { + srcPolicy: ThresholdDecisionPolicy{ + Threshold: "1", + Timeout: proto.Duration{Seconds: 1}, + }, + srcTally: Tally{YesCount: "0", NoCount: "0", AbstainCount: "0", VetoCount: "0"}, + srcTotalPower: "3", + srcVotingDuration: time.Millisecond, + expResult: DecisionPolicyResult{Allow: false, Final: false}, + }, + "reject as final when remaining votes can't cross threshold": { + srcPolicy: ThresholdDecisionPolicy{ + Threshold: "2", + Timeout: proto.Duration{Seconds: 1}, + }, + srcTally: Tally{YesCount: "0", NoCount: "2", AbstainCount: "0", VetoCount: "0"}, + srcTotalPower: "3", + srcVotingDuration: time.Millisecond, + expResult: DecisionPolicyResult{Allow: false, Final: true}, + }, + "expired when on timeout": { + srcPolicy: ThresholdDecisionPolicy{ + Threshold: "1", + Timeout: proto.Duration{Seconds: 1}, + }, + srcTally: Tally{YesCount: "2"}, + srcTotalPower: "3", + srcVotingDuration: time.Second, + expResult: DecisionPolicyResult{Allow: false, Final: true}, + }, + "expired when after timeout": { + srcPolicy: ThresholdDecisionPolicy{ + Threshold: "1", + Timeout: proto.Duration{Seconds: 1}, + }, + srcTally: Tally{YesCount: "2"}, + srcTotalPower: "3", + srcVotingDuration: time.Second + time.Nanosecond, + expResult: DecisionPolicyResult{Allow: false, Final: true}, + }, + "abstain has no impact": { + srcPolicy: ThresholdDecisionPolicy{ + Threshold: "1", + Timeout: proto.Duration{Seconds: 1}, + }, + srcTally: Tally{YesCount: "0", NoCount: "0", AbstainCount: "1", VetoCount: "0"}, + srcTotalPower: "3", + srcVotingDuration: time.Millisecond, + expResult: DecisionPolicyResult{Allow: false, Final: false}, + }, + "veto same as no": { + srcPolicy: ThresholdDecisionPolicy{ + Threshold: "1", + Timeout: proto.Duration{Seconds: 1}, + }, + srcTally: Tally{YesCount: "0", NoCount: "0", AbstainCount: "0", VetoCount: "2"}, + srcTotalPower: "3", + srcVotingDuration: time.Millisecond, + expResult: DecisionPolicyResult{Allow: false, Final: false}, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + res, err := spec.srcPolicy.Allow(spec.srcTally, spec.srcTotalPower, spec.srcVotingDuration) + if spec.expErr != nil { + require.Error(t, err) + return + } + require.NoError(t, err) + assert.Equal(t, spec.expResult, res) + }) + } +} + +func TestThresholdDecisionPolicyValidate(t *testing.T) { + specs := map[string]struct { + src ThresholdDecisionPolicy + expErr bool + }{ + "all good": {src: ThresholdDecisionPolicy{ + Threshold: "1", + Timeout: proto.Duration{Seconds: 1}, + }}, + "greater than group total weight": { + src: ThresholdDecisionPolicy{ + Threshold: "2", + Timeout: proto.Duration{Seconds: 1}, + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.Validate(GroupInfo{TotalWeight: "1"}) + assert.Equal(t, spec.expErr, err != nil, err) + }) + } +} + +func TestThresholdDecisionPolicyValidateBasic(t *testing.T) { + maxSeconds := int64(10000 * 365.25 * 24 * 60 * 60) + specs := map[string]struct { + src ThresholdDecisionPolicy + expErr bool + }{ + "all good": {src: ThresholdDecisionPolicy{ + Threshold: "1", + Timeout: proto.Duration{Seconds: 1}, + }}, + "threshold missing": {src: ThresholdDecisionPolicy{ + Timeout: proto.Duration{Seconds: 1}, + }, + expErr: true, + }, + "timeout missing": {src: ThresholdDecisionPolicy{ + Threshold: "1", + }, + expErr: true, + }, + "duration out of limit": {src: ThresholdDecisionPolicy{ + Threshold: "1", + Timeout: proto.Duration{Seconds: maxSeconds + 1}, + }, + expErr: true, + }, + "no negative thresholds": {src: ThresholdDecisionPolicy{ + Threshold: "-1", + Timeout: proto.Duration{Seconds: 1}, + }, + expErr: true, + }, + "no empty thresholds": {src: ThresholdDecisionPolicy{ + Timeout: proto.Duration{Seconds: 1}, + }, + expErr: true, + }, + "no zero thresholds": {src: ThresholdDecisionPolicy{ + Timeout: proto.Duration{Seconds: 1}, + Threshold: "0", + }, + expErr: true, + }, + "no negative timeouts": {src: ThresholdDecisionPolicy{ + Threshold: "1", + Timeout: proto.Duration{Seconds: -1}, + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + assert.Equal(t, spec.expErr, err != nil, err) + }) + } +} + +func TestVotePrimaryKey(t *testing.T) { + addr := []byte{0xff, 0xfe} + v := Vote{ + ProposalId: 1, + Voter: string(addr[:]), + } + assert.Equal(t, []byte{0, 0, 0, 0, 0, 0, 0, 1, 0xff, 0xfe}, v.PrimaryKey()) +} + +func TestGroupInfoValidation(t *testing.T) { + _, _, addr := testdata.KeyTestPubAddr() + adminAddr := addr.String() + + specs := map[string]struct { + src GroupInfo + expErr bool + }{ + "all good": { + src: GroupInfo{ + GroupId: 1, + Admin: adminAddr, + Metadata: nil, + Version: 1, + TotalWeight: "0", + }, + }, + "invalid group": { + src: GroupInfo{ + Admin: adminAddr, + Metadata: nil, + Version: 1, + TotalWeight: "0", + }, + expErr: true, + }, + "invalid admin": { + src: GroupInfo{ + GroupId: 1, + Admin: "", + Metadata: nil, + Version: 1, + TotalWeight: "0", + }, + expErr: true, + }, + "invalid version": { + src: GroupInfo{ + GroupId: 1, + Admin: adminAddr, + Metadata: nil, + TotalWeight: "0", + }, + expErr: true, + }, + "unset total weight": { + src: GroupInfo{ + GroupId: 1, + Admin: adminAddr, + Metadata: nil, + Version: 1, + }, + expErr: true, + }, + "negative total weight": { + src: GroupInfo{ + GroupId: 1, + Admin: adminAddr, + Metadata: nil, + Version: 1, + TotalWeight: "-1", + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestGroupMemberValidation(t *testing.T) { + _, _, addr := testdata.KeyTestPubAddr() + memberAddr := addr.String() + + specs := map[string]struct { + src GroupMember + expErr bool + }{ + "all good": { + src: GroupMember{ + GroupId: 1, + Member: &Member{ + Address: memberAddr, + Weight: "1", + Metadata: nil, + }, + }, + }, + "invalid group": { + src: GroupMember{ + GroupId: 0, + Member: &Member{ + Address: memberAddr, + Weight: "1", + Metadata: nil, + }, + }, + expErr: true, + }, + "invalid address": { + src: GroupMember{ + GroupId: 1, + Member: &Member{ + Address: "invalid-member-address", + Weight: "1", + Metadata: nil, + }, + }, + expErr: true, + }, + "empty address": { + src: GroupMember{ + GroupId: 1, + Member: &Member{ + Weight: "1", + Metadata: nil, + }, + }, + expErr: true, + }, + "invalid weight": { + src: GroupMember{ + GroupId: 1, + Member: &Member{ + Address: memberAddr, + Weight: "-1", + Metadata: nil, + }, + }, + expErr: true, + }, + "nil weight": { + src: GroupMember{ + GroupId: 1, + Member: &Member{ + Address: memberAddr, + Metadata: nil, + }, + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestGroupAccountInfo(t *testing.T) { + specs := map[string]struct { + groupAccount sdk.AccAddress + group uint64 + admin sdk.AccAddress + version uint64 + threshold string + timeout proto.Duration + expErr bool + }{ + "all good": { + group: 1, + groupAccount: []byte("valid--group-address"), + admin: []byte("valid--admin-address"), + version: 1, + threshold: "1", + timeout: proto.Duration{Seconds: 1}, + }, + "invalid group": { + group: 0, + groupAccount: []byte("valid--group-address"), + admin: []byte("valid--admin-address"), + version: 1, + threshold: "1", + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + "invalid group account address": { + group: 1, + groupAccount: []byte("any-invalid-group-address"), + admin: []byte("valid--admin-address"), + version: 1, + threshold: "1", + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + "empty group account address": { + group: 1, + admin: []byte("valid--admin-address"), + version: 1, + threshold: "1", + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + "empty admin account address": { + group: 1, + groupAccount: []byte("valid--group-address"), + version: 1, + threshold: "1", + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + "invalid admin account address": { + group: 1, + groupAccount: []byte("valid--group-address"), + admin: []byte("any-invalid-admin-address"), + version: 1, + threshold: "1", + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + "empty version number": { + group: 1, + groupAccount: []byte("valid--group-address"), + admin: []byte("valid--admin-address"), + threshold: "1", + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + "missing decision policy": { + group: 1, + groupAccount: []byte("valid--group-address"), + admin: []byte("valid--admin-address"), + version: 1, + expErr: true, + }, + "missing decision policy timeout": { + group: 1, + groupAccount: []byte("valid--group-address"), + admin: []byte("valid--admin-address"), + version: 1, + threshold: "1", + expErr: true, + }, + "decision policy with invalid timeout": { + group: 1, + groupAccount: []byte("valid--group-address"), + admin: []byte("valid--admin-address"), + version: 1, + threshold: "1", + timeout: proto.Duration{Seconds: -1}, + expErr: true, + }, + "missing decision policy threshold": { + group: 1, + groupAccount: []byte("valid--group-address"), + admin: []byte("valid--admin-address"), + version: 1, + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + "decision policy with negative threshold": { + group: 1, + groupAccount: []byte("valid--group-address"), + admin: []byte("valid--admin-address"), + version: 1, + threshold: "-1", + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + "decision policy with zero threshold": { + group: 1, + groupAccount: []byte("valid--group-address"), + admin: []byte("valid--admin-address"), + version: 1, + threshold: "0", + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + m, err := NewGroupAccountInfo( + spec.groupAccount, + spec.group, + spec.admin, + nil, + spec.version, + &ThresholdDecisionPolicy{ + Threshold: spec.threshold, + Timeout: spec.timeout, + }, + ) + require.NoError(t, err) + + if spec.expErr { + require.Error(t, m.ValidateBasic()) + } else { + require.NoError(t, m.ValidateBasic()) + } + }) + } +} + +func TestTallyValidateBasic(t *testing.T) { + specs := map[string]struct { + src Tally + expErr bool + }{ + "all good": { + src: Tally{ + YesCount: "1", + NoCount: "0", + AbstainCount: "0", + VetoCount: "0", + }, + }, + "negative yes count": { + src: Tally{ + YesCount: "-1", + NoCount: "0", + AbstainCount: "0", + VetoCount: "0", + }, + expErr: true, + }, + "negative no count": { + src: Tally{ + YesCount: "0", + NoCount: "-1", + AbstainCount: "0", + VetoCount: "0", + }, + expErr: true, + }, + "negative abstain count": { + src: Tally{ + YesCount: "0", + NoCount: "0", + AbstainCount: "-1", + VetoCount: "0", + }, + expErr: true, + }, + "negative veto count": { + src: Tally{ + YesCount: "0", + NoCount: "0", + AbstainCount: "0", + VetoCount: "-1", + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestTallyTotalCounts(t *testing.T) { + specs := map[string]struct { + src Tally + expErr bool + res string + }{ + "all good": { + src: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + res: "4", + }, + "negative yes count": { + src: Tally{ + YesCount: "-1", + NoCount: "0", + AbstainCount: "0", + VetoCount: "0", + }, + expErr: true, + }, + "negative no count": { + src: Tally{ + YesCount: "0", + NoCount: "-1", + AbstainCount: "0", + VetoCount: "0", + }, + expErr: true, + }, + "negative abstain count": { + src: Tally{ + YesCount: "0", + NoCount: "0", + AbstainCount: "-1", + VetoCount: "0", + }, + expErr: true, + }, + "negative veto count": { + src: Tally{ + YesCount: "0", + NoCount: "0", + AbstainCount: "0", + VetoCount: "-1", + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + res, err := spec.src.TotalCounts() + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, spec.res, math.DecimalString(res)) + } + }) + } +} + +func TestTallyAdd(t *testing.T) { + specs := map[string]struct { + src Tally + expTally Tally + vote Vote + expErr bool + weight string + }{ + "add yes": { + src: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + expTally: Tally{ + YesCount: "5", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + vote: Vote{Choice: Choice_CHOICE_YES}, + weight: "4", + }, + "add no": { + src: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + expTally: Tally{ + YesCount: "1", + NoCount: "2.5", + AbstainCount: "1", + VetoCount: "1", + }, + vote: Vote{Choice: Choice_CHOICE_NO}, + weight: "1.5", + }, + "add abstain": { + src: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + expTally: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "2.5", + VetoCount: "1", + }, + vote: Vote{Choice: Choice_CHOICE_ABSTAIN}, + weight: "1.5", + }, + "add veto": { + src: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + expTally: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "2.5", + }, + vote: Vote{Choice: Choice_CHOICE_VETO}, + weight: "1.5", + }, + "negative yes count": { + src: Tally{ + YesCount: "-1", + NoCount: "0", + AbstainCount: "0", + VetoCount: "0", + }, + expErr: true, + weight: "4", + }, + "negative no count": { + src: Tally{ + YesCount: "0", + NoCount: "-1", + AbstainCount: "0", + VetoCount: "0", + }, + expErr: true, + weight: "4", + }, + "negative abstain count": { + src: Tally{ + YesCount: "0", + NoCount: "0", + AbstainCount: "-1", + VetoCount: "0", + }, + expErr: true, + weight: "4", + }, + "negative veto count": { + src: Tally{ + YesCount: "0", + NoCount: "0", + AbstainCount: "0", + VetoCount: "-1", + }, + expErr: true, + weight: "4", + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.Add(spec.vote, spec.weight) + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, spec.expTally.YesCount, spec.src.YesCount) + require.Equal(t, spec.expTally.NoCount, spec.src.NoCount) + require.Equal(t, spec.expTally.AbstainCount, spec.src.AbstainCount) + require.Equal(t, spec.expTally.VetoCount, spec.src.VetoCount) + } + }) + } +} + +func TestTallySub(t *testing.T) { + specs := map[string]struct { + src Tally + expTally Tally + vote Vote + expErr bool + weight string + }{ + "sub yes": { + src: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + expTally: Tally{ + YesCount: "0.5", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + vote: Vote{Choice: Choice_CHOICE_YES}, + weight: "0.5", + }, + "sub no": { + src: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + expTally: Tally{ + YesCount: "1", + NoCount: "0.5", + AbstainCount: "1", + VetoCount: "1", + }, + vote: Vote{Choice: Choice_CHOICE_NO}, + weight: "0.5", + }, + "sub abstain": { + src: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + expTally: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "0.5", + VetoCount: "1", + }, + vote: Vote{Choice: Choice_CHOICE_ABSTAIN}, + weight: "0.5", + }, + "sub veto": { + src: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + expTally: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "0.5", + }, + vote: Vote{Choice: Choice_CHOICE_VETO}, + weight: "0.5", + }, + "negative yes count": { + src: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + expErr: true, + vote: Vote{Choice: Choice_CHOICE_YES}, + weight: "2", + }, + "negative no count": { + src: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + expErr: true, + vote: Vote{Choice: Choice_CHOICE_NO}, + weight: "2", + }, + "negative abstain count": { + src: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + expErr: true, + vote: Vote{Choice: Choice_CHOICE_ABSTAIN}, + weight: "2", + }, + "negative veto count": { + src: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + expErr: true, + vote: Vote{Choice: Choice_CHOICE_VETO}, + weight: "2", + }, + "unknown choice": { + src: Tally{ + YesCount: "1", + NoCount: "1", + AbstainCount: "1", + VetoCount: "1", + }, + expErr: true, + vote: Vote{Choice: Choice_CHOICE_UNSPECIFIED}, + weight: "2", + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.Sub(spec.vote, spec.weight) + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, spec.expTally.YesCount, spec.src.YesCount) + require.Equal(t, spec.expTally.NoCount, spec.src.NoCount) + require.Equal(t, spec.expTally.AbstainCount, spec.src.AbstainCount) + require.Equal(t, spec.expTally.VetoCount, spec.src.VetoCount) + } + }) + } +} + +func TestAccAddressesValidateBasic(t *testing.T) { + _, _, addr1 := testdata.KeyTestPubAddr() + _, _, addr2 := testdata.KeyTestPubAddr() + specs := map[string]struct { + src AccAddresses + expErr bool + }{ + "valid": { + src: AccAddresses{addr1, addr2}, + expErr: false, + }, + "same address twice": { + src: AccAddresses{addr1, addr1}, + expErr: true, + }, + } + + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/group/typesupport.go b/x/group/typesupport.go new file mode 100644 index 0000000000..d300b1b9fb --- /dev/null +++ b/x/group/typesupport.go @@ -0,0 +1,39 @@ +package group + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +func (ms Members) ValidateBasic() error { + index := make(map[string]struct{}, len(ms.Members)) + for i := range ms.Members { + member := ms.Members[i] + if err := member.ValidateBasic(); err != nil { + return err + } + addr := member.Address + if _, exists := index[addr]; exists { + return sdkerrors.Wrapf(ErrDuplicate, "address: %s", addr) + } + index[addr] = struct{}{} + } + return nil +} + +type AccAddresses []sdk.AccAddress + +// ValidateBasic verifies that there's no duplicate address. +// Individual account address validation has to be done separately. +func (a AccAddresses) ValidateBasic() error { + index := make(map[string]struct{}, len(a)) + for i := range a { + accAddr := a[i] + addr := string(accAddr) + if _, exists := index[addr]; exists { + return sdkerrors.Wrapf(ErrDuplicate, "address: %s", accAddr.String()) + } + index[addr] = struct{}{} + } + return nil +} From 3b04720f82415c4fed1129a29e0522e52d37ff2f Mon Sep 17 00:00:00 2001 From: kitty Date: Fri, 30 Jul 2021 13:00:25 +0100 Subject: [PATCH 13/34] minor changes to bls12381 key generation --- crypto/keys/bls12381/bls12381.go | 9 +++++++-- crypto/keys/bls12381/bls12381_test.go | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/crypto/keys/bls12381/bls12381.go b/crypto/keys/bls12381/bls12381.go index eab266c3d2..7aa9ffb98c 100644 --- a/crypto/keys/bls12381/bls12381.go +++ b/crypto/keys/bls12381/bls12381.go @@ -122,7 +122,7 @@ func genPrivKey(rand io.Reader) []byte { sk := blst.KeyGen(ikm[:]) if sk == nil { - panic("Failed to generate secret key!") + panic("failed to generate secret key!") } skBytes := sk.Serialize() @@ -136,7 +136,12 @@ func genPrivKey(rand io.Reader) []byte { // if it's derived from user input. func GenPrivKeyFromSecret(secret []byte) *PrivKey { ikm := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes. - skBytes := blst.KeyGen(ikm).Serialize() + + sk := blst.KeyGen(ikm) + if sk == nil { + panic("failed to generate secret key from ikm") + } + skBytes := sk.Serialize() return &PrivKey{Key: skBytes} } diff --git a/crypto/keys/bls12381/bls12381_test.go b/crypto/keys/bls12381/bls12381_test.go index 48fbd02faf..8271718a64 100644 --- a/crypto/keys/bls12381/bls12381_test.go +++ b/crypto/keys/bls12381/bls12381_test.go @@ -22,6 +22,18 @@ func TestSignAndValidateBls12381(t *testing.T) { } +func TestKeyFromSecret(t *testing.T) { + insecureSeed := []byte("a random number for testing") + privKey := bls12381.GenPrivKeyFromSecret(insecureSeed) + pubKey := privKey.PubKey() + + msg := []byte("hello") + sig, err := privKey.Sign(msg) + require.Nil(t, err) + assert.True(t, pubKey.VerifySignature(msg, sig)) + +} + func BenchmarkSignBls(b *testing.B) { privKey := bls12381.GenPrivKey() From 4791350c2e74065cd26610b25138a9c168a5a31f Mon Sep 17 00:00:00 2001 From: kitty Date: Fri, 30 Jul 2021 17:50:06 +0100 Subject: [PATCH 14/34] initial commit from regen-ledger/proto/regen/group v1.0.0 --- proto/regen/group/v1alpha1/events.proto | 54 +++++ proto/regen/group/v1alpha1/genesis.proto | 39 ++++ proto/regen/group/v1alpha1/query.proto | 244 +++++++++++++++++++++ proto/regen/group/v1alpha1/tx.proto | 258 ++++++++++++++++++++++ proto/regen/group/v1alpha1/types.proto | 268 +++++++++++++++++++++++ 5 files changed, 863 insertions(+) create mode 100644 proto/regen/group/v1alpha1/events.proto create mode 100644 proto/regen/group/v1alpha1/genesis.proto create mode 100644 proto/regen/group/v1alpha1/query.proto create mode 100644 proto/regen/group/v1alpha1/tx.proto create mode 100644 proto/regen/group/v1alpha1/types.proto diff --git a/proto/regen/group/v1alpha1/events.proto b/proto/regen/group/v1alpha1/events.proto new file mode 100644 index 0000000000..6fed94ac81 --- /dev/null +++ b/proto/regen/group/v1alpha1/events.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; + +package regen.group.v1alpha1; + +option go_package = "github.com/regen-network/regen-ledger/x/group"; + +// EventCreateGroup is an event emitted when a group is created. +message EventCreateGroup { + + // group_id is the unique ID of the group. + uint64 group_id = 1; +} + +// EventUpdateGroup is an event emitted when a group is updated. +message EventUpdateGroup { + + // group_id is the unique ID of the group. + uint64 group_id = 1; +} + +// EventCreateGroupAccount is an event emitted when a group account is created. +message EventCreateGroupAccount { + + // address is the address of the group account. + string address = 1; +} + +// EventUpdateGroupAccount is an event emitted when a group account is updated. +message EventUpdateGroupAccount { + + // address is the address of the group account. + string address = 1; +} + +// EventCreateProposal is an event emitted when a proposal is created. +message EventCreateProposal { + + // proposal_id is the unique ID of the proposal. + uint64 proposal_id = 1; +} + +// EventVote is an event emitted when a voter votes on a proposal. +message EventVote { + + // proposal_id is the unique ID of the proposal. + uint64 proposal_id = 1; +} + +// EventExec is an event emitted when a proposal is executed. +message EventExec { + + // proposal_id is the unique ID of the proposal. + uint64 proposal_id = 1; +} diff --git a/proto/regen/group/v1alpha1/genesis.proto b/proto/regen/group/v1alpha1/genesis.proto new file mode 100644 index 0000000000..4aef6b6bf2 --- /dev/null +++ b/proto/regen/group/v1alpha1/genesis.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; + +package regen.group.v1alpha1; + +option go_package = "github.com/regen-network/regen-ledger/x/group"; + +import "gogoproto/gogo.proto"; +import "regen/group/v1alpha1/types.proto"; + +// GenesisState defines the group module's genesis state. +message GenesisState { + + // group_seq is the group table orm.Sequence, + // it is used to get the next group ID. + uint64 group_seq = 1; + + // groups is the list of groups info. + repeated GroupInfo groups = 2; + + // group_members is the list of groups members. + repeated GroupMember group_members = 3; + + // group_account_seq is the group account table orm.Sequence, + // it is used to generate the next group account address. + uint64 group_account_seq = 4; + + // group_accounts is the list of group accounts info. + repeated GroupAccountInfo group_accounts = 5; + + // proposal_seq is the proposal table orm.Sequence, + // it is used to get the next proposal ID. + uint64 proposal_seq = 6; + + // proposals is the list of proposals. + repeated Proposal proposals = 7; + + // votes is the list of votes. + repeated Vote votes = 8; +} diff --git a/proto/regen/group/v1alpha1/query.proto b/proto/regen/group/v1alpha1/query.proto new file mode 100644 index 0000000000..185e203dc3 --- /dev/null +++ b/proto/regen/group/v1alpha1/query.proto @@ -0,0 +1,244 @@ +syntax = "proto3"; + +package regen.group.v1alpha1; + +import "regen/group/v1alpha1/types.proto"; +import "gogoproto/gogo.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; + +option go_package = "github.com/regen-network/regen-ledger/x/group"; + +// Query is the regen.group.v1alpha1 Query service. +service Query { + + // GroupInfo queries group info based on group id. + rpc GroupInfo(QueryGroupInfoRequest) returns (QueryGroupInfoResponse); + + // GroupAccountInfo queries group account info based on group account address. + rpc GroupAccountInfo(QueryGroupAccountInfoRequest) returns (QueryGroupAccountInfoResponse); + + // GroupMembers queries members of a group + rpc GroupMembers(QueryGroupMembersRequest) returns (QueryGroupMembersResponse); + + // GroupsByAdmin queries groups by admin address. + rpc GroupsByAdmin(QueryGroupsByAdminRequest) returns (QueryGroupsByAdminResponse); + + // GroupAccountsByGroup queries group accounts by group id. + rpc GroupAccountsByGroup(QueryGroupAccountsByGroupRequest) returns (QueryGroupAccountsByGroupResponse); + + // GroupsByAdmin queries group accounts by admin address. + rpc GroupAccountsByAdmin(QueryGroupAccountsByAdminRequest) returns (QueryGroupAccountsByAdminResponse); + + // Proposal queries a proposal based on proposal id. + rpc Proposal(QueryProposalRequest) returns (QueryProposalResponse); + + // ProposalsByGroupAccount queries proposals based on group account address. + rpc ProposalsByGroupAccount(QueryProposalsByGroupAccountRequest) returns (QueryProposalsByGroupAccountResponse); + + // VoteByProposalVoter queries a vote by proposal id and voter. + rpc VoteByProposalVoter(QueryVoteByProposalVoterRequest) returns (QueryVoteByProposalVoterResponse); + + // VotesByProposal queries a vote by proposal. + rpc VotesByProposal(QueryVotesByProposalRequest) returns (QueryVotesByProposalResponse); + + // VotesByVoter queries a vote by voter. + rpc VotesByVoter(QueryVotesByVoterRequest) returns (QueryVotesByVoterResponse); +} + +// QueryGroupInfoRequest is the Query/GroupInfo request type. +message QueryGroupInfoRequest { + + // group_id is the unique ID of the group. + uint64 group_id = 1; +} + +// QueryGroupInfoResponse is the Query/GroupInfo response type. +message QueryGroupInfoResponse { + + // info is the GroupInfo for the group. + GroupInfo info = 1; +} + +// QueryGroupAccountInfoRequest is the Query/GroupAccountInfo request type. +message QueryGroupAccountInfoRequest { + + // address is the account address of the group account. + string address = 1; +} + +// QueryGroupAccountInfoResponse is the Query/GroupAccountInfo response type. +message QueryGroupAccountInfoResponse { + + // info is the GroupAccountInfo for the group account. + GroupAccountInfo info = 1; +} + +// QueryGroupMembersRequest is the Query/GroupMembersRequest request type. +message QueryGroupMembersRequest { + + // group_id is the unique ID of the group. + uint64 group_id = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryGroupMembersResponse is the Query/GroupMembersResponse response type. +message QueryGroupMembersResponse { + + // members are the members of the group with given group_id. + repeated GroupMember members = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryGroupsByAdminRequest is the Query/GroupsByAdminRequest request type. +message QueryGroupsByAdminRequest { + + // admin is the account address of a group's admin. + string admin = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryGroupsByAdminResponse is the Query/GroupsByAdminResponse response type. +message QueryGroupsByAdminResponse { + + // groups are the groups info with the provided admin. + repeated GroupInfo groups = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryGroupAccountsByGroupRequest is the Query/GroupAccountsByGroup request type. +message QueryGroupAccountsByGroupRequest { + + // group_id is the unique ID of the group account's group. + uint64 group_id = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryGroupAccountsByGroupResponse is the Query/GroupAccountsByGroup response type. +message QueryGroupAccountsByGroupResponse { + + // group_accounts are the group accounts info associated with the provided group. + repeated GroupAccountInfo group_accounts = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryGroupAccountsByAdminRequest is the Query/GroupAccountsByAdmin request type. +message QueryGroupAccountsByAdminRequest { + + // admin is the admin address of the group account. + string admin = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryGroupAccountsByAdminResponse is the Query/GroupAccountsByAdmin response type. +message QueryGroupAccountsByAdminResponse { + + // group_accounts are the group accounts info with provided admin. + repeated GroupAccountInfo group_accounts = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryProposalRequest is the Query/Proposal request type. +message QueryProposalRequest { + + // proposal_id is the unique ID of a proposal. + uint64 proposal_id = 1; +} + +// QueryProposalResponse is the Query/Proposal response type. +message QueryProposalResponse { + + // proposal is the proposal info. + Proposal proposal = 1; +} + +// QueryProposalsByGroupAccountRequest is the Query/ProposalByGroupAccount request type. +message QueryProposalsByGroupAccountRequest { + + // address is the group account address related to proposals. + string address = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryProposalsByGroupAccountResponse is the Query/ProposalByGroupAccount response type. +message QueryProposalsByGroupAccountResponse { + + // proposals are the proposals with given group account. + repeated Proposal proposals = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryVoteByProposalVoterResponse is the Query/VoteByProposalVoter request type. +message QueryVoteByProposalVoterRequest { + + // proposal_id is the unique ID of a proposal. + uint64 proposal_id = 1; + + // voter is a proposal voter account address. + string voter = 2; +} + +// QueryVoteByProposalVoterResponse is the Query/VoteByProposalVoter response type. +message QueryVoteByProposalVoterResponse { + + // vote is the vote with given proposal_id and voter. + Vote vote = 1; +} + +// QueryVotesByProposalResponse is the Query/VotesByProposal request type. +message QueryVotesByProposalRequest { + + // proposal_id is the unique ID of a proposal. + uint64 proposal_id = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryVotesByProposalResponse is the Query/VotesByProposal response type. +message QueryVotesByProposalResponse { + + // votes are the list of votes for given proposal_id. + repeated Vote votes = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryVotesByVoterResponse is the Query/VotesByVoter request type. +message QueryVotesByVoterRequest { + // voter is a proposal voter account address. + string voter = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryVotesByVoterResponse is the Query/VotesByVoter response type. +message QueryVotesByVoterResponse { + + // votes are the list of votes by given voter. + repeated Vote votes = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/proto/regen/group/v1alpha1/tx.proto b/proto/regen/group/v1alpha1/tx.proto new file mode 100644 index 0000000000..e17d7e9d57 --- /dev/null +++ b/proto/regen/group/v1alpha1/tx.proto @@ -0,0 +1,258 @@ +syntax = "proto3"; + +package regen.group.v1alpha1; + +option go_package = "github.com/regen-network/regen-ledger/x/group"; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/any.proto"; +import "regen/group/v1alpha1/types.proto"; + +// Msg is the regen.group.v1alpha1 Msg service. +service Msg { + + // CreateGroup creates a new group with an admin account address, a list of members and some optional metadata. + rpc CreateGroup(MsgCreateGroupRequest) returns (MsgCreateGroupResponse); + + // UpdateGroupMembers updates the group members with given group id and admin address. + rpc UpdateGroupMembers(MsgUpdateGroupMembersRequest) returns (MsgUpdateGroupMembersResponse); + + // UpdateGroupAdmin updates the group admin with given group id and previous admin address. + rpc UpdateGroupAdmin(MsgUpdateGroupAdminRequest) returns (MsgUpdateGroupAdminResponse); + + // UpdateGroupMetadata updates the group metadata with given group id and admin address. + rpc UpdateGroupMetadata(MsgUpdateGroupMetadataRequest) returns (MsgUpdateGroupMetadataResponse); + + // CreateGroupAccount creates a new group account using given DecisionPolicy. + rpc CreateGroupAccount(MsgCreateGroupAccountRequest) returns (MsgCreateGroupAccountResponse); + + // UpdateGroupAccountAdmin updates a group account admin. + rpc UpdateGroupAccountAdmin(MsgUpdateGroupAccountAdminRequest) returns (MsgUpdateGroupAccountAdminResponse); + + // UpdateGroupAccountDecisionPolicy allows a group account decision policy to be updated. + rpc UpdateGroupAccountDecisionPolicy(MsgUpdateGroupAccountDecisionPolicyRequest) returns (MsgUpdateGroupAccountDecisionPolicyResponse); + + // UpdateGroupAccountMetadata updates a group account metadata. + rpc UpdateGroupAccountMetadata(MsgUpdateGroupAccountMetadataRequest) returns (MsgUpdateGroupAccountMetadataResponse); + + // CreateProposal submits a new proposal. + rpc CreateProposal(MsgCreateProposalRequest) returns (MsgCreateProposalResponse); + + // Vote allows a voter to vote on a proposal. + rpc Vote(MsgVoteRequest) returns (MsgVoteResponse); + + // Exec executes a proposal. + rpc Exec(MsgExecRequest) returns (MsgExecResponse); +} + +// +// Groups +// + +// MsgCreateGroupRequest is the Msg/CreateGroup request type. +message MsgCreateGroupRequest { + + // admin is the account address of the group admin. + string admin = 1; + + // members defines the group members. + repeated Member members = 2 [(gogoproto.nullable) = false]; + + // metadata is any arbitrary metadata to attached to the group. + bytes metadata = 3; +} + +// MsgCreateGroupResponse is the Msg/CreateGroup response type. +message MsgCreateGroupResponse { + + // group_id is the unique ID of the newly created group. + uint64 group_id = 1; +} + +// MsgUpdateGroupMembersRequest is the Msg/UpdateGroupMembers request type. +message MsgUpdateGroupMembersRequest { + + // admin is the account address of the group admin. + string admin = 1; + + // group_id is the unique ID of the group. + uint64 group_id = 2; + + // member_updates is the list of members to update, + // set weight to 0 to remove a member. + repeated Member member_updates = 3 [(gogoproto.nullable) = false]; +} + +// MsgUpdateGroupMembersResponse is the Msg/UpdateGroupMembers response type. +message MsgUpdateGroupMembersResponse { } + +// MsgUpdateGroupAdminRequest is the Msg/UpdateGroupAdmin request type. +message MsgUpdateGroupAdminRequest { + + // admin is the current account address of the group admin. + string admin = 1; + + // group_id is the unique ID of the group. + uint64 group_id = 2; + + // new_admin is the group new admin account address. + string new_admin = 3; +} + +// MsgUpdateGroupAdminResponse is the Msg/UpdateGroupAdmin response type. +message MsgUpdateGroupAdminResponse { } + +// MsgUpdateGroupMetadataRequest is the Msg/UpdateGroupMetadata request type. +message MsgUpdateGroupMetadataRequest { + + // admin is the account address of the group admin. + string admin = 1; + + // group_id is the unique ID of the group. + uint64 group_id = 2; + + // metadata is the updated group's metadata. + bytes metadata = 3; +} + +// MsgUpdateGroupMetadataResponse is the Msg/UpdateGroupMetadata response type. +message MsgUpdateGroupMetadataResponse { } + +// +// Group Accounts +// + +// MsgCreateGroupAccountRequest is the Msg/CreateGroupAccount request type. +message MsgCreateGroupAccountRequest { + option (gogoproto.goproto_getters) = false; + + // admin is the account address of the group admin. + string admin = 1; + + // group_id is the unique ID of the group. + uint64 group_id = 2; + + // metadata is any arbitrary metadata to attached to the group account. + bytes metadata = 3; + + // decision_policy specifies the group account's decision policy. + google.protobuf.Any decision_policy = 4 [(cosmos_proto.accepts_interface) = "DecisionPolicy"]; +} + +// MsgCreateGroupAccountResponse is the Msg/CreateGroupAccount response type. +message MsgCreateGroupAccountResponse { + + // address is the account address of the newly created group account. + string address = 1; +} + +// MsgUpdateGroupAccountAdminRequest is the Msg/UpdateGroupAccountAdmin request type. +message MsgUpdateGroupAccountAdminRequest { + + // admin is the account address of the group admin. + string admin = 1; + + // address is the group account address. + string address = 2; + + // new_admin is the new group account admin. + string new_admin = 3; +} + +// MsgUpdateGroupAccountAdminResponse is the Msg/UpdateGroupAccountAdmin response type. +message MsgUpdateGroupAccountAdminResponse { } + +// MsgUpdateGroupAccountDecisionPolicyRequest is the Msg/UpdateGroupAccountDecisionPolicy request type. +message MsgUpdateGroupAccountDecisionPolicyRequest { + option (gogoproto.goproto_getters) = false; + + // admin is the account address of the group admin. + string admin = 1; + + // address is the group account address. + string address = 2; + + // decision_policy is the updated group account decision policy. + google.protobuf.Any decision_policy = 3 [(cosmos_proto.accepts_interface) = "DecisionPolicy"]; +} + +// MsgUpdateGroupAccountDecisionPolicyResponse is the Msg/UpdateGroupAccountDecisionPolicy response type. +message MsgUpdateGroupAccountDecisionPolicyResponse { } + +// MsgUpdateGroupAccountMetadataRequest is the Msg/UpdateGroupAccountMetadata request type. +message MsgUpdateGroupAccountMetadataRequest { + + // admin is the account address of the group admin. + string admin = 1; + + // address is the group account address. + string address = 2; + + // metadata is the updated group account metadata. + bytes metadata = 3; +} + +// MsgUpdateGroupAccountMetadataResponse is the Msg/UpdateGroupAccountMetadata response type. +message MsgUpdateGroupAccountMetadataResponse { } + +// +// Proposals and Voting +// + +// MsgCreateProposalRequest is the Msg/CreateProposal request type. +message MsgCreateProposalRequest { + option (gogoproto.goproto_getters) = false; + + // address is the group account address. + string address = 1; + + // proposers are the account addresses of the proposers. + // Proposers signatures will be counted as yes votes. + repeated string proposers = 2; + + // metadata is any arbitrary metadata to attached to the proposal. + bytes metadata = 3; + + // msgs is a list of Msgs that will be executed if the proposal passes. + repeated google.protobuf.Any msgs = 4; +} + +// MsgCreateProposalResponse is the Msg/CreateProposal response type. +message MsgCreateProposalResponse { + + // proposal is the unique ID of the proposal. + uint64 proposal_id = 1; +} + +// MsgVoteRequest is the Msg/Vote request type. +message MsgVoteRequest { + + // proposal is the unique ID of the proposal. + uint64 proposal_id = 1; + + // voter is the voter account address. + string voter = 2; + + // choice is the voter's choice on the proposal. + Choice choice = 3; + + // metadata is any arbitrary metadata to attached to the vote. + bytes metadata = 4; +} + +// MsgVoteResponse is the Msg/Vote response type. +message MsgVoteResponse { } + +// MsgExecRequest is the Msg/Exec request type. +message MsgExecRequest { + + // proposal is the unique ID of the proposal. + uint64 proposal_id = 1; + + // signer is the account address used to execute the proposal. + string signer = 2; +} + +// MsgExecResponse is the Msg/Exec request type. +message MsgExecResponse { } diff --git a/proto/regen/group/v1alpha1/types.proto b/proto/regen/group/v1alpha1/types.proto new file mode 100644 index 0000000000..dcc02cd830 --- /dev/null +++ b/proto/regen/group/v1alpha1/types.proto @@ -0,0 +1,268 @@ +syntax = "proto3"; + +package regen.group.v1alpha1; + +option go_package = "github.com/regen-network/regen-ledger/x/group"; + +import "gogoproto/gogo.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/any.proto"; + +// Member represents a group member with an account address, +// non-zero weight and metadata. +message Member { + + // address is the member's account address. + string address = 1; + + // weight is the member's voting weight that should be greater than 0. + string weight = 2; + + // metadata is any arbitrary metadata to attached to the member. + bytes metadata = 3; +} + +// Members defines a repeated slice of Member objects. +message Members { + + // members is the list of members. + repeated Member members = 1 [(gogoproto.nullable) = false]; +} + +// ThresholdDecisionPolicy implements the DecisionPolicy interface +message ThresholdDecisionPolicy { + option (cosmos_proto.implements_interface) = "DecisionPolicy"; + + // threshold is the minimum weighted sum of yes votes that must be met or exceeded for a proposal to succeed. + string threshold = 1; + + // timeout is the duration from submission of a proposal to the end of voting period + // Within this times votes and exec messages can be submitted. + google.protobuf.Duration timeout = 2 [(gogoproto.nullable) = false]; +} + +// Choice defines available types of choices for voting. +enum Choice { + + // CHOICE_UNSPECIFIED defines a no-op voting choice. + CHOICE_UNSPECIFIED = 0; + + // CHOICE_NO defines a no voting choice. + CHOICE_NO = 1; + + // CHOICE_YES defines a yes voting choice. + CHOICE_YES = 2; + + // CHOICE_ABSTAIN defines an abstaining voting choice. + CHOICE_ABSTAIN = 3; + + // CHOICE_VETO defines a voting choice with veto. + CHOICE_VETO = 4; +} + +// +// State +// + +// GroupInfo represents the high-level on-chain information for a group. +message GroupInfo { + + // group_id is the unique ID of the group. + uint64 group_id = 1; + + // admin is the account address of the group's admin. + string admin = 2; + + // metadata is any arbitrary metadata to attached to the group. + bytes metadata = 3; + + // version is used to track changes to a group's membership structure that + // would break existing proposals. Whenever any members weight is changed, + // or any member is added or removed this version is incremented and will + // cause proposals based on older versions of this group to fail + uint64 version = 4; + + // total_weight is the sum of the group members' weights. + string total_weight = 5; +} + +// GroupMember represents the relationship between a group and a member. +message GroupMember { + + // group_id is the unique ID of the group. + uint64 group_id = 1; + + // member is the member data. + Member member = 2; +} + +// GroupAccountInfo represents the high-level on-chain information for a group account. +message GroupAccountInfo { + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; + + // address is the group account address. + string address = 1; + + // group_id is the unique ID of the group. + uint64 group_id = 2; + + // admin is the account address of the group admin. + string admin = 3; + + // metadata is any arbitrary metadata to attached to the group account. + bytes metadata = 4; + + // version is used to track changes to a group's GroupAccountInfo structure that + // would create a different result on a running proposal. + uint64 version = 5; + + // decision_policy specifies the group account's decision policy. + google.protobuf.Any decision_policy = 6 [(cosmos_proto.accepts_interface) = "DecisionPolicy"]; +} + +// Proposal defines a group proposal. Any member of a group can submit a proposal +// for a group account to decide upon. +// A proposal consists of a set of `sdk.Msg`s that will be executed if the proposal +// passes as well as some optional metadata associated with the proposal. +message Proposal { + option (gogoproto.goproto_getters) = false; + + // proposal_id is the unique id of the proposal. + uint64 proposal_id = 1; + + // address is the group account address. + string address = 2; + + // metadata is any arbitrary metadata to attached to the proposal. + bytes metadata = 3; + + // proposers are the account addresses of the proposers. + repeated string proposers = 4; + + // submitted_at is a timestamp specifying when a proposal was submitted. + google.protobuf.Timestamp submitted_at = 5 [(gogoproto.nullable) = false]; + + // group_version tracks the version of the group that this proposal corresponds to. + // When group membership is changed, existing proposals from previous group versions will become invalid. + uint64 group_version = 6; + + // group_account_version tracks the version of the group account that this proposal corresponds to. + // When a decision policy is changed, existing proposals from previous policy versions will become invalid. + uint64 group_account_version = 7; + + // Status defines proposal statuses. + enum Status { + option (gogoproto.goproto_enum_prefix) = false; + + // An empty value is invalid and not allowed. + STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "ProposalStatusInvalid"]; + + // Initial status of a proposal when persisted. + STATUS_SUBMITTED = 1 [(gogoproto.enumvalue_customname) = "ProposalStatusSubmitted"]; + + // Final status of a proposal when the final tally was executed. + STATUS_CLOSED = 2 [(gogoproto.enumvalue_customname) = "ProposalStatusClosed"]; + + // Final status of a proposal when the group was modified before the final tally. + STATUS_ABORTED = 3 [(gogoproto.enumvalue_customname) = "ProposalStatusAborted"]; + + // TODO: do we want to support a withdrawn operation? + // A proposal can be deleted before the voting start time by the owner. When this happens the final status + // is Withdrawn. + // STATUS_WITHDRAWN = 4 [(gogoproto.enumvalue_customname) = "Withdrawn"]; + } + + // Status represents the high level position in the life cycle of the proposal. Initial value is Submitted. + Status status = 8; + + // Result defines types of proposal results. + enum Result { + option (gogoproto.goproto_enum_prefix) = false; + + // An empty value is invalid and not allowed + RESULT_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "ProposalResultInvalid"]; + + // Until a final tally has happened the status is unfinalized + RESULT_UNFINALIZED = 1 [(gogoproto.enumvalue_customname) = "ProposalResultUnfinalized"]; + + // Final result of the tally + RESULT_ACCEPTED = 2 [(gogoproto.enumvalue_customname) = "ProposalResultAccepted"]; + + // Final result of the tally + RESULT_REJECTED = 3 [(gogoproto.enumvalue_customname) = "ProposalResultRejected"]; + } + + // result is the final result based on the votes and election rule. Initial value is unfinalized. + // The result is persisted so that clients can always rely on this state and not have to replicate the logic. + Result result = 9; + + // vote_state contains the sums of all weighted votes for this proposal. + Tally vote_state = 10 [(gogoproto.nullable) = false]; + + // timeout is the timestamp of the block where the proposal execution times out. Header times of the votes and execution messages + // must be before this end time to be included in the election. After the timeout timestamp the proposal can not be + // executed anymore and should be considered pending delete. + google.protobuf.Timestamp timeout = 11 [(gogoproto.nullable) = false]; + + // ExecutorResult defines types of proposal executor results. + enum ExecutorResult { + option (gogoproto.goproto_enum_prefix) = false; + + // An empty value is not allowed. + EXECUTOR_RESULT_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "ProposalExecutorResultInvalid"]; + + // We have not yet run the executor. + EXECUTOR_RESULT_NOT_RUN = 1 [(gogoproto.enumvalue_customname) = "ProposalExecutorResultNotRun"]; + + // The executor was successful and proposed action updated state. + EXECUTOR_RESULT_SUCCESS = 2 [(gogoproto.enumvalue_customname) = "ProposalExecutorResultSuccess"]; + + // The executor returned an error and proposed action didn't update state. + EXECUTOR_RESULT_FAILURE = 3 [(gogoproto.enumvalue_customname) = "ProposalExecutorResultFailure"]; + } + + // executor_result is the final result based on the votes and election rule. Initial value is NotRun. + ExecutorResult executor_result = 12; + + // msgs is a list of Msgs that will be executed if the proposal passes. + repeated google.protobuf.Any msgs = 13; +} + +// Tally represents the sum of weighted votes. +message Tally { + option (gogoproto.goproto_getters) = false; + + // yes_count is the weighted sum of yes votes. + string yes_count = 1; + + // no_count is the weighted sum of no votes. + string no_count = 2; + + // abstain_count is the weighted sum of abstainers + string abstain_count = 3; + + // veto_count is the weighted sum of vetoes. + string veto_count = 4; +} + +// Vote represents a vote for a proposal. +message Vote { + + // proposal is the unique ID of the proposal. + uint64 proposal_id = 1; + + // voter is the account address of the voter. + string voter = 2; + + // choice is the voter's choice on the proposal. + Choice choice = 3; + + // metadata is any arbitrary metadata to attached to the vote. + bytes metadata = 4; + + // submitted_at is the timestamp when the vote was submitted. + google.protobuf.Timestamp submitted_at = 5 [(gogoproto.nullable) = false]; +} From c9eafc940426d00ee4f42cff1e6eb866b2accdc7 Mon Sep 17 00:00:00 2001 From: kitty Date: Mon, 2 Aug 2021 13:48:21 +0100 Subject: [PATCH 15/34] group module compatibility for fetchai cosomos-sdk --- go.mod | 17 +++--- go.sum | 74 +++++++++++++++++++++--- proto/regen/group/v1alpha1/events.proto | 2 +- proto/regen/group/v1alpha1/genesis.proto | 2 +- proto/regen/group/v1alpha1/query.proto | 2 +- proto/regen/group/v1alpha1/tx.proto | 2 +- proto/regen/group/v1alpha1/types.proto | 2 +- x/group/client/query.go | 2 +- x/group/client/tx.go | 2 +- x/group/client/util.go | 3 +- x/group/module/module.go | 16 +++-- x/group/server/genesis.go | 2 +- x/group/server/handler.go | 2 +- x/group/server/msg_server.go | 2 +- x/group/server/proposal_executor.go | 2 +- x/group/server/query_server.go | 2 +- x/group/server/server.go | 2 +- x/group/server/server_test.go | 4 +- 18 files changed, 99 insertions(+), 41 deletions(-) diff --git a/go.mod b/go.mod index ee4bb40e80..79c347b1c0 100644 --- a/go.mod +++ b/go.mod @@ -4,29 +4,27 @@ module github.com/cosmos/cosmos-sdk require ( github.com/99designs/keyring v1.1.6 - github.com/DataDog/zstd v1.4.5 // indirect github.com/armon/go-metrics v0.3.8 github.com/bgentry/speakeasy v0.1.0 github.com/btcsuite/btcd v0.21.0-beta github.com/btcsuite/btcutil v1.0.2 + github.com/cockroachdb/apd/v2 v2.0.2 github.com/confio/ics23/go v0.6.6 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/iavl v0.16.0 github.com/cosmos/ledger-cosmos-go v0.11.1 - github.com/dgraph-io/ristretto v0.0.3 // indirect - github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25 github.com/gogo/gateway v1.1.0 github.com/gogo/protobuf v1.3.3 github.com/golang/mock v1.4.4 github.com/golang/protobuf v1.5.2 github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3 // indirect - github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa // indirect github.com/gorilla/handlers v1.5.1 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/golang-lru v0.5.4 + github.com/lib/pq v1.10.2 // indirect github.com/magiconair/properties v1.8.5 github.com/mattn/go-isatty v0.0.12 github.com/mitchellh/mapstructure v1.3.3 // indirect @@ -37,11 +35,10 @@ require ( github.com/prometheus/common v0.23.0 github.com/rakyll/statik v0.1.7 github.com/regen-network/cosmos-proto v0.3.1 + github.com/regen-network/regen-ledger v1.0.0 github.com/rs/zerolog v1.21.0 - github.com/spf13/afero v1.3.4 // indirect github.com/spf13/cast v1.3.1 github.com/spf13/cobra v1.1.3 - github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.7.0 @@ -51,9 +48,9 @@ require ( github.com/tendermint/go-amino v0.16.0 github.com/tendermint/tendermint v0.34.11 github.com/tendermint/tm-db v0.6.4 - golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad + golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect - google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f + google.golang.org/genproto v0.0.0-20210406143921-e86de6bf7a46 google.golang.org/grpc v1.37.0 google.golang.org/protobuf v1.26.0 gopkg.in/ini.v1 v1.61.0 // indirect @@ -67,3 +64,7 @@ replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alp replace github.com/tendermint/tendermint => github.com/fetchai/tendermint v1.0.0 replace github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 + +replace github.com/regen-network/regen-ledger => github.com/kitounliu/regen-ledger v1.0.0-fetchai-1 + +//replace github.com/supranational/blst => github.com/ejfitzgerald/blst v0.3.5-0.20210729162216-d4a811d56976 diff --git a/go.sum b/go.sum index b382b59e32..eabc793686 100644 --- a/go.sum +++ b/go.sum @@ -14,6 +14,10 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= +github.com/CosmWasm/wasmd v0.15.0 h1:QG0GSnFvynbzI8Lls6V73+JjYFQjY92MZ/zOauDJ1NU= +github.com/CosmWasm/wasmd v0.15.0/go.mod h1:muLJYc43u0JMZ+j96IMkbyBnkwsvO/gaEx8ZHQIJwvk= +github.com/CosmWasm/wasmvm v0.13.0 h1:AP8LVcCxI3KLtHY24qLhzVe+ChOXwcR8MNm8Jxkuhwk= +github.com/CosmWasm/wasmvm v0.13.0/go.mod h1:Id107qllDJyJjVQQsKMOy2YYF98sqPJ2t+jX1QES40A= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= @@ -40,6 +44,7 @@ github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-metrics v0.3.6/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-metrics v0.3.8 h1:oOxq3KPj0WhCuy50EhzwiyMyG2ovRQZpZLXQuOh2a/M= github.com/armon/go-metrics v0.3.8/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= @@ -81,6 +86,8 @@ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6D github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= +github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/confio/ics23/go v0.6.3/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= @@ -96,6 +103,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cosmos/cosmos-sdk v0.41.0/go.mod h1:vlgqdPpUGSxgqSbZea6fjszoLkPKwCuiqSBySLlv4ro= +github.com/cosmos/cosmos-sdk v0.42.0-rc0/go.mod h1:xiLp1G8mumj82S5KLJGCAyeAlD+7VNomg/aRSJV12yk= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= @@ -205,6 +214,7 @@ github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3 h1:ur2rms48b3Ep1dxh7aUV2FZEQ8jEVO2F6ILKx8ofkAg= github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -220,8 +230,8 @@ github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64= -github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= @@ -297,6 +307,8 @@ github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmK github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/ipfs/go-cid v0.0.7 h1:ysQJVJA3fNDF1qigJbsSQOdjhVLsOEoPdh0+R97k3jY= +github.com/ipfs/go-cid v0.0.7/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -319,6 +331,8 @@ github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0 github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kitounliu/regen-ledger v1.0.0-fetchai-1 h1:I/OZ0qbLy4J0Pqx1UMFDybWXnhb/xMoNFT3Yi8uln94= +github.com/kitounliu/regen-ledger v1.0.0-fetchai-1/go.mod h1:qW0GomcarXVf82TctmfVpCUQ+wVEmq2Ny41heagK7D4= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+NVZZA= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -330,12 +344,16 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= +github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.4/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= @@ -349,8 +367,12 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= +github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g= +github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= github.com/minio/highwayhash v1.0.1 h1:dZ6IIu8Z14VlC0VpfKofAhCy74wu/Qb5gcn52yWoz/0= github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= +github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771 h1:MHkK1uRtFbVqvAgvWxafZe54+5uBxLluGylDiKgdhwo= +github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -365,8 +387,22 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= +github.com/mr-tron/base58 v1.1.3 h1:v+sk57XuaCKGXpWtVBX8YJzO7hMGx4Aajh4TQbdEFdc= +github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= +github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI= +github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA= +github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4= +github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM= +github.com/multiformats/go-multibase v0.0.3 h1:l/B6bJDQjvQ5G52jw4QGSYeOTZoAwIO77RblWplfIqk= +github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc= +github.com/multiformats/go-multihash v0.0.13/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc= +github.com/multiformats/go-multihash v0.0.14 h1:QoBceQYQQtNUuf6s7wHxnE2c8bhbMqhfGzNI032se/I= +github.com/multiformats/go-multihash v0.0.14/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc= +github.com/multiformats/go-varint v0.0.5 h1:XVZwSo04Cs3j/jS0uAEPpT3JY6DzMcVLLoWOSnCxOjg= +github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= @@ -401,6 +437,7 @@ github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxS github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/otiai10/copy v1.4.2/go.mod h1:XWfuS3CrI0R6IE0FbgHsEazaXO8G0LpMp9o8tos0x4E= github.com/otiai10/copy v1.6.0 h1:IinKAryFFuPONZ7cm6T6E2QX/vcJwSnlaA5lfoaXIiQ= github.com/otiai10/copy v1.6.0/go.mod h1:XWfuS3CrI0R6IE0FbgHsEazaXO8G0LpMp9o8tos0x4E= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= @@ -414,6 +451,7 @@ github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0Mw github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs= github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= @@ -455,6 +493,7 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= +github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.18.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.23.0 h1:GXWvPYuTUenIa+BhOq/x+L/QZzCqASkVRny5KTlPDGM= github.com/prometheus/common v0.23.0/go.mod h1:H6QK/N6XVT42whUeIdI3dp36w49c+/iMDk7UAI2qm7Q= @@ -483,6 +522,7 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= +github.com/rs/zerolog v1.20.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo= github.com/rs/zerolog v1.21.0 h1:Q3vdXlfLNT+OftyBHsU0Y445MD+8m8axjKgf2si0QcM= github.com/rs/zerolog v1.21.0/go.mod h1:ZPhntP/xmq1nnND05hhpAh2QMhSsA4UN3MGZ6O2J3hM= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= @@ -538,6 +578,7 @@ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoH github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -545,6 +586,7 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/supranational/blst v0.3.4 h1:iZE9lBMoywK2uy2U/5hDOvobQk9FnOQ2wNlu9GmRCoA= github.com/supranational/blst v0.3.4/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca h1:Ld/zXl5t4+D69SiV4JoN7kkfvJdOWlPpfxrzxpLMoUk= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= @@ -555,6 +597,7 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/tm-db v0.5.1/go.mod h1:g92zWjHpCYlEvQXvy9M168Su8V1IBEeawpXVVBaK4f4= github.com/tendermint/tm-db v0.6.3/go.mod h1:lfA1dL9/Y/Y8wwyPp2NMLyn5P5Ptr/gvDFNWtrCWSf8= github.com/tendermint/tm-db v0.6.4 h1:3N2jlnYQkXNQclQwd/eKV/NzlqPlfK21cpRRIx80XXQ= github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw= @@ -595,6 +638,7 @@ golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -605,8 +649,9 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -621,6 +666,7 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -646,6 +692,7 @@ golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= @@ -654,8 +701,11 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4 h1:b0LrWgu8+q7z4J+0Y3Umo5q1dL7NXBkKBWkaVkAq17E= +golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -707,18 +757,25 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201211090839-8ad439b19e0f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -736,6 +793,7 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -743,6 +801,7 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -778,8 +837,9 @@ google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20201119123407-9b1e624d6bc4/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f h1:izedQ6yVIc5mZsRuXzmSreCOlzI0lCU1HpG8yEdMiKw= google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210406143921-e86de6bf7a46 h1:f4STrQZf8jaowsiUitigvrqMCCM4QJH1A2JCSI7U1ow= +google.golang.org/genproto v0.0.0-20210406143921-e86de6bf7a46/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= diff --git a/proto/regen/group/v1alpha1/events.proto b/proto/regen/group/v1alpha1/events.proto index 6fed94ac81..2181ec2c55 100644 --- a/proto/regen/group/v1alpha1/events.proto +++ b/proto/regen/group/v1alpha1/events.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package regen.group.v1alpha1; -option go_package = "github.com/regen-network/regen-ledger/x/group"; +option go_package = "github.com/cosmos/cosmos-sdk/x/group"; // EventCreateGroup is an event emitted when a group is created. message EventCreateGroup { diff --git a/proto/regen/group/v1alpha1/genesis.proto b/proto/regen/group/v1alpha1/genesis.proto index 4aef6b6bf2..9567f87976 100644 --- a/proto/regen/group/v1alpha1/genesis.proto +++ b/proto/regen/group/v1alpha1/genesis.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package regen.group.v1alpha1; -option go_package = "github.com/regen-network/regen-ledger/x/group"; +option go_package = "github.com/cosmos/cosmos-sdk/x/group"; import "gogoproto/gogo.proto"; import "regen/group/v1alpha1/types.proto"; diff --git a/proto/regen/group/v1alpha1/query.proto b/proto/regen/group/v1alpha1/query.proto index 185e203dc3..6cfe1f45d2 100644 --- a/proto/regen/group/v1alpha1/query.proto +++ b/proto/regen/group/v1alpha1/query.proto @@ -6,7 +6,7 @@ import "regen/group/v1alpha1/types.proto"; import "gogoproto/gogo.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; -option go_package = "github.com/regen-network/regen-ledger/x/group"; +option go_package = "github.com/cosmos/cosmos-sdk/x/group"; // Query is the regen.group.v1alpha1 Query service. service Query { diff --git a/proto/regen/group/v1alpha1/tx.proto b/proto/regen/group/v1alpha1/tx.proto index e17d7e9d57..453ea72134 100644 --- a/proto/regen/group/v1alpha1/tx.proto +++ b/proto/regen/group/v1alpha1/tx.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package regen.group.v1alpha1; -option go_package = "github.com/regen-network/regen-ledger/x/group"; +option go_package = "github.com/cosmos/cosmos-sdk/x/group"; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; diff --git a/proto/regen/group/v1alpha1/types.proto b/proto/regen/group/v1alpha1/types.proto index dcc02cd830..8c8469ad28 100644 --- a/proto/regen/group/v1alpha1/types.proto +++ b/proto/regen/group/v1alpha1/types.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package regen.group.v1alpha1; -option go_package = "github.com/regen-network/regen-ledger/x/group"; +option go_package = "github.com/cosmos/cosmos-sdk/x/group"; import "gogoproto/gogo.proto"; import "google/protobuf/duration.proto"; diff --git a/x/group/client/query.go b/x/group/client/query.go index 01b2406286..5ddfea269d 100644 --- a/x/group/client/query.go +++ b/x/group/client/query.go @@ -5,7 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/regen-network/regen-ledger/x/group" + "github.com/cosmos/cosmos-sdk/x/group" "github.com/spf13/cobra" ) diff --git a/x/group/client/tx.go b/x/group/client/tx.go index 7fb1bab6dd..487772dffd 100644 --- a/x/group/client/tx.go +++ b/x/group/client/tx.go @@ -15,7 +15,7 @@ import ( authclient "github.com/cosmos/cosmos-sdk/x/auth/client" "github.com/spf13/cobra" - "github.com/regen-network/regen-ledger/x/group" + "github.com/cosmos/cosmos-sdk/x/group" ) const flagMembers = "members" diff --git a/x/group/client/util.go b/x/group/client/util.go index 5b326b6c06..790d122193 100644 --- a/x/group/client/util.go +++ b/x/group/client/util.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "github.com/cosmos/cosmos-sdk/client" - "github.com/regen-network/regen-ledger/x/group" + "github.com/cosmos/cosmos-sdk/x/group" ) func parseMembers(clientCtx client.Context, membersFile string) ([]group.Member, error) { @@ -18,7 +18,6 @@ func parseMembers(clientCtx client.Context, membersFile string) ([]group.Member, if err != nil { return nil, err } - err = clientCtx.JSONMarshaler.UnmarshalJSON(contents, &members) if err != nil { return nil, err diff --git a/x/group/module/module.go b/x/group/module/module.go index df7ab72532..fd0f92ca91 100644 --- a/x/group/module/module.go +++ b/x/group/module/module.go @@ -3,20 +3,18 @@ package module import ( "encoding/json" "fmt" - - "github.com/grpc-ecosystem/grpc-gateway/runtime" - climodule "github.com/regen-network/regen-ledger/types/module/client/cli" - servermodule "github.com/regen-network/regen-ledger/types/module/server" - "github.com/regen-network/regen-ledger/x/group" - "github.com/regen-network/regen-ledger/x/group/client" - "github.com/regen-network/regen-ledger/x/group/server" - sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/group" + "github.com/cosmos/cosmos-sdk/x/group/client" + "github.com/cosmos/cosmos-sdk/x/group/server" "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + climodule "github.com/regen-network/regen-ledger/types/module/client/cli" + servermodule "github.com/regen-network/regen-ledger/types/module/server" "github.com/spf13/cobra" ) @@ -72,4 +70,4 @@ func (a Module) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { func (a Module) Route(configurator servermodule.Configurator) sdk.Route { return sdk.NewRoute(group.RouterKey, server.NewHandler(configurator, a.AccountKeeper)) -} +} \ No newline at end of file diff --git a/x/group/server/genesis.go b/x/group/server/genesis.go index 8df0f2f2ca..f4afcb8ca8 100644 --- a/x/group/server/genesis.go +++ b/x/group/server/genesis.go @@ -7,9 +7,9 @@ import ( "github.com/cosmos/cosmos-sdk/types/errors" abci "github.com/tendermint/tendermint/abci/types" + "github.com/cosmos/cosmos-sdk/x/group" "github.com/regen-network/regen-ledger/orm" "github.com/regen-network/regen-ledger/types" - "github.com/regen-network/regen-ledger/x/group" ) func (s serverImpl) InitGenesis(ctx types.Context, cdc codec.JSONMarshaler, data json.RawMessage) ([]abci.ValidatorUpdate, error) { diff --git a/x/group/server/handler.go b/x/group/server/handler.go index a63f46dfad..86e940c50a 100644 --- a/x/group/server/handler.go +++ b/x/group/server/handler.go @@ -3,9 +3,9 @@ package server import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/group" "github.com/regen-network/regen-ledger/types" servermodule "github.com/regen-network/regen-ledger/types/module/server" - "github.com/regen-network/regen-ledger/x/group" ) // NewHandler creates an sdk.Handler for all the group type messages. diff --git a/x/group/server/msg_server.go b/x/group/server/msg_server.go index eb1c53ed82..3f38bd54f7 100644 --- a/x/group/server/msg_server.go +++ b/x/group/server/msg_server.go @@ -11,11 +11,11 @@ import ( "github.com/cockroachdb/apd/v2" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/group" gogotypes "github.com/gogo/protobuf/types" "github.com/regen-network/regen-ledger/math" "github.com/regen-network/regen-ledger/orm" "github.com/regen-network/regen-ledger/types" - "github.com/regen-network/regen-ledger/x/group" ) func (s serverImpl) CreateGroup(ctx types.Context, req *group.MsgCreateGroupRequest) (*group.MsgCreateGroupResponse, error) { diff --git a/x/group/server/proposal_executor.go b/x/group/server/proposal_executor.go index 1a2f2b230a..182e680dc8 100644 --- a/x/group/server/proposal_executor.go +++ b/x/group/server/proposal_executor.go @@ -3,7 +3,7 @@ package server import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/regen-network/regen-ledger/x/group" + "github.com/cosmos/cosmos-sdk/x/group" ) // ensureMsgAuthZ checks that if a message requires signers that all of them are equal to the given group account. diff --git a/x/group/server/query_server.go b/x/group/server/query_server.go index b9e80c2554..cd721ceb57 100644 --- a/x/group/server/query_server.go +++ b/x/group/server/query_server.go @@ -4,9 +4,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" + "github.com/cosmos/cosmos-sdk/x/group" "github.com/regen-network/regen-ledger/orm" "github.com/regen-network/regen-ledger/types" - "github.com/regen-network/regen-ledger/x/group" ) func (s serverImpl) GroupInfo(ctx types.Context, request *group.QueryGroupInfoRequest) (*group.QueryGroupInfoResponse, error) { diff --git a/x/group/server/server.go b/x/group/server/server.go index 326e7866fa..6355d0a8fb 100644 --- a/x/group/server/server.go +++ b/x/group/server/server.go @@ -1,9 +1,9 @@ package server import ( + "github.com/cosmos/cosmos-sdk/x/group" "github.com/regen-network/regen-ledger/orm" servermodule "github.com/regen-network/regen-ledger/types/module/server" - "github.com/regen-network/regen-ledger/x/group" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/group/server/server_test.go b/x/group/server/server_test.go index 9c73037c14..d013a48022 100644 --- a/x/group/server/server_test.go +++ b/x/group/server/server_test.go @@ -14,10 +14,10 @@ import ( "github.com/stretchr/testify/suite" + groupmodule "github.com/cosmos/cosmos-sdk/x/group/module" + "github.com/cosmos/cosmos-sdk/x/group/server/testsuite" "github.com/regen-network/regen-ledger/types/module" "github.com/regen-network/regen-ledger/types/module/server" - groupmodule "github.com/regen-network/regen-ledger/x/group/module" - "github.com/regen-network/regen-ledger/x/group/server/testsuite" ) func TestServer(t *testing.T) { From ff7fd2b3ac520eb00d39cd15912fcf73ab1d1df4 Mon Sep 17 00:00:00 2001 From: kitty Date: Wed, 4 Aug 2021 16:35:39 +0100 Subject: [PATCH 16/34] add bls account restriction to group members --- x/group/server/msg_server.go | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/x/group/server/msg_server.go b/x/group/server/msg_server.go index 3f38bd54f7..697ecc19b6 100644 --- a/x/group/server/msg_server.go +++ b/x/group/server/msg_server.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/binary" "fmt" + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" "reflect" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -18,6 +19,33 @@ import ( "github.com/regen-network/regen-ledger/types" ) +func (s serverImpl) validateBlsMember(ctx types.Context, mem group.Member) error { + addr, err := sdk.AccAddressFromBech32(mem.Address) + if err!= nil { + return err + } + acc := s.accKeeper.GetAccount(ctx.Context, addr) + if acc == nil { + return fmt.Errorf("account %s does not exist", mem.Address) + } + + pk := acc.GetPubKey() + if pk == nil { + return fmt.Errorf("account public key not set yet") + } + + if pk.Type() != bls12381.KeyType { + return fmt.Errorf("member account %s is not a bls account", mem.Address) + } + + if !acc.GetPopValid() { + return fmt.Errorf("member account %s hasn't validated pop for public key", mem.Address) + } + + return nil +} + + func (s serverImpl) CreateGroup(ctx types.Context, req *group.MsgCreateGroupRequest) (*group.MsgCreateGroupResponse, error) { metadata := req.Metadata members := group.Members{Members: req.Members} @@ -31,6 +59,12 @@ func (s serverImpl) CreateGroup(ctx types.Context, req *group.MsgCreateGroupRequ return nil, err } + for _, mem := range members.Members { + if err := s.validateBlsMember(ctx, mem); err!=nil { + return nil, err + } + } + totalWeight := apd.New(0, 0) for i := range members.Members { m := members.Members[i] @@ -94,6 +128,13 @@ func (s serverImpl) UpdateGroupMembers(ctx types.Context, req *group.MsgUpdateGr if err != nil { return err } + + for _, mem := range req.MemberUpdates { + if err := s.validateBlsMember(ctx, mem); err!=nil { + return err + } + } + for i := range req.MemberUpdates { if err := assertMetadataLength(req.MemberUpdates[i].Metadata, "group member metadata"); err != nil { return err From 5423934eec53842352072fec5a7543e144db02a7 Mon Sep 17 00:00:00 2001 From: kitty Date: Wed, 4 Aug 2021 16:39:01 +0100 Subject: [PATCH 17/34] fix bug in setting pop --- crypto/keys/bls12381/bls12381.go | 6 +++--- x/auth/ante/sigverify.go | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crypto/keys/bls12381/bls12381.go b/crypto/keys/bls12381/bls12381.go index 7aa9ffb98c..fc4d02d7ae 100644 --- a/crypto/keys/bls12381/bls12381.go +++ b/crypto/keys/bls12381/bls12381.go @@ -24,7 +24,7 @@ const ( // SignatureSize is the size of a bls signature. Namely the size of a compressed // G2 point. SignatureSize = 96 - keyType = "bls12381" + KeyType = "bls12381" SeedSize = 32 ) @@ -76,7 +76,7 @@ func (privKey *PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool { } func (privKey *PrivKey) Type() string { - return keyType + return KeyType } // MarshalAmino overrides Amino binary marshalling. @@ -191,7 +191,7 @@ func (pubKey *PubKey) String() string { } func (pubKey *PubKey) Type() string { - return keyType + return KeyType } func (pubKey *PubKey) Equals(other cryptotypes.PubKey) bool { diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 84de7d391c..9e10e57470 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/hex" "fmt" - "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" @@ -314,8 +313,11 @@ func (spvd SetPopValidDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate switch pk.(type) { case *bls12381.PubKey, *secp256k1.PubKey, *ed25519.PubKey: - if err := acc.SetPopValid(true); err != nil { - return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPop, err.Error()) + if !acc.GetPopValid() { + if err := acc.SetPopValid(true); err != nil { + return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPop, err.Error()) + } + spvd.ak.SetAccount(ctx, acc) } } } From eea0283f24d0b2b96643ce72fd564b0ec5c79ca3 Mon Sep 17 00:00:00 2001 From: kitty Date: Fri, 13 Aug 2021 14:37:24 +0100 Subject: [PATCH 18/34] make msg uniqueness checking optional --- crypto/keys/bls12381/multisig.go | 10 ++++++---- crypto/keys/bls12381/multisig_test.go | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crypto/keys/bls12381/multisig.go b/crypto/keys/bls12381/multisig.go index 18e499e390..d887951fce 100644 --- a/crypto/keys/bls12381/multisig.go +++ b/crypto/keys/bls12381/multisig.go @@ -47,7 +47,7 @@ func AggregateSignature(sigs [][]byte) ([]byte, error) { // VerifyMultiSignature assumes public key is already validated func VerifyMultiSignature(msg []byte, sig []byte, pks []*PubKey) error { - return VerifyAggregateSignature([][]byte{msg}, sig, [][]*PubKey{pks}) + return VerifyAggregateSignature([][]byte{msg}, false, sig, [][]*PubKey{pks}) } func Unique(msgs [][]byte) bool { @@ -65,7 +65,7 @@ func Unique(msgs [][]byte) bool { return true } -func VerifyAggregateSignature(msgs [][]byte, sig []byte, pkss [][]*PubKey) error { +func VerifyAggregateSignature(msgs [][]byte, msgCheck bool, sig []byte, pkss [][]*PubKey) error { n := len(msgs) if n == 0 { return fmt.Errorf("messages cannot be empty") @@ -75,8 +75,10 @@ func VerifyAggregateSignature(msgs [][]byte, sig []byte, pkss [][]*PubKey) error return fmt.Errorf("the number of messages and public key sets must match") } - if !Unique(msgs) { - return fmt.Errorf("messages must be pairwise distinct") + if msgCheck { + if !Unique(msgs) { + return fmt.Errorf("messages must be pairwise distinct") + } } apks := make([]*blst.P1Affine, len(pkss)) diff --git a/crypto/keys/bls12381/multisig_test.go b/crypto/keys/bls12381/multisig_test.go index c0024f859b..23c9e2343a 100644 --- a/crypto/keys/bls12381/multisig_test.go +++ b/crypto/keys/bls12381/multisig_test.go @@ -55,7 +55,7 @@ func TestBlsAggSig(t *testing.T) { aggSig, err := bls.AggregateSignature(sigs) require.Nil(t, err) - assert.Nil(t, bls.VerifyAggregateSignature(msgs, aggSig, pks)) + assert.Nil(t, bls.VerifyAggregateSignature(msgs, true, aggSig, pks)) } @@ -113,7 +113,7 @@ func benchmarkBlsVerifyAgg(total int, b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { - bls.VerifyAggregateSignature(msgs, aggSig, pks) + bls.VerifyAggregateSignature(msgs, false, aggSig, pks) } } From f7b0ddd11de27ed0e97557559f0aceb923c287a1 Mon Sep 17 00:00:00 2001 From: kitty Date: Fri, 13 Aug 2021 14:39:17 +0100 Subject: [PATCH 19/34] add bls basic/aggregate vote --- proto/regen/group/v1alpha1/tx.proto | 69 +- proto/regen/group/v1alpha1/types.proto | 5 +- x/group/client/tx.go | 272 ++++ x/group/client/util.go | 40 + x/group/codec.go | 4 + x/group/msgs.go | 171 ++- x/group/server/handler.go | 6 + x/group/server/msg_server.go | 149 +++ x/group/tx.pb.go | 1585 +++++++++++++++++++++--- x/group/tx_cosmos.pb.go | 51 + x/group/types.pb.go | 205 ++- 11 files changed, 2245 insertions(+), 312 deletions(-) diff --git a/proto/regen/group/v1alpha1/tx.proto b/proto/regen/group/v1alpha1/tx.proto index 453ea72134..9065746afa 100644 --- a/proto/regen/group/v1alpha1/tx.proto +++ b/proto/regen/group/v1alpha1/tx.proto @@ -5,8 +5,10 @@ package regen.group.v1alpha1; option go_package = "github.com/cosmos/cosmos-sdk/x/group"; import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; +//import "cosmos_proto/cosmos.proto"; +import "cosmos.proto"; import "google/protobuf/any.proto"; +import "google/protobuf/timestamp.proto"; import "regen/group/v1alpha1/types.proto"; // Msg is the regen.group.v1alpha1 Msg service. @@ -42,6 +44,9 @@ service Msg { // Vote allows a voter to vote on a proposal. rpc Vote(MsgVoteRequest) returns (MsgVoteResponse); + // VoteAgg allows a sender to submit a set of votes + rpc VoteAgg(MsgVoteAggRequest) returns (MsgVoteAggResponse); + // Exec executes a proposal. rpc Exec(MsgExecRequest) returns (MsgExecResponse); } @@ -244,6 +249,66 @@ message MsgVoteRequest { // MsgVoteResponse is the Msg/Vote response type. message MsgVoteResponse { } + +// MsgVoteRequest is the Msg/Vote request type. +message MsgVoteBasicRequest { + + // proposal is the unique ID of the proposal. + uint64 proposal_id = 1; + + // choice is the voter's choice on the proposal. + Choice choice = 2; + + // timeout is the unique timestamp before which all the basic votes need to aggregated and submitted. + google.protobuf.Timestamp timeout = 3 [(gogoproto.nullable) = false]; +} + +// MsgVoteResponse is the basic vote that can be aggregated together +message MsgVoteBasicResponse { + // proposal is the unique ID of the proposal. + uint64 proposal_id = 1; + + // choice is the voter's choice on the proposal. + Choice choice = 2; + + // timeout is the unique timestamp before which the aggregated vote needs to submitted. + google.protobuf.Timestamp timeout = 3 [(gogoproto.nullable) = false]; + + // voter is the account address of the voter. + string voter = 4; + + // pub_key is the voter's public key + google.protobuf.Any pub_key = 5 + [(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""]; + + // sig is the individual signature which will be aggregated with other signatures + bytes sig = 6; +} + +// MsgVoteRequest is the Msg/Vote request type. +message MsgVoteAggRequest { + // sender is the person who submits the votes + string sender = 1; + + // proposal is the unique ID of the proposal. + uint64 proposal_id = 2; + + // votes are the list of voters' choices on the proposal. + repeated Choice votes = 3; + + // timeout is the unique timestamp before which all the basic votes need to aggregated and submitted. + google.protobuf.Timestamp timeout = 4 [(gogoproto.nullable) = false]; + + // agg_sig is the bls aggregated signature for all the votes + bytes agg_sig = 5; + + // metadata is any arbitrary metadata to attached to the vote. + bytes metadata = 6; +} + +// MsgVoteResponse is the Msg/Vote response type. +message MsgVoteAggResponse { } + // MsgExecRequest is the Msg/Exec request type. message MsgExecRequest { @@ -256,3 +321,5 @@ message MsgExecRequest { // MsgExecResponse is the Msg/Exec request type. message MsgExecResponse { } + + diff --git a/proto/regen/group/v1alpha1/types.proto b/proto/regen/group/v1alpha1/types.proto index 8c8469ad28..9101fcaeb6 100644 --- a/proto/regen/group/v1alpha1/types.proto +++ b/proto/regen/group/v1alpha1/types.proto @@ -7,7 +7,8 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/group"; import "gogoproto/gogo.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; -import "cosmos_proto/cosmos.proto"; +//import "cosmos_proto/cosmos.proto"; +import "cosmos.proto"; import "google/protobuf/any.proto"; // Member represents a group member with an account address, @@ -265,4 +266,4 @@ message Vote { // submitted_at is the timestamp when the vote was submitted. google.protobuf.Timestamp submitted_at = 5 [(gogoproto.nullable) = false]; -} +} \ No newline at end of file diff --git a/x/group/client/tx.go b/x/group/client/tx.go index 487772dffd..633222ec25 100644 --- a/x/group/client/tx.go +++ b/x/group/client/tx.go @@ -1,8 +1,15 @@ package client import ( + "bytes" "encoding/base64" "fmt" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + + "github.com/gogo/protobuf/types" + tmcli "github.com/tendermint/tendermint/libs/cli" "strconv" "strings" @@ -16,6 +23,7 @@ import ( "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/x/group" + gogotypes "github.com/gogo/protobuf/types" ) const flagMembers = "members" @@ -42,6 +50,9 @@ func TxCmd(name string) *cobra.Command { MsgCreateProposalCmd(), MsgVoteCmd(), MsgExecCmd(), + MsgVoteAggCmd(), + GetVoteBasicCmd(), + GetVerifyVoteBasicCmd(), ) return txCmd @@ -639,3 +650,264 @@ func MsgExecCmd() *cobra.Command { return cmd } + +func MsgVoteAggCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "vote-agg [sender] [propsal_id] [timeout] [group-members-json-file] [[vote-json-file]...]", + Short: "Aggregate signatures of basic votes into aggregated signature and submit the combined votes", + Long: `Aggregate signatures of basic votes into aggregated signature and submit the combined votes. + +Parameters: + sender: sender's account address + proposal-id: unique ID of the proposal + timeout: UTC time for the submission deadline of the aggregated vote, e.g., 2021-08-15T12:00:00Z + group-members-json-file: path to json file that contains group members + vote-json-file: path to json file that contains a basic vote with a verified signature +`, + Args: cobra.MinimumNArgs(5), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + proposalID, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } + + timeString := fmt.Sprintf("\"%s\"", args[2]) + var timeout types.Timestamp + err = clientCtx.JSONMarshaler.UnmarshalJSON([]byte(timeString), &timeout) + if err != nil { + return err + } + timeNow := gogotypes.TimestampNow() + if timeout.Compare(timeNow) <= 0 { + return fmt.Errorf("deadline for submitting the vote has passed") + } + + groupMembers, err := parseGroupMembers(clientCtx, args[3]) + if err != nil { + return err + } + for _, mem := range groupMembers { + if err = mem.ValidateBasic(); err != nil { + return err + } + } + + index := make(map[string]int, len(groupMembers)) + for i, mem := range groupMembers { + addr := mem.Member.Address + if _, exists := index[addr]; exists { + return fmt.Errorf("duplicate address: %s", addr) + } + index[addr] = i + } + + votes := make([]group.Choice, len(groupMembers)) + for i := range votes { + votes[i] = group.Choice_CHOICE_UNSPECIFIED + } + + var sigs [][]byte + for i := 4; i < len(args); i++ { + vote, err := parseVoteBasic(clientCtx, args[i]) + if err != nil { + return err + } + + if vote.ProposalId != proposalID || !vote.Timeout.Equal(timeout) { + return fmt.Errorf("invalid vote from %s: expected proposal id %d and timeout %s", vote.Voter, proposalID, timeout.String()) + } + + memIndex, ok := index[vote.Voter] + if !ok { + return fmt.Errorf("invalid voter") + } + + votes[memIndex] = vote.Choice + sigs = append(sigs, vote.Sig) + } + + sigma, err := bls12381.AggregateSignature(sigs) + if err != nil { + return err + } + + msg := &group.MsgVoteAggRequest{ + Sender: args[0], + ProposalId: proposalID, + Votes: votes, + Timeout: timeout, + AggSig: sigma, + Metadata: nil, + } + + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + + +// GetVoteBasicCmd creates a CLI command for Msg/VoteBasic. +func GetVoteBasicCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "vote-basic [voter] [proposal-id] [choice] [timeout]", + Short: "Vote on a proposal", + Long: `Vote on a proposal and the vote will be aggregated with other votes. + +Parameters: + voter: voter account addresses. + proposal-id: unique ID of the proposal + choice: choice of the voter(s) + CHOICE_UNSPECIFIED: no-op + CHOICE_NO: no + CHOICE_YES: yes + CHOICE_ABSTAIN: abstain + CHOICE_VETO: veto + timeout: UTC time for the submission deadline of the vote, e.g., 2021-08-15T12:00:00Z +`, + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + proposalID, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } + + choice, err := group.ChoiceFromString(args[2]) + if err != nil { + return err + } + + timeString := fmt.Sprintf("\"%s\"", args[3]) + var timeout types.Timestamp + err = clientCtx.JSONMarshaler.UnmarshalJSON([]byte(timeString), &timeout) + if err != nil { + return err + } + + timeNow := gogotypes.TimestampNow() + if timeout.Compare(timeNow) <= 0 { + return fmt.Errorf("deadline for submitting the vote has passed") + } + + msg := &group.MsgVoteBasicRequest{ + ProposalId: proposalID, + Choice: choice, + Timeout: timeout, + } + + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + bytesToSign := msg.GetSignBytes() + sigBytes, pubKey, err := clientCtx.Keyring.Sign(clientCtx.GetFromName(), bytesToSign) + + pubKeyAny, err := codectypes.NewAnyWithValue(pubKey) + if err != nil { + return err + } + + vote := &group.MsgVoteBasicResponse{ + ProposalId: proposalID, + Choice: choice, + Timeout: timeout, + Voter: args[0], + PubKey: pubKeyAny, + Sig: sigBytes, + } + + return clientCtx.PrintProto(vote) + }, + } + + cmd.Flags().String(flags.FlagFrom, "", "Name or address of private key with which to sign") + cmd.Flags().StringP(tmcli.OutputFlag, "o", "text", "Output format (text|json)") + + return cmd +} + + + +// GetVerifyVoteBasicCmd creates a CLI command for aggregating basic votes. +func GetVerifyVoteBasicCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "verify-vote-basic [file]", + Short: "Verify signature for a basic vote", + Long: `Verify signature for a basic vote. + +Parameters: + file: a basic vote with signature +`, + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + vote, err := parseVoteBasic(clientCtx, args[0]) + if err != nil { + return err + } + + if err = vote.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + msgBytes := vote.GetSignBytes() + + pubKey, ok := vote.PubKey.GetCachedValue().(cryptotypes.PubKey) + if !ok { + return fmt.Errorf("failed to get public key") + } + + voterAddress, err := sdk.AccAddressFromBech32(vote.Voter) + if err != nil { + return err + } + if !bytes.Equal(pubKey.Address(), voterAddress) { + return fmt.Errorf("public key does not match the voter's address %s", vote.Voter) + } + + if !pubKey.VerifySignature(msgBytes, vote.Sig) { + return fmt.Errorf("verification failed") + } + + cmd.Println("Verification Successful!") + + return nil + }, + } + + return cmd +} + + + diff --git a/x/group/client/util.go b/x/group/client/util.go index 790d122193..95b89408c3 100644 --- a/x/group/client/util.go +++ b/x/group/client/util.go @@ -25,3 +25,43 @@ func parseMembers(clientCtx client.Context, membersFile string) ([]group.Member, return members.Members, nil } + +func parseGroupMembers(clientCtx client.Context, membersFile string) ([]*group.GroupMember, error) { + res := group.QueryGroupMembersResponse{} + + if membersFile == "" { + return res.Members, nil + } + + contents, err := ioutil.ReadFile(membersFile) + if err != nil { + return nil, err + } + err = clientCtx.JSONMarshaler.UnmarshalJSON(contents, &res) + if err != nil { + return nil, err + } + + return res.Members, nil +} + +func parseVoteBasic(clientCtx client.Context, voteFile string) (group.MsgVoteBasicResponse, error) { + vote := group.MsgVoteBasicResponse{} + + if voteFile == "" { + return vote, nil + } + + contents, err := ioutil.ReadFile(voteFile) + if err != nil { + return vote, err + } + + err = clientCtx.JSONMarshaler.UnmarshalJSON(contents, &vote) + if err != nil { + return vote, err + } + + return vote, nil + +} diff --git a/x/group/codec.go b/x/group/codec.go index 75be45627f..2471ad7cde 100644 --- a/x/group/codec.go +++ b/x/group/codec.go @@ -25,6 +25,8 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgCreateProposalRequest{}, "cosmos-sdk/group/MsgCreateProposal", nil) cdc.RegisterConcrete(&MsgVoteRequest{}, "cosmos-sdk/group/MsgVote", nil) cdc.RegisterConcrete(&MsgExecRequest{}, "cosmos-sdk/group/MsgExec", nil) + cdc.RegisterConcrete(&MsgVoteAggRequest{}, "cosmos-sdk/group/MsgVoteAgg", nil) + cdc.RegisterConcrete(&MsgVoteBasicResponse{}, "cosmos-sdk/group/MsgVoteBasic", nil) } func RegisterTypes(registry cdctypes.InterfaceRegistry) { @@ -40,6 +42,8 @@ func RegisterTypes(registry cdctypes.InterfaceRegistry) { &MsgCreateProposalRequest{}, &MsgVoteRequest{}, &MsgExecRequest{}, + &MsgVoteAggRequest{}, + &MsgVoteBasicResponse{}, ) msgservice.RegisterMsgServiceDesc(registry, &Msg_ServiceDesc) diff --git a/x/group/msgs.go b/x/group/msgs.go index 22bbbfc565..b80665b4f8 100644 --- a/x/group/msgs.go +++ b/x/group/msgs.go @@ -2,8 +2,9 @@ package group import ( "fmt" - "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" proto "github.com/gogo/protobuf/proto" @@ -22,6 +23,9 @@ const ( TypeMsgUpdateGroupAccountComment = "update_group_account_comment" TypeMsgCreateProposal = "create_proposal" TypeMsgVote = "vote" + TypeMsgVoteBasic = "vote_basic" + TypeMsgVoteBasicOutput = "vote_basic_output" + TypeMsgVoteAgg = "vote_agg" TypeMsgExec = "exec" ) @@ -642,6 +646,171 @@ func (m MsgVoteRequest) ValidateBasic() error { return nil } + +var _ sdk.Msg = &MsgVoteBasicRequest{} + +// Route Implements Msg. +func (m MsgVoteBasicRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (m MsgVoteBasicRequest) Type() string { return TypeMsgVoteBasic } + +// GetSignBytes Implements Msg. +func (m MsgVoteBasicRequest) GetSignBytes() []byte { + req := MsgVoteBasicRequest{ + ProposalId: m.ProposalId, + Choice: m.Choice, + Timeout: m.Timeout, + } + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&req)) +} + +// GetSigners returns the expected signers for a MsgVoteRequest. +func (m MsgVoteBasicRequest) GetSigners() []sdk.AccAddress { + panic("this message does not include signers") +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgVoteBasicRequest) ValidateBasic() error { + if m.ProposalId == 0 { + return sdkerrors.Wrap(ErrEmpty, "proposal") + } + if m.Choice == Choice_CHOICE_UNSPECIFIED { + return sdkerrors.Wrap(ErrEmpty, "choice") + } + if _, ok := Choice_name[int32(m.Choice)]; !ok { + return sdkerrors.Wrap(ErrInvalid, "choice") + } + return nil +} + + +var _ sdk.Msg = &MsgVoteBasicResponse{} +var _ types.UnpackInterfacesMessage = MsgVoteBasicResponse{} + +// Route Implements Msg. +func (m MsgVoteBasicResponse) Route() string { return RouterKey } + +// Type Implements Msg. +func (m MsgVoteBasicResponse) Type() string { return TypeMsgVoteBasicOutput } + +// GetSignBytes Implements Msg. +func (m MsgVoteBasicResponse) GetSignBytes() []byte { + res := MsgVoteBasicRequest{ + ProposalId: m.ProposalId, + Choice: m.Choice, + Timeout: m.Timeout, + } + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&res)) +} + +// GetSigners returns the expected signers for a MsgVoteRequest. +func (m MsgVoteBasicResponse) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Voter) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgVoteBasicResponse) ValidateBasic() error { + if m.ProposalId == 0 { + return sdkerrors.Wrap(ErrEmpty, "proposal") + } + if m.Choice == Choice_CHOICE_UNSPECIFIED { + return sdkerrors.Wrap(ErrEmpty, "choice") + } + if _, ok := Choice_name[int32(m.Choice)]; !ok { + return sdkerrors.Wrap(ErrInvalid, "choice") + } + return nil +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (m MsgVoteBasicResponse) UnpackInterfaces(unpacker types.AnyUnpacker) error { + var pk cryptotypes.PubKey + return unpacker.UnpackAny(m.PubKey, &pk) +} + + +var _ sdk.Msg = &MsgVoteAggRequest{} + +// Route Implements Msg. +func (m MsgVoteAggRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (m MsgVoteAggRequest) Type() string { return TypeMsgVoteAgg } + +// GetSignBytes Implements Msg. +func (m MsgVoteAggRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgVoteRequest. +func (m MsgVoteAggRequest) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgVoteAggRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return sdkerrors.Wrap(err, "sender") + } + if m.ProposalId == 0 { + return sdkerrors.Wrap(ErrEmpty, "proposal") + } + for _, c := range m.Votes { + if _, ok := Choice_name[int32(c)]; !ok { + return sdkerrors.Wrap(ErrInvalid, "choice") + } + } + return nil +} + + + +func (m MsgVoteAggRequest) VerifyAggSig(pks []cryptotypes.PubKey) error { + n := len(m.Votes) + if n <= 0 { + return fmt.Errorf("empty votes") + } + if len(pks) != n { + return fmt.Errorf("the length of public keys and votes must equal") + } + + pkeys := make([][]*bls12381.PubKey, len(Choice_name)) + for i, pk := range pks { + pkey, ok := pk.(*bls12381.PubKey) + if !ok { + return fmt.Errorf("only support bls12381 public key") + } + c := m.Votes[i] + pkeys[c] = append(pkeys[c], pkey) + } + + var votes [][]byte + var pubkeys [][]*bls12381.PubKey + + // skip the unspecified choice + for i := 1; i= len(choices) { + return nil, fmt.Errorf("wrong number of votes") + } + + acc := s.accKeeper.GetAccount(ctx.Context, memAddr) + if acc == nil { + return nil, fmt.Errorf("account does not exist") + } + pk := acc.GetPubKey() + if pk == nil { + return nil, fmt.Errorf("public key not set yet") + } + pubKeys = append(pubKeys, pk) + + meta := fmt.Sprintf("submitted through aggregated vote by %s", req.Sender) + if choices[i] != group.Choice_CHOICE_UNSPECIFIED { + vote := group.Vote{ + ProposalId: id, + Voter: mem.Member.Address, + Choice: choices[i], + Metadata: []byte(meta), + SubmittedAt: *blockTime, + } + votes = append(votes, vote) + weights = append(weights, mem.Member.Weight) + } + } + + if err = req.VerifyAggSig(pubKeys); err != nil { + return nil, err + } + + // Count and store votes. + for i := range votes { + if err := proposal.VoteState.Add(votes[i], weights[i]); err != nil { + return nil, sdkerrors.Wrap(err, "add new vote") + } + + // If the vote already exists, skip the new vote + if err := s.voteTable.Create(ctx, &votes[i]); err != nil { + if orm.ErrUniqueConstraint.Is(err) { + if err := proposal.VoteState.Sub(votes[i], weights[i]); err != nil { + return nil, sdkerrors.Wrap(err, "sub new vote") + } + continue + } + return nil, err + } + } + + if err := doTally(ctx, &proposal, electorate, accountInfo); err != nil { + return nil, err + } + + if err = s.proposalTable.Save(ctx, id, &proposal); err != nil { + return nil, err + } + + err = ctx.EventManager().EmitTypedEvent(&group.EventVote{ProposalId: id}) + if err != nil { + return nil, err + } + + return &group.MsgVoteAggResponse{}, nil +} + // Exec executes the messages from a proposal. func (s serverImpl) Exec(ctx types.Context, req *group.MsgExecRequest) (*group.MsgExecResponse, error) { id := req.ProposalId diff --git a/x/group/tx.pb.go b/x/group/tx.pb.go index 1265bec245..5e012a9d11 100644 --- a/x/group/tx.pb.go +++ b/x/group/tx.pb.go @@ -8,6 +8,7 @@ import ( types "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + types1 "github.com/gogo/protobuf/types" _ "github.com/regen-network/cosmos-proto" io "io" math "math" @@ -1022,6 +1023,289 @@ func (m *MsgVoteResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgVoteResponse proto.InternalMessageInfo +// MsgVoteRequest is the Msg/Vote request type. +type MsgVoteBasicRequest struct { + // proposal is the unique ID of the proposal. + ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` + // choice is the voter's choice on the proposal. + Choice Choice `protobuf:"varint,2,opt,name=choice,proto3,enum=regen.group.v1alpha1.Choice" json:"choice,omitempty"` + // timeout is the unique timestamp before which all the basic votes need to aggregated and submitted. + Timeout types1.Timestamp `protobuf:"bytes,3,opt,name=timeout,proto3" json:"timeout"` +} + +func (m *MsgVoteBasicRequest) Reset() { *m = MsgVoteBasicRequest{} } +func (m *MsgVoteBasicRequest) String() string { return proto.CompactTextString(m) } +func (*MsgVoteBasicRequest) ProtoMessage() {} +func (*MsgVoteBasicRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{20} +} +func (m *MsgVoteBasicRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVoteBasicRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVoteBasicRequest.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 *MsgVoteBasicRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVoteBasicRequest.Merge(m, src) +} +func (m *MsgVoteBasicRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgVoteBasicRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVoteBasicRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgVoteBasicRequest proto.InternalMessageInfo + +func (m *MsgVoteBasicRequest) GetProposalId() uint64 { + if m != nil { + return m.ProposalId + } + return 0 +} + +func (m *MsgVoteBasicRequest) GetChoice() Choice { + if m != nil { + return m.Choice + } + return Choice_CHOICE_UNSPECIFIED +} + +func (m *MsgVoteBasicRequest) GetTimeout() types1.Timestamp { + if m != nil { + return m.Timeout + } + return types1.Timestamp{} +} + +// MsgVoteResponse is the basic vote that can be aggregated together +type MsgVoteBasicResponse struct { + // proposal is the unique ID of the proposal. + ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` + // choice is the voter's choice on the proposal. + Choice Choice `protobuf:"varint,2,opt,name=choice,proto3,enum=regen.group.v1alpha1.Choice" json:"choice,omitempty"` + // timeout is the unique timestamp before which the aggregated vote needs to submitted. + Timeout types1.Timestamp `protobuf:"bytes,3,opt,name=timeout,proto3" json:"timeout"` + // voter is the account address of the voter. + Voter string `protobuf:"bytes,4,opt,name=voter,proto3" json:"voter,omitempty"` + // pub_key is the voter's public key + PubKey *types.Any `protobuf:"bytes,5,opt,name=pub_key,json=pubKey,proto3" json:"public_key,omitempty" yaml:"public_key"` + // sig is the individual signature which will be aggregated with other signatures + Sig []byte `protobuf:"bytes,6,opt,name=sig,proto3" json:"sig,omitempty"` +} + +func (m *MsgVoteBasicResponse) Reset() { *m = MsgVoteBasicResponse{} } +func (m *MsgVoteBasicResponse) String() string { return proto.CompactTextString(m) } +func (*MsgVoteBasicResponse) ProtoMessage() {} +func (*MsgVoteBasicResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{21} +} +func (m *MsgVoteBasicResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVoteBasicResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVoteBasicResponse.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 *MsgVoteBasicResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVoteBasicResponse.Merge(m, src) +} +func (m *MsgVoteBasicResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgVoteBasicResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVoteBasicResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgVoteBasicResponse proto.InternalMessageInfo + +func (m *MsgVoteBasicResponse) GetProposalId() uint64 { + if m != nil { + return m.ProposalId + } + return 0 +} + +func (m *MsgVoteBasicResponse) GetChoice() Choice { + if m != nil { + return m.Choice + } + return Choice_CHOICE_UNSPECIFIED +} + +func (m *MsgVoteBasicResponse) GetTimeout() types1.Timestamp { + if m != nil { + return m.Timeout + } + return types1.Timestamp{} +} + +func (m *MsgVoteBasicResponse) GetVoter() string { + if m != nil { + return m.Voter + } + return "" +} + +func (m *MsgVoteBasicResponse) GetPubKey() *types.Any { + if m != nil { + return m.PubKey + } + return nil +} + +func (m *MsgVoteBasicResponse) GetSig() []byte { + if m != nil { + return m.Sig + } + return nil +} + +// MsgVoteRequest is the Msg/Vote request type. +type MsgVoteAggRequest struct { + // sender is the person who submits the votes + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // proposal is the unique ID of the proposal. + ProposalId uint64 `protobuf:"varint,2,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` + // votes are the list of voters' choices on the proposal. + Votes []Choice `protobuf:"varint,3,rep,packed,name=votes,proto3,enum=regen.group.v1alpha1.Choice" json:"votes,omitempty"` + // timeout is the unique timestamp before which all the basic votes need to aggregated and submitted. + Timeout types1.Timestamp `protobuf:"bytes,4,opt,name=timeout,proto3" json:"timeout"` + // agg_sig is the bls aggregated signature for all the votes + AggSig []byte `protobuf:"bytes,5,opt,name=agg_sig,json=aggSig,proto3" json:"agg_sig,omitempty"` + // metadata is any arbitrary metadata to attached to the vote. + Metadata []byte `protobuf:"bytes,6,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (m *MsgVoteAggRequest) Reset() { *m = MsgVoteAggRequest{} } +func (m *MsgVoteAggRequest) String() string { return proto.CompactTextString(m) } +func (*MsgVoteAggRequest) ProtoMessage() {} +func (*MsgVoteAggRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{22} +} +func (m *MsgVoteAggRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVoteAggRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVoteAggRequest.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 *MsgVoteAggRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVoteAggRequest.Merge(m, src) +} +func (m *MsgVoteAggRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgVoteAggRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVoteAggRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgVoteAggRequest proto.InternalMessageInfo + +func (m *MsgVoteAggRequest) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgVoteAggRequest) GetProposalId() uint64 { + if m != nil { + return m.ProposalId + } + return 0 +} + +func (m *MsgVoteAggRequest) GetVotes() []Choice { + if m != nil { + return m.Votes + } + return nil +} + +func (m *MsgVoteAggRequest) GetTimeout() types1.Timestamp { + if m != nil { + return m.Timeout + } + return types1.Timestamp{} +} + +func (m *MsgVoteAggRequest) GetAggSig() []byte { + if m != nil { + return m.AggSig + } + return nil +} + +func (m *MsgVoteAggRequest) GetMetadata() []byte { + if m != nil { + return m.Metadata + } + return nil +} + +// MsgVoteResponse is the Msg/Vote response type. +type MsgVoteAggResponse struct { +} + +func (m *MsgVoteAggResponse) Reset() { *m = MsgVoteAggResponse{} } +func (m *MsgVoteAggResponse) String() string { return proto.CompactTextString(m) } +func (*MsgVoteAggResponse) ProtoMessage() {} +func (*MsgVoteAggResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{23} +} +func (m *MsgVoteAggResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVoteAggResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVoteAggResponse.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 *MsgVoteAggResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVoteAggResponse.Merge(m, src) +} +func (m *MsgVoteAggResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgVoteAggResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVoteAggResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgVoteAggResponse proto.InternalMessageInfo + // MsgExecRequest is the Msg/Exec request type. type MsgExecRequest struct { // proposal is the unique ID of the proposal. @@ -1034,7 +1318,7 @@ func (m *MsgExecRequest) Reset() { *m = MsgExecRequest{} } func (m *MsgExecRequest) String() string { return proto.CompactTextString(m) } func (*MsgExecRequest) ProtoMessage() {} func (*MsgExecRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b4673626e7797578, []int{20} + return fileDescriptor_b4673626e7797578, []int{24} } func (m *MsgExecRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1085,7 +1369,7 @@ func (m *MsgExecResponse) Reset() { *m = MsgExecResponse{} } func (m *MsgExecResponse) String() string { return proto.CompactTextString(m) } func (*MsgExecResponse) ProtoMessage() {} func (*MsgExecResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b4673626e7797578, []int{21} + return fileDescriptor_b4673626e7797578, []int{25} } func (m *MsgExecResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1135,6 +1419,10 @@ func init() { proto.RegisterType((*MsgCreateProposalResponse)(nil), "regen.group.v1alpha1.MsgCreateProposalResponse") proto.RegisterType((*MsgVoteRequest)(nil), "regen.group.v1alpha1.MsgVoteRequest") proto.RegisterType((*MsgVoteResponse)(nil), "regen.group.v1alpha1.MsgVoteResponse") + proto.RegisterType((*MsgVoteBasicRequest)(nil), "regen.group.v1alpha1.MsgVoteBasicRequest") + proto.RegisterType((*MsgVoteBasicResponse)(nil), "regen.group.v1alpha1.MsgVoteBasicResponse") + proto.RegisterType((*MsgVoteAggRequest)(nil), "regen.group.v1alpha1.MsgVoteAggRequest") + proto.RegisterType((*MsgVoteAggResponse)(nil), "regen.group.v1alpha1.MsgVoteAggResponse") proto.RegisterType((*MsgExecRequest)(nil), "regen.group.v1alpha1.MsgExecRequest") proto.RegisterType((*MsgExecResponse)(nil), "regen.group.v1alpha1.MsgExecResponse") } @@ -1142,66 +1430,80 @@ func init() { func init() { proto.RegisterFile("regen/group/v1alpha1/tx.proto", fileDescriptor_b4673626e7797578) } var fileDescriptor_b4673626e7797578 = []byte{ - // 936 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4f, 0x6f, 0xe3, 0x44, - 0x14, 0xcf, 0x34, 0xa6, 0x7f, 0x5e, 0x21, 0x0b, 0x43, 0x59, 0x5c, 0x6f, 0x9b, 0x06, 0xab, 0x2b, - 0x22, 0x96, 0xda, 0xb4, 0x5d, 0x09, 0x58, 0xf6, 0x40, 0xbb, 0xa0, 0x55, 0x0f, 0x91, 0x16, 0x23, - 0x38, 0x70, 0x89, 0x5c, 0x7b, 0x70, 0x0d, 0x89, 0xc7, 0xeb, 0x71, 0xb6, 0xcd, 0x01, 0x89, 0x1b, - 0x1c, 0x38, 0x70, 0xe1, 0x00, 0x07, 0xc4, 0x8d, 0x2f, 0x00, 0xdf, 0x80, 0xc3, 0x8a, 0x53, 0x6f, - 0x70, 0x42, 0xa8, 0xfd, 0x22, 0x28, 0x33, 0xe3, 0xc4, 0x49, 0x6c, 0xc7, 0x09, 0x70, 0xcb, 0xf3, - 0xbc, 0xf7, 0x9b, 0xdf, 0xfb, 0x33, 0xbf, 0xa7, 0xc0, 0x76, 0x44, 0x3c, 0x12, 0x98, 0x5e, 0x44, - 0x7b, 0xa1, 0xf9, 0x64, 0xdf, 0xee, 0x84, 0x67, 0xf6, 0xbe, 0x19, 0x5f, 0x18, 0x61, 0x44, 0x63, - 0x8a, 0x37, 0xf8, 0xb1, 0xc1, 0x8f, 0x8d, 0xe4, 0x58, 0xdb, 0xf0, 0xa8, 0x47, 0xb9, 0x83, 0x39, - 0xf8, 0x25, 0x7c, 0xb5, 0x4d, 0x87, 0xb2, 0x2e, 0x65, 0x6d, 0x71, 0x20, 0x8c, 0xe4, 0xc8, 0xa3, - 0xd4, 0xeb, 0x10, 0x93, 0x5b, 0xa7, 0xbd, 0x4f, 0x4d, 0x3b, 0xe8, 0xcb, 0xa3, 0x46, 0x36, 0x81, - 0x7e, 0x48, 0x64, 0xb0, 0xfe, 0x15, 0x82, 0x97, 0x5a, 0xcc, 0x7b, 0x10, 0x11, 0x3b, 0x26, 0x0f, - 0x07, 0x7e, 0x16, 0x79, 0xdc, 0x23, 0x2c, 0xc6, 0x1b, 0xf0, 0x8c, 0xed, 0x76, 0xfd, 0x40, 0x45, - 0x0d, 0xd4, 0x5c, 0xb3, 0x84, 0x81, 0xef, 0xc3, 0x4a, 0x97, 0x74, 0x4f, 0x49, 0xc4, 0xd4, 0xa5, - 0x46, 0xb5, 0xb9, 0x7e, 0xb0, 0x65, 0x64, 0x65, 0x61, 0xb4, 0xb8, 0xd3, 0xb1, 0xf2, 0xf4, 0xaf, - 0x9d, 0x8a, 0x95, 0x84, 0x60, 0x0d, 0x56, 0xbb, 0x24, 0xb6, 0x5d, 0x3b, 0xb6, 0xd5, 0x6a, 0x03, - 0x35, 0x9f, 0xb5, 0x86, 0xb6, 0x7e, 0x08, 0x37, 0x27, 0x89, 0xb0, 0x90, 0x06, 0x8c, 0xe0, 0x4d, - 0x58, 0xe5, 0xe8, 0x6d, 0xdf, 0xe5, 0x64, 0x14, 0x6b, 0x85, 0xdb, 0x27, 0xae, 0xfe, 0x03, 0x82, - 0xad, 0x16, 0xf3, 0x3e, 0x0a, 0xdd, 0x24, 0x4a, 0x5c, 0xcc, 0x8a, 0xb3, 0x48, 0x23, 0x2e, 0x8d, - 0x21, 0xe2, 0x13, 0xa8, 0x09, 0xb6, 0xed, 0x1e, 0x07, 0x65, 0x6a, 0xb5, 0x74, 0x9e, 0xcf, 0x89, - 0x48, 0xc1, 0x86, 0xe9, 0x3b, 0xb0, 0x9d, 0xc3, 0x4d, 0x24, 0xa6, 0x7f, 0x06, 0xda, 0xb8, 0xc3, - 0xd1, 0x80, 0xdd, 0xc2, 0xd4, 0x6f, 0xc1, 0x5a, 0x40, 0xce, 0xdb, 0x22, 0xa8, 0xca, 0x83, 0x56, - 0x03, 0x72, 0xce, 0x41, 0xf5, 0x6d, 0xb8, 0x95, 0x79, 0x97, 0xa4, 0xd2, 0x99, 0xe6, 0x2a, 0xfa, - 0xb2, 0x30, 0x9b, 0xa2, 0x5e, 0x37, 0xa0, 0x9e, 0x77, 0x9b, 0xe4, 0xf3, 0x9b, 0x68, 0x6c, 0x6a, - 0x1c, 0x8e, 0x1c, 0x87, 0xf6, 0x82, 0xf8, 0xff, 0xe0, 0x83, 0x3f, 0x80, 0x1b, 0x2e, 0x71, 0x7c, - 0xe6, 0xd3, 0xa0, 0x1d, 0xd2, 0x8e, 0xef, 0xf4, 0x55, 0xa5, 0x81, 0x9a, 0xeb, 0x07, 0x1b, 0x86, - 0x78, 0x5c, 0x46, 0xf2, 0xb8, 0x8c, 0xa3, 0xa0, 0x7f, 0x8c, 0x7f, 0xff, 0x65, 0xaf, 0xf6, 0x9e, - 0x0c, 0x78, 0xc4, 0xfd, 0xad, 0x9a, 0x3b, 0x66, 0xdf, 0x53, 0xbe, 0xfe, 0x69, 0xa7, 0xa2, 0xbf, - 0xcd, 0xcb, 0x9a, 0x95, 0x85, 0x9c, 0x6d, 0x15, 0x56, 0x6c, 0xd7, 0x8d, 0x08, 0x63, 0x32, 0x91, - 0xc4, 0xd4, 0x43, 0x78, 0x65, 0xa2, 0x61, 0x22, 0xb4, 0xc4, 0x8c, 0xa4, 0x40, 0x97, 0xc6, 0x40, - 0x8b, 0x47, 0x64, 0x17, 0xf4, 0xa2, 0x1b, 0x65, 0x67, 0x7e, 0x45, 0xf0, 0x5a, 0xa6, 0xdb, 0x44, - 0x41, 0x16, 0x64, 0x98, 0xd1, 0x8a, 0xea, 0x7f, 0xd2, 0x8a, 0x3d, 0xb8, 0x53, 0x8a, 0xb6, 0x4c, - 0x33, 0x82, 0xdd, 0x4c, 0xf7, 0x72, 0xef, 0x22, 0x3f, 0xbf, 0xa2, 0x67, 0xf1, 0x2a, 0xdc, 0x9e, - 0x71, 0xa7, 0x24, 0xf7, 0x23, 0x02, 0x75, 0x38, 0x57, 0x8f, 0x22, 0x1a, 0x52, 0x66, 0x77, 0x12, - 0x46, 0xb9, 0x23, 0x85, 0xb7, 0x60, 0x2d, 0xe4, 0xce, 0x89, 0x7c, 0xaf, 0x59, 0xa3, 0x0f, 0x85, - 0x0f, 0xa4, 0x09, 0x4a, 0x97, 0x79, 0x4c, 0x55, 0xb8, 0x16, 0x66, 0xb6, 0xc2, 0xe2, 0x1e, 0xb2, - 0xd8, 0xf7, 0x61, 0x33, 0x83, 0x9f, 0x9c, 0xf9, 0x1d, 0x58, 0x0f, 0xe5, 0xb7, 0x91, 0xa4, 0x43, - 0xf2, 0xe9, 0xc4, 0xd5, 0xbf, 0x47, 0x50, 0x6b, 0x31, 0xef, 0x63, 0x1a, 0x93, 0x24, 0xa9, 0x59, - 0x31, 0x83, 0x3e, 0x3c, 0xa1, 0x31, 0x89, 0x64, 0xbd, 0x85, 0x81, 0xef, 0xc2, 0xb2, 0x73, 0x46, - 0x7d, 0x87, 0xf0, 0x8c, 0x6a, 0x79, 0x2a, 0xfe, 0x80, 0xfb, 0x58, 0xd2, 0x77, 0xac, 0x12, 0xca, - 0x44, 0x8f, 0x5e, 0x80, 0x1b, 0x43, 0x6a, 0xb2, 0x1b, 0x27, 0x9c, 0xed, 0xfb, 0x17, 0xc4, 0x29, - 0xcd, 0xf6, 0x26, 0x2c, 0x33, 0xdf, 0x0b, 0x86, 0x74, 0xa5, 0x25, 0xd1, 0x05, 0x94, 0x40, 0x3f, - 0xf8, 0x03, 0xa0, 0xda, 0x62, 0x1e, 0x3e, 0x83, 0xf5, 0x94, 0x8e, 0xe0, 0x3b, 0x39, 0xfb, 0x28, - 0x6b, 0x97, 0x6b, 0xaf, 0x97, 0x73, 0x96, 0xfd, 0xf9, 0x02, 0xf0, 0xf4, 0xd2, 0xc2, 0x07, 0xb9, - 0x18, 0xb9, 0xdb, 0x57, 0x3b, 0x9c, 0x2b, 0x46, 0x5e, 0x7f, 0x0e, 0xcf, 0x4f, 0xae, 0x29, 0xfc, - 0x46, 0x19, 0xa0, 0xb4, 0x32, 0x6a, 0xfb, 0x73, 0x44, 0xc8, 0x8b, 0xbf, 0x44, 0xf0, 0x62, 0xc6, - 0x4e, 0xc2, 0x25, 0xb3, 0x18, 0xd3, 0x05, 0xed, 0xee, 0x7c, 0x41, 0xa3, 0xd2, 0x4f, 0x2f, 0x8b, - 0x82, 0xd2, 0xe7, 0xee, 0xc7, 0x82, 0xd2, 0x17, 0x6c, 0xa3, 0x6f, 0x10, 0xbc, 0x9c, 0xa3, 0xff, - 0xf8, 0xcd, 0x52, 0x05, 0x9d, 0xde, 0x51, 0xda, 0x5b, 0xf3, 0x07, 0x4a, 0x3a, 0x3f, 0x23, 0x68, - 0xcc, 0x12, 0x6c, 0xfc, 0xee, 0x1c, 0xf0, 0x99, 0x2b, 0x4a, 0x3b, 0xfa, 0x17, 0x08, 0x92, 0xe9, - 0x77, 0x08, 0xb4, 0x7c, 0xdd, 0xc6, 0xf7, 0xe6, 0xb8, 0x61, 0x72, 0x90, 0xde, 0x59, 0x28, 0x56, - 0xf2, 0x7a, 0x0c, 0xb5, 0x71, 0x11, 0xc6, 0xc6, 0x8c, 0xb9, 0x98, 0xd8, 0x26, 0x9a, 0x59, 0xda, - 0x5f, 0x5e, 0xf9, 0x21, 0x28, 0x03, 0x75, 0xc4, 0xbb, 0xb9, 0x81, 0x29, 0x5d, 0xd7, 0x6e, 0xcf, - 0xf0, 0x1a, 0x81, 0x0e, 0x44, 0xb1, 0x00, 0x34, 0x25, 0xbf, 0x05, 0xa0, 0x69, 0x65, 0x3d, 0x7e, - 0xf8, 0xf4, 0xaa, 0x8e, 0x2e, 0xaf, 0xea, 0xe8, 0xef, 0xab, 0x3a, 0xfa, 0xf6, 0xba, 0x5e, 0xb9, - 0xbc, 0xae, 0x57, 0xfe, 0xbc, 0xae, 0x57, 0x3e, 0xd9, 0xf3, 0xfc, 0xf8, 0xac, 0x77, 0x6a, 0x38, - 0xb4, 0x6b, 0x72, 0xa8, 0xbd, 0x80, 0xc4, 0xe7, 0x34, 0xfa, 0x5c, 0x5a, 0x1d, 0xe2, 0x7a, 0x24, - 0x32, 0x2f, 0xc4, 0x3f, 0xab, 0xd3, 0x65, 0xbe, 0x07, 0x0f, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, - 0xa9, 0x53, 0x7a, 0x00, 0xf0, 0x0d, 0x00, 0x00, + // 1154 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0xda, 0x8e, 0x9d, 0xbc, 0x14, 0xb7, 0x99, 0x9a, 0xd6, 0xd9, 0x26, 0xb6, 0x59, 0xa5, + 0xaa, 0x45, 0x1b, 0x9b, 0x24, 0x95, 0x80, 0x50, 0x21, 0x92, 0x82, 0x50, 0x84, 0x2c, 0x15, 0x17, + 0x38, 0xa0, 0x4a, 0xd6, 0xda, 0x3b, 0x4c, 0x96, 0x7a, 0x77, 0xb6, 0x9e, 0x75, 0x13, 0x1f, 0x90, + 0xb8, 0xc1, 0x81, 0x03, 0x17, 0x0e, 0x70, 0x40, 0xdc, 0xe0, 0xc6, 0x85, 0x7e, 0x03, 0x0e, 0x15, + 0xa7, 0x1e, 0x39, 0x45, 0x28, 0xb9, 0x71, 0x83, 0x4f, 0x80, 0x76, 0x66, 0x36, 0x5e, 0xdb, 0xbb, + 0xeb, 0x75, 0x80, 0x9e, 0x92, 0xb7, 0xf3, 0xde, 0x9b, 0xdf, 0xfb, 0x3b, 0x3f, 0x19, 0xd6, 0x7a, + 0x98, 0x60, 0xbb, 0x4e, 0x7a, 0xb4, 0xef, 0xd4, 0x1f, 0x6f, 0xea, 0x5d, 0xe7, 0x40, 0xdf, 0xac, + 0xbb, 0x47, 0x35, 0xa7, 0x47, 0x5d, 0x8a, 0x0a, 0xfc, 0xb8, 0xc6, 0x8f, 0x6b, 0xfe, 0xb1, 0x5a, + 0x20, 0x94, 0x50, 0xae, 0x50, 0xf7, 0xfe, 0x13, 0xba, 0xea, 0x85, 0x0e, 0x65, 0x16, 0x65, 0x52, + 0x5a, 0x21, 0x94, 0x92, 0x2e, 0xae, 0x73, 0xa9, 0xdd, 0xff, 0xa4, 0xae, 0xdb, 0x03, 0x79, 0x54, + 0x1e, 0x3f, 0x72, 0x4d, 0x0b, 0x33, 0x57, 0xb7, 0x1c, 0xa9, 0x50, 0x09, 0x07, 0x35, 0x70, 0xb0, + 0xf4, 0xae, 0x7d, 0xa1, 0xc0, 0x8b, 0x0d, 0x46, 0xee, 0xf6, 0xb0, 0xee, 0xe2, 0x77, 0x3d, 0xbd, + 0x26, 0x7e, 0xd4, 0xc7, 0xcc, 0x45, 0x05, 0x98, 0xd7, 0x0d, 0xcb, 0xb4, 0x8b, 0x4a, 0x45, 0xa9, + 0x2e, 0x36, 0x85, 0x80, 0xee, 0x40, 0xce, 0xc2, 0x56, 0x1b, 0xf7, 0x58, 0x31, 0x55, 0x49, 0x57, + 0x97, 0xb6, 0x56, 0x6b, 0x61, 0x91, 0xd5, 0x1a, 0x5c, 0x69, 0x2f, 0xf3, 0xf4, 0xb8, 0x3c, 0xd7, + 0xf4, 0x4d, 0x90, 0x0a, 0x0b, 0x16, 0x76, 0x75, 0x43, 0x77, 0xf5, 0x62, 0xba, 0xa2, 0x54, 0x2f, + 0x34, 0xcf, 0x64, 0x6d, 0x1b, 0xae, 0x8c, 0x03, 0x61, 0x0e, 0xb5, 0x19, 0x46, 0x2b, 0xb0, 0xc0, + 0xbd, 0xb7, 0x4c, 0x83, 0x83, 0xc9, 0x34, 0x73, 0x5c, 0xde, 0x37, 0xb4, 0xef, 0x14, 0x58, 0x6d, + 0x30, 0xf2, 0xa1, 0x63, 0xf8, 0x56, 0xe2, 0x62, 0x16, 0x1f, 0x45, 0xd0, 0x63, 0x6a, 0xc4, 0x23, + 0xda, 0x87, 0xbc, 0x40, 0xdb, 0xea, 0x73, 0xa7, 0xac, 0x98, 0x4e, 0x1c, 0xe7, 0x0b, 0xc2, 0x52, + 0xa0, 0x61, 0x5a, 0x19, 0xd6, 0x22, 0xb0, 0x89, 0xc0, 0xb4, 0x4f, 0x41, 0x1d, 0x55, 0xd8, 0xf5, + 0xd0, 0x9d, 0x1b, 0xfa, 0x35, 0x58, 0xb4, 0xf1, 0x61, 0x4b, 0x18, 0xa5, 0xb9, 0xd1, 0x82, 0x8d, + 0x0f, 0xb9, 0x53, 0x6d, 0x0d, 0xae, 0x85, 0xde, 0x25, 0xa1, 0x74, 0x27, 0xb1, 0x8a, 0xba, 0x9c, + 0x1b, 0x4d, 0x5c, 0xad, 0x2b, 0x50, 0x8a, 0xba, 0x4d, 0xe2, 0xf9, 0x55, 0x14, 0x36, 0xd0, 0x0e, + 0xbb, 0x9d, 0x0e, 0xed, 0xdb, 0xee, 0xff, 0x81, 0x07, 0xbd, 0x0f, 0x17, 0x0d, 0xdc, 0x31, 0x99, + 0x49, 0xed, 0x96, 0x43, 0xbb, 0x66, 0x67, 0x50, 0xcc, 0x54, 0x94, 0xea, 0xd2, 0x56, 0xa1, 0x26, + 0x46, 0xac, 0xe6, 0x8f, 0x58, 0x6d, 0xd7, 0x1e, 0xec, 0xa1, 0xdf, 0x7e, 0xd9, 0xc8, 0xbf, 0x2d, + 0x0d, 0xee, 0x71, 0xfd, 0x66, 0xde, 0x18, 0x91, 0x77, 0x32, 0x5f, 0xfe, 0x50, 0x9e, 0xd3, 0x5e, + 0xe7, 0x69, 0x0d, 0x8b, 0x42, 0xf6, 0x76, 0x11, 0x72, 0xba, 0x61, 0xf4, 0x30, 0x63, 0x32, 0x10, + 0x5f, 0xd4, 0x1c, 0x78, 0x69, 0xac, 0x60, 0xc2, 0x34, 0x41, 0x8f, 0x04, 0x9c, 0xa6, 0x46, 0x9c, + 0xc6, 0xb7, 0xc8, 0x3a, 0x68, 0x71, 0x37, 0xca, 0xca, 0x3c, 0x51, 0xe0, 0xe5, 0x50, 0xb5, 0xb1, + 0x84, 0x9c, 0x13, 0x61, 0x48, 0x29, 0xd2, 0xff, 0x49, 0x29, 0x36, 0xe0, 0x66, 0x22, 0xd8, 0x32, + 0xcc, 0x1e, 0xac, 0x87, 0xaa, 0x27, 0x9b, 0x8b, 0xe8, 0xf8, 0xe2, 0xc6, 0xe2, 0x06, 0x5c, 0x9f, + 0x72, 0xa7, 0x04, 0xf7, 0xbd, 0x02, 0xc5, 0xb3, 0xbe, 0xba, 0xd7, 0xa3, 0x0e, 0x65, 0x7a, 0xd7, + 0x47, 0x14, 0xd9, 0x52, 0x68, 0x15, 0x16, 0x1d, 0xae, 0xec, 0xaf, 0xef, 0xc5, 0xe6, 0xf0, 0x43, + 0xec, 0x80, 0x54, 0x21, 0x63, 0x31, 0xc2, 0x8a, 0x19, 0xbe, 0x0b, 0x43, 0x4b, 0xd1, 0xe4, 0x1a, + 0x32, 0xd9, 0x77, 0x60, 0x25, 0x04, 0x9f, 0xec, 0xf9, 0x32, 0x2c, 0x39, 0xf2, 0xdb, 0x70, 0xa5, + 0x83, 0xff, 0x69, 0xdf, 0xd0, 0xbe, 0x55, 0x20, 0xdf, 0x60, 0xe4, 0x23, 0xea, 0x62, 0x3f, 0xa8, + 0x69, 0x36, 0x5e, 0x1d, 0x1e, 0x53, 0x17, 0xf7, 0x64, 0xbe, 0x85, 0x80, 0x6e, 0x43, 0xb6, 0x73, + 0x40, 0xcd, 0x0e, 0xe6, 0x11, 0xe5, 0xa3, 0xb6, 0xf8, 0x5d, 0xae, 0xd3, 0x94, 0xba, 0x23, 0x99, + 0xc8, 0x8c, 0xd5, 0x68, 0x19, 0x2e, 0x9e, 0x41, 0x93, 0xd5, 0xf8, 0x49, 0x81, 0xcb, 0xf2, 0xdb, + 0x9e, 0xce, 0xcc, 0x4e, 0x62, 0xcc, 0x43, 0x74, 0xa9, 0x19, 0xd0, 0xed, 0x40, 0xce, 0x7b, 0xe7, + 0x69, 0xdf, 0x95, 0x93, 0xa1, 0x4e, 0x94, 0xe3, 0x03, 0x9f, 0x07, 0xf8, 0x0f, 0xb0, 0x34, 0xd0, + 0x7e, 0x4e, 0x41, 0x61, 0x14, 0x6a, 0xc2, 0x9a, 0x3c, 0x7f, 0xac, 0xc3, 0x8a, 0x66, 0x82, 0x15, + 0x7d, 0x00, 0x39, 0xa7, 0xdf, 0x6e, 0x3d, 0xc4, 0x83, 0xe2, 0x7c, 0xcc, 0x5e, 0xd8, 0xf8, 0xf3, + 0xb8, 0x5c, 0x70, 0xfa, 0xed, 0xae, 0xd9, 0xf1, 0x74, 0x6f, 0x51, 0xcb, 0x74, 0xb1, 0xe5, 0xb8, + 0x83, 0xbf, 0x8f, 0xcb, 0xcb, 0x03, 0xdd, 0xea, 0xee, 0x68, 0xc3, 0x53, 0xad, 0x99, 0x75, 0xfa, + 0xed, 0xf7, 0xf0, 0x00, 0x5d, 0x82, 0x34, 0x33, 0x49, 0x31, 0xcb, 0x8b, 0xee, 0xfd, 0xab, 0xfd, + 0xa5, 0xc0, 0xb2, 0xcc, 0xd8, 0x2e, 0x21, 0x7e, 0x69, 0xaf, 0x40, 0x96, 0x61, 0xdb, 0xc0, 0x3d, + 0x39, 0x62, 0x52, 0x1a, 0x4f, 0x63, 0x6a, 0x22, 0x8d, 0x5b, 0x22, 0x28, 0xc1, 0x2a, 0xa6, 0x65, + 0x51, 0xa8, 0x06, 0x93, 0x98, 0x99, 0x35, 0x89, 0x57, 0x21, 0xa7, 0x13, 0xd2, 0xf2, 0x82, 0x9a, + 0xe7, 0x41, 0x65, 0x75, 0x42, 0xee, 0x9b, 0x64, 0xa4, 0xc7, 0xb3, 0x63, 0x3d, 0x5e, 0x00, 0x14, + 0x0c, 0x59, 0xb6, 0xf9, 0x3e, 0x1f, 0xca, 0x77, 0x8e, 0x70, 0xf2, 0x06, 0xf7, 0xd2, 0x64, 0x12, + 0xfb, 0x6c, 0x2a, 0xa5, 0x24, 0x87, 0x48, 0xb8, 0x12, 0xde, 0xb7, 0x9e, 0x2c, 0x41, 0xba, 0xc1, + 0x08, 0x3a, 0x80, 0xa5, 0xc0, 0x73, 0x89, 0x6e, 0x46, 0xd0, 0xae, 0x30, 0xca, 0xaa, 0xde, 0x4a, + 0xa6, 0x2c, 0x5b, 0xfe, 0x33, 0x40, 0x93, 0xdc, 0x0c, 0x6d, 0x45, 0xfa, 0x88, 0x24, 0x99, 0xea, + 0xf6, 0x4c, 0x36, 0xf2, 0xfa, 0x43, 0xb8, 0x34, 0xce, 0xc6, 0xd0, 0x2b, 0x49, 0x1c, 0x05, 0x09, + 0x80, 0xba, 0x39, 0x83, 0x85, 0xbc, 0xf8, 0x73, 0x05, 0x2e, 0x87, 0x50, 0x2f, 0x94, 0x30, 0x8a, + 0x91, 0xe7, 0x4f, 0xbd, 0x3d, 0x9b, 0xd1, 0x30, 0xf5, 0x93, 0x9c, 0x28, 0x26, 0xf5, 0x91, 0x34, + 0x30, 0x26, 0xf5, 0x31, 0xa4, 0xeb, 0x2b, 0x05, 0xae, 0x46, 0xd0, 0x1c, 0xf4, 0x6a, 0xa2, 0x84, + 0x4e, 0x52, 0x31, 0xf5, 0xb5, 0xd9, 0x0d, 0x25, 0x9c, 0x1f, 0x15, 0xa8, 0x4c, 0xe3, 0x25, 0xe8, + 0xad, 0x19, 0xdc, 0x87, 0x32, 0x31, 0x75, 0xf7, 0x5f, 0x78, 0x90, 0x48, 0xbf, 0x51, 0x40, 0x8d, + 0xa6, 0x27, 0x68, 0x67, 0x86, 0x1b, 0xc6, 0x1b, 0xe9, 0x8d, 0x73, 0xd9, 0x4a, 0x5c, 0x8f, 0x20, + 0x3f, 0xca, 0x35, 0x50, 0x6d, 0x4a, 0x5f, 0x8c, 0x91, 0x26, 0xb5, 0x9e, 0x58, 0x5f, 0x5e, 0x79, + 0x1f, 0x32, 0xde, 0x82, 0x44, 0xeb, 0x91, 0x86, 0x01, 0xfa, 0xa2, 0x5e, 0x9f, 0xa2, 0x25, 0x9d, + 0x3e, 0x80, 0x9c, 0xdc, 0xba, 0xe8, 0x46, 0xac, 0xc5, 0xf0, 0x29, 0x52, 0xab, 0xd3, 0x15, 0x87, + 0x90, 0xbd, 0x95, 0x1b, 0x03, 0x39, 0xb0, 0xdc, 0x63, 0x20, 0x07, 0xf7, 0xf6, 0xde, 0x9b, 0x4f, + 0x4f, 0x4a, 0xca, 0xb3, 0x93, 0x92, 0xf2, 0xc7, 0x49, 0x49, 0xf9, 0xfa, 0xb4, 0x34, 0xf7, 0xec, + 0xb4, 0x34, 0xf7, 0xfb, 0x69, 0x69, 0xee, 0xe3, 0x75, 0x62, 0xba, 0x07, 0xfd, 0x76, 0xad, 0x43, + 0xad, 0xba, 0xf8, 0x45, 0x43, 0xfe, 0xd9, 0x60, 0xc6, 0xc3, 0xfa, 0x91, 0xf8, 0x55, 0xa2, 0x9d, + 0xe5, 0x6f, 0xd8, 0xf6, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0e, 0xb7, 0xed, 0xa1, 0x40, 0x11, + 0x00, 0x00, } func (m *MsgCreateGroupRequest) Marshal() (dAtA []byte, err error) { @@ -1933,7 +2235,7 @@ func (m *MsgVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgExecRequest) Marshal() (dAtA []byte, err error) { +func (m *MsgVoteBasicRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1943,22 +2245,30 @@ func (m *MsgExecRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgExecRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgVoteBasicRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgExecRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgVoteBasicRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + { + size, err := m.Timeout.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.Choice != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Choice)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } if m.ProposalId != 0 { i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) @@ -1968,7 +2278,7 @@ func (m *MsgExecRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgExecResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgVoteBasicResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1978,56 +2288,260 @@ func (m *MsgExecResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgExecResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgVoteBasicResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgExecResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgVoteBasicResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - return len(dAtA) - i, nil -} - -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ + if len(m.Sig) > 0 { + i -= len(m.Sig) + copy(dAtA[i:], m.Sig) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sig))) + i-- + dAtA[i] = 0x32 } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgCreateGroupRequest) Size() (n int) { - if m == nil { - return 0 + if m.PubKey != nil { + { + size, err := m.PubKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a } - var l int - _ = l - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x22 } - if len(m.Members) > 0 { - for _, e := range m.Members { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) + { + size, err := m.Timeout.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - l = len(m.Metadata) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + i-- + dAtA[i] = 0x1a + if m.Choice != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Choice)) + i-- + dAtA[i] = 0x10 } - return n + if m.ProposalId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } -func (m *MsgCreateGroupResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgVoteAggRequest) 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 *MsgVoteAggRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVoteAggRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x32 + } + if len(m.AggSig) > 0 { + i -= len(m.AggSig) + copy(dAtA[i:], m.AggSig) + i = encodeVarintTx(dAtA, i, uint64(len(m.AggSig))) + i-- + dAtA[i] = 0x2a + } + { + size, err := m.Timeout.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Votes) > 0 { + dAtA8 := make([]byte, len(m.Votes)*10) + var j7 int + for _, num := range m.Votes { + for num >= 1<<7 { + dAtA8[j7] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j7++ + } + dAtA8[j7] = uint8(num) + j7++ + } + i -= j7 + copy(dAtA[i:], dAtA8[:j7]) + i = encodeVarintTx(dAtA, i, uint64(j7)) + i-- + dAtA[i] = 0x1a + } + if m.ProposalId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgVoteAggResponse) 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 *MsgVoteAggResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVoteAggResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgExecRequest) 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 *MsgExecRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x12 + } + if m.ProposalId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgExecResponse) 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 *MsgExecResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCreateGroupRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Members) > 0 { + for _, e := range m.Members { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateGroupResponse) Size() (n int) { + if m == nil { + return 0 } var l int _ = l @@ -2326,6 +2840,94 @@ func (m *MsgVoteResponse) Size() (n int) { return n } +func (m *MsgVoteBasicRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovTx(uint64(m.ProposalId)) + } + if m.Choice != 0 { + n += 1 + sovTx(uint64(m.Choice)) + } + l = m.Timeout.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgVoteBasicResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovTx(uint64(m.ProposalId)) + } + if m.Choice != 0 { + n += 1 + sovTx(uint64(m.Choice)) + } + l = m.Timeout.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.PubKey != nil { + l = m.PubKey.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Sig) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgVoteAggRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.ProposalId != 0 { + n += 1 + sovTx(uint64(m.ProposalId)) + } + if len(m.Votes) > 0 { + l = 0 + for _, e := range m.Votes { + l += sovTx(uint64(e)) + } + n += 1 + sovTx(uint64(l)) + l + } + l = m.Timeout.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.AggSig) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgVoteAggResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgExecRequest) Size() (n int) { if m == nil { return 0 @@ -2492,10 +3094,7 @@ func (m *MsgCreateGroupRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -2564,10 +3163,7 @@ func (m *MsgCreateGroupResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -2702,10 +3298,7 @@ func (m *MsgUpdateGroupMembersRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -2755,10 +3348,7 @@ func (m *MsgUpdateGroupMembersResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -2891,10 +3481,7 @@ func (m *MsgUpdateGroupAdminRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -2944,10 +3531,7 @@ func (m *MsgUpdateGroupAdminResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -3082,10 +3666,7 @@ func (m *MsgUpdateGroupMetadataRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -3135,10 +3716,7 @@ func (m *MsgUpdateGroupMetadataResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -3309,10 +3887,7 @@ func (m *MsgCreateGroupAccountRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -3394,10 +3969,7 @@ func (m *MsgCreateGroupAccountResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -3543,10 +4115,7 @@ func (m *MsgUpdateGroupAccountAdminRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -3596,10 +4165,7 @@ func (m *MsgUpdateGroupAccountAdminResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -3749,10 +4315,7 @@ func (m *MsgUpdateGroupAccountDecisionPolicyRequest) Unmarshal(dAtA []byte) erro if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -3802,10 +4365,7 @@ func (m *MsgUpdateGroupAccountDecisionPolicyResponse) Unmarshal(dAtA []byte) err if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -3953,10 +4513,7 @@ func (m *MsgUpdateGroupAccountMetadataRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4006,10 +4563,7 @@ func (m *MsgUpdateGroupAccountMetadataResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4191,10 +4745,7 @@ func (m *MsgCreateProposalRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4263,10 +4814,7 @@ func (m *MsgCreateProposalResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4420,10 +4968,401 @@ func (m *MsgVoteRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } - if (iNdEx + skippy) < 0 { + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgVoteResponse) 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 ErrIntOverflowTx + } + 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: MsgVoteResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgVoteResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgVoteBasicRequest) 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 ErrIntOverflowTx + } + 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: MsgVoteBasicRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgVoteBasicRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Choice", wireType) + } + m.Choice = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Choice |= Choice(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgVoteBasicResponse) 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 ErrIntOverflowTx + } + 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: MsgVoteBasicResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgVoteBasicResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Choice", wireType) + } + m.Choice = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Choice |= Choice(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Voter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PubKey == nil { + m.PubKey = &types.Any{} + } + if err := m.PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sig", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sig = append(m.Sig[:0], dAtA[iNdEx:postIndex]...) + if m.Sig == nil { + m.Sig = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4438,7 +5377,7 @@ func (m *MsgVoteRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgVoteResponse) Unmarshal(dAtA []byte) error { +func (m *MsgVoteAggRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4461,22 +5400,290 @@ func (m *MsgVoteResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgVoteResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVoteAggRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgVoteResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVoteAggRequest: 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType == 0 { + var v Choice + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= Choice(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Votes = append(m.Votes, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + if elementCount != 0 && len(m.Votes) == 0 { + m.Votes = make([]Choice, 0, elementCount) + } + for iNdEx < postIndex { + var v Choice + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= Choice(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Votes = append(m.Votes, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Votes", wireType) + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AggSig", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AggSig = append(m.AggSig[:0], dAtA[iNdEx:postIndex]...) + if m.AggSig == nil { + m.AggSig = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } - if (iNdEx + skippy) < 0 { + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgVoteAggResponse) 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 ErrIntOverflowTx + } + 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: MsgVoteAggResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgVoteAggResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4577,10 +5784,7 @@ func (m *MsgExecRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4630,10 +5834,7 @@ func (m *MsgExecResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { diff --git a/x/group/tx_cosmos.pb.go b/x/group/tx_cosmos.pb.go index f57f3f34a9..da15a807c6 100644 --- a/x/group/tx_cosmos.pb.go +++ b/x/group/tx_cosmos.pb.go @@ -36,6 +36,8 @@ type MsgClient interface { CreateProposal(ctx context.Context, in *MsgCreateProposalRequest, opts ...grpc.CallOption) (*MsgCreateProposalResponse, error) // Vote allows a voter to vote on a proposal. Vote(ctx context.Context, in *MsgVoteRequest, opts ...grpc.CallOption) (*MsgVoteResponse, error) + // VoteAgg allows a sender to submit a set of votes + VoteAgg(ctx context.Context, in *MsgVoteAggRequest, opts ...grpc.CallOption) (*MsgVoteAggResponse, error) // Exec executes a proposal. Exec(ctx context.Context, in *MsgExecRequest, opts ...grpc.CallOption) (*MsgExecResponse, error) } @@ -52,6 +54,7 @@ type msgClient struct { _UpdateGroupAccountMetadata types.Invoker _CreateProposal types.Invoker _Vote types.Invoker + _VoteAgg types.Invoker _Exec types.Invoker } @@ -289,6 +292,29 @@ func (c *msgClient) Vote(ctx context.Context, in *MsgVoteRequest, opts ...grpc.C return out, nil } +func (c *msgClient) VoteAgg(ctx context.Context, in *MsgVoteAggRequest, opts ...grpc.CallOption) (*MsgVoteAggResponse, error) { + if invoker := c._VoteAgg; invoker != nil { + var out MsgVoteAggResponse + err := invoker(ctx, in, &out) + return &out, err + } + if invokerConn, ok := c.cc.(types.InvokerConn); ok { + var err error + c._VoteAgg, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/VoteAgg") + if err != nil { + var out MsgVoteAggResponse + err = c._VoteAgg(ctx, in, &out) + return &out, err + } + } + out := new(MsgVoteAggResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/VoteAgg", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) Exec(ctx context.Context, in *MsgExecRequest, opts ...grpc.CallOption) (*MsgExecResponse, error) { if invoker := c._Exec; invoker != nil { var out MsgExecResponse @@ -334,6 +360,8 @@ type MsgServer interface { CreateProposal(types.Context, *MsgCreateProposalRequest) (*MsgCreateProposalResponse, error) // Vote allows a voter to vote on a proposal. Vote(types.Context, *MsgVoteRequest) (*MsgVoteResponse, error) + // VoteAgg allows a sender to submit a set of votes + VoteAgg(types.Context, *MsgVoteAggRequest) (*MsgVoteAggResponse, error) // Exec executes a proposal. Exec(types.Context, *MsgExecRequest) (*MsgExecResponse, error) } @@ -522,6 +550,24 @@ func _Msg_Vote_Handler(srv interface{}, ctx context.Context, dec func(interface{ return interceptor(ctx, in, info, handler) } +func _Msg_VoteAgg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgVoteAggRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).VoteAgg(types.UnwrapSDKContext(ctx), in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/VoteAgg", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).VoteAgg(types.UnwrapSDKContext(ctx), req.(*MsgVoteAggRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_Exec_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgExecRequest) if err := dec(in); err != nil { @@ -587,6 +633,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{ MethodName: "Vote", Handler: _Msg_Vote_Handler, }, + { + MethodName: "VoteAgg", + Handler: _Msg_VoteAgg_Handler, + }, { MethodName: "Exec", Handler: _Msg_Exec_Handler, @@ -606,5 +656,6 @@ const ( MsgUpdateGroupAccountMetadataMethod = "/regen.group.v1alpha1.Msg/UpdateGroupAccountMetadata" MsgCreateProposalMethod = "/regen.group.v1alpha1.Msg/CreateProposal" MsgVoteMethod = "/regen.group.v1alpha1.Msg/Vote" + MsgVoteAggMethod = "/regen.group.v1alpha1.Msg/VoteAgg" MsgExecMethod = "/regen.group.v1alpha1.Msg/Exec" ) diff --git a/x/group/types.pb.go b/x/group/types.pb.go index 59d18f8de5..0772281d1e 100644 --- a/x/group/types.pb.go +++ b/x/group/types.pb.go @@ -749,86 +749,86 @@ func init() { func init() { proto.RegisterFile("regen/group/v1alpha1/types.proto", fileDescriptor_9b7906b115009838) } var fileDescriptor_9b7906b115009838 = []byte{ - // 1257 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x41, 0x6f, 0x1b, 0x45, - 0x14, 0xce, 0xda, 0x8e, 0x13, 0x3f, 0x27, 0x8e, 0x35, 0xa4, 0xad, 0xe3, 0xa4, 0xce, 0xd6, 0x15, - 0x52, 0x04, 0x8a, 0xad, 0x04, 0x38, 0x10, 0x51, 0x84, 0xbd, 0xd9, 0x14, 0xa3, 0xd4, 0x0e, 0xbb, - 0x76, 0x80, 0x1e, 0xb0, 0xd6, 0xbb, 0x53, 0x67, 0x61, 0xbd, 0x63, 0xed, 0xce, 0xa6, 0x35, 0x3f, - 0x00, 0x15, 0x9f, 0xb8, 0x70, 0xe0, 0x60, 0xa9, 0x12, 0x7f, 0x81, 0x1f, 0x51, 0x71, 0xaa, 0x10, - 0x07, 0xc4, 0x01, 0xa1, 0xf6, 0xc2, 0x05, 0x89, 0x9f, 0x80, 0x76, 0x66, 0x36, 0xc9, 0x36, 0x8e, - 0xdb, 0x03, 0xb7, 0x7d, 0xef, 0x7d, 0xdf, 0x9b, 0xf7, 0xbe, 0x37, 0x7e, 0x63, 0x90, 0x3d, 0xdc, - 0xc7, 0x6e, 0xb5, 0xef, 0x91, 0x60, 0x58, 0x3d, 0xdd, 0x31, 0x9c, 0xe1, 0x89, 0xb1, 0x53, 0xa5, - 0xa3, 0x21, 0xf6, 0x2b, 0x43, 0x8f, 0x50, 0x82, 0x56, 0x19, 0xa2, 0xc2, 0x10, 0x95, 0x08, 0x51, - 0x5c, 0xed, 0x93, 0x3e, 0x61, 0x80, 0x6a, 0xf8, 0xc5, 0xb1, 0xc5, 0x52, 0x9f, 0x90, 0xbe, 0x83, - 0xab, 0xcc, 0xea, 0x05, 0x0f, 0xaa, 0x56, 0xe0, 0x19, 0xd4, 0x26, 0xae, 0x88, 0x6f, 0xbe, 0x1c, - 0xa7, 0xf6, 0x00, 0xfb, 0xd4, 0x18, 0x0c, 0x05, 0x60, 0xcd, 0x24, 0xfe, 0x80, 0xf8, 0x5d, 0x9e, - 0x99, 0x1b, 0x51, 0xe8, 0x65, 0xae, 0xe1, 0x8e, 0x78, 0xa8, 0x7c, 0x0c, 0xe9, 0x7b, 0x78, 0xd0, - 0xc3, 0x1e, 0x2a, 0xc0, 0x82, 0x61, 0x59, 0x1e, 0xf6, 0xfd, 0x82, 0x24, 0x4b, 0x5b, 0x19, 0x2d, - 0x32, 0xd1, 0x75, 0x48, 0x3f, 0xc4, 0x76, 0xff, 0x84, 0x16, 0x12, 0x2c, 0x20, 0x2c, 0x54, 0x84, - 0xc5, 0x01, 0xa6, 0x86, 0x65, 0x50, 0xa3, 0x90, 0x94, 0xa5, 0xad, 0x25, 0xed, 0xcc, 0x2e, 0xdf, - 0x85, 0x05, 0x9e, 0xd7, 0x47, 0x1f, 0xc0, 0xc2, 0x80, 0x7f, 0x16, 0x24, 0x39, 0xb9, 0x95, 0xdd, - 0xdd, 0xa8, 0x4c, 0xd3, 0xa5, 0xc2, 0xf1, 0xf5, 0xd4, 0xd3, 0x3f, 0x37, 0xe7, 0xb4, 0x88, 0x52, - 0xfe, 0x56, 0x82, 0x1b, 0xed, 0x13, 0x0f, 0xfb, 0x27, 0xc4, 0xb1, 0xf6, 0xb1, 0x69, 0xfb, 0x36, - 0x71, 0x8f, 0x88, 0x63, 0x9b, 0x23, 0xb4, 0x01, 0x19, 0x1a, 0x85, 0x44, 0xd1, 0xe7, 0x0e, 0xf4, - 0x3e, 0x2c, 0x84, 0x1a, 0x91, 0x80, 0xd7, 0x9d, 0xdd, 0x5d, 0xab, 0x70, 0x1d, 0x2a, 0x91, 0x0e, - 0x95, 0x7d, 0xa1, 0x71, 0x74, 0xa8, 0xc0, 0xef, 0xa1, 0x5f, 0x7f, 0xde, 0xce, 0xc5, 0x0f, 0x2b, - 0xff, 0x20, 0x41, 0xe6, 0x6e, 0x58, 0x71, 0xc3, 0x7d, 0x40, 0xd0, 0x1a, 0x2c, 0xb2, 0xf2, 0xbb, - 0x36, 0x3f, 0x39, 0xa5, 0x2d, 0x30, 0xbb, 0x61, 0xa1, 0x55, 0x98, 0x37, 0xac, 0x81, 0xed, 0x0a, - 0xb5, 0xb8, 0x31, 0x4b, 0xac, 0x50, 0xfa, 0x53, 0xec, 0x85, 0x67, 0x15, 0x52, 0x3c, 0x97, 0x30, - 0xd1, 0x2d, 0x58, 0xa2, 0x84, 0x1a, 0x4e, 0x57, 0x0c, 0x60, 0x9e, 0xa5, 0xcc, 0x32, 0xdf, 0x67, - 0xcc, 0x55, 0xfe, 0x12, 0xb2, 0xac, 0x2c, 0x31, 0xc6, 0x19, 0x85, 0xbd, 0x0b, 0x69, 0xae, 0xaa, - 0xd0, 0x63, 0xe6, 0x1c, 0x34, 0x81, 0x2d, 0xff, 0x2b, 0x41, 0x9e, 0x1d, 0x50, 0x33, 0x4d, 0x12, - 0xb8, 0x94, 0xb5, 0x7f, 0xf5, 0x65, 0xb9, 0x78, 0x7e, 0xe2, 0x0a, 0x61, 0x92, 0x57, 0x09, 0x93, - 0xba, 0x5a, 0x98, 0xf9, 0xb8, 0x30, 0x9f, 0xc2, 0x8a, 0x25, 0xe6, 0xd3, 0x1d, 0xb2, 0x01, 0x15, - 0xd2, 0xac, 0xa9, 0xd5, 0x4b, 0x43, 0xae, 0xb9, 0xa3, 0x3a, 0xfa, 0xe5, 0xd2, 0x40, 0xb5, 0x9c, - 0x15, 0xb3, 0xf7, 0x16, 0x1f, 0x3f, 0xd9, 0x9c, 0xfb, 0xfb, 0xc9, 0xa6, 0x54, 0xfe, 0x07, 0x60, - 0xf1, 0xc8, 0x23, 0x43, 0xe2, 0x1b, 0x0e, 0xda, 0x84, 0xec, 0x50, 0x7c, 0x9f, 0x6b, 0x0a, 0x91, - 0xab, 0x61, 0x5d, 0xd4, 0x22, 0x11, 0xd7, 0x62, 0xd6, 0xcc, 0x37, 0x20, 0xc3, 0x73, 0x84, 0xbf, - 0x8b, 0x94, 0x9c, 0x0c, 0xef, 0xee, 0x99, 0x03, 0x29, 0xb0, 0xe4, 0x07, 0xbd, 0x81, 0x4d, 0x29, - 0xb6, 0xba, 0x06, 0x9f, 0x7b, 0x76, 0xb7, 0x78, 0xa9, 0xb7, 0x76, 0xb4, 0x04, 0xc4, 0x0d, 0xce, - 0x9e, 0xb1, 0x6a, 0x14, 0xdd, 0x86, 0x65, 0x3e, 0x8a, 0x48, 0xc3, 0x34, 0xab, 0x7d, 0x89, 0x39, - 0x8f, 0x85, 0x90, 0xbb, 0x70, 0x8d, 0x83, 0x0c, 0x3e, 0xde, 0x33, 0xf0, 0x02, 0x03, 0xbf, 0xd1, - 0xbf, 0x30, 0xfa, 0x88, 0x73, 0x07, 0xd2, 0x3e, 0x35, 0x68, 0xe0, 0x17, 0x16, 0x65, 0x69, 0x2b, - 0xb7, 0xfb, 0xe6, 0xf4, 0x8b, 0x14, 0x49, 0x58, 0xd1, 0x19, 0x58, 0x13, 0xa4, 0x90, 0xee, 0x61, - 0x3f, 0x70, 0x68, 0x21, 0xf3, 0x5a, 0x74, 0x8d, 0x81, 0x35, 0x41, 0x42, 0x1f, 0x01, 0x9c, 0x12, - 0x8a, 0xbb, 0x61, 0x36, 0x5c, 0x00, 0xa6, 0xcc, 0xfa, 0xf4, 0x14, 0x6d, 0xc3, 0x71, 0x46, 0x42, - 0x9a, 0x4c, 0x48, 0x0a, 0x2b, 0xc1, 0x68, 0xef, 0x7c, 0x33, 0x64, 0x5f, 0x53, 0xd8, 0x88, 0x80, - 0x8e, 0x61, 0x05, 0x3f, 0xc2, 0x66, 0x40, 0x89, 0xd7, 0x15, 0x5d, 0x2c, 0xb1, 0x2e, 0xb6, 0x5f, - 0xd1, 0x85, 0x2a, 0x58, 0xa2, 0x9b, 0x1c, 0x8e, 0xd9, 0x68, 0x0b, 0x52, 0x03, 0xbf, 0xef, 0x17, - 0x96, 0xd9, 0x8a, 0x9c, 0x7a, 0x8b, 0x35, 0x86, 0x28, 0x3f, 0x93, 0x20, 0xcd, 0x15, 0x45, 0x3b, - 0x80, 0xf4, 0x76, 0xad, 0xdd, 0xd1, 0xbb, 0x9d, 0xa6, 0x7e, 0xa4, 0x2a, 0x8d, 0x83, 0x86, 0xba, - 0x9f, 0x9f, 0x2b, 0xae, 0x8d, 0x27, 0xf2, 0xb5, 0xe8, 0x64, 0x8e, 0x6d, 0xb8, 0xa7, 0x86, 0x63, - 0x5b, 0x68, 0x07, 0xf2, 0x82, 0xa2, 0x77, 0xea, 0xf7, 0x1a, 0xed, 0xb6, 0xba, 0x9f, 0x97, 0x8a, - 0xeb, 0xe3, 0x89, 0x7c, 0x23, 0x4e, 0xd0, 0xa3, 0x9b, 0x84, 0xde, 0x86, 0x65, 0x41, 0x51, 0x0e, - 0x5b, 0xba, 0xba, 0x9f, 0x4f, 0x14, 0x0b, 0xe3, 0x89, 0xbc, 0x1a, 0xc7, 0x2b, 0x0e, 0xf1, 0xb1, - 0x85, 0xb6, 0x21, 0x27, 0xc0, 0xb5, 0x7a, 0x4b, 0x0b, 0xb3, 0x27, 0xa7, 0x95, 0x53, 0xeb, 0x11, - 0x8f, 0x62, 0xab, 0x98, 0x7a, 0xfc, 0x53, 0x69, 0xae, 0xfc, 0x87, 0x04, 0x69, 0xa1, 0xc3, 0x0e, - 0x20, 0x4d, 0xd5, 0x3b, 0x87, 0xed, 0x59, 0x2d, 0x71, 0x6c, 0xd4, 0xd2, 0x7b, 0x17, 0x28, 0x07, - 0x8d, 0x66, 0xed, 0xb0, 0x71, 0x9f, 0x35, 0x75, 0x73, 0x3c, 0x91, 0xd7, 0xe2, 0x94, 0x8e, 0xfb, - 0xc0, 0x76, 0x0d, 0xc7, 0xfe, 0x06, 0x5b, 0xa8, 0x0a, 0x2b, 0x82, 0x56, 0x53, 0x14, 0xf5, 0xa8, - 0xcd, 0x1a, 0x2b, 0x8e, 0x27, 0xf2, 0xf5, 0x38, 0xa7, 0x66, 0x9a, 0x78, 0x48, 0x63, 0x04, 0x4d, - 0xfd, 0x44, 0x55, 0x78, 0x6f, 0x53, 0x08, 0x1a, 0xfe, 0x0a, 0x9b, 0xe7, 0xcd, 0xfd, 0x98, 0x80, - 0x5c, 0x7c, 0xf8, 0xa8, 0x0e, 0xeb, 0xea, 0xe7, 0xaa, 0xd2, 0x69, 0xb7, 0xb4, 0xee, 0xd4, 0x6e, - 0x6f, 0x8d, 0x27, 0xf2, 0xcd, 0x28, 0x6b, 0x9c, 0x1c, 0x75, 0x7d, 0x07, 0x6e, 0xbc, 0x9c, 0xa3, - 0xd9, 0x6a, 0x77, 0xb5, 0x4e, 0x33, 0x2f, 0x15, 0xe5, 0xf1, 0x44, 0xde, 0x98, 0xce, 0x6f, 0x12, - 0xaa, 0x05, 0x2e, 0xfa, 0xf0, 0x32, 0x5d, 0xef, 0x28, 0x8a, 0xaa, 0xeb, 0xf9, 0xc4, 0xac, 0xe3, - 0xf5, 0xc0, 0x34, 0xc3, 0xdd, 0x36, 0x85, 0x7f, 0x50, 0x6b, 0x1c, 0x76, 0x34, 0x35, 0x9f, 0x9c, - 0xc5, 0x3f, 0x30, 0x6c, 0x27, 0xf0, 0x30, 0xd7, 0x66, 0x2f, 0x15, 0xee, 0xdc, 0xf2, 0x77, 0x12, - 0xcc, 0xb3, 0x9f, 0x2a, 0x5a, 0x87, 0xcc, 0x08, 0xfb, 0x5d, 0xb6, 0x6d, 0xc4, 0xcb, 0xb2, 0x38, - 0xc2, 0xbe, 0x12, 0xda, 0xe1, 0xd3, 0xe2, 0x12, 0x11, 0x13, 0x9b, 0xd6, 0x25, 0x3c, 0x74, 0x1b, - 0x96, 0x8d, 0x9e, 0x4f, 0x0d, 0xdb, 0x15, 0x71, 0xfe, 0xc4, 0x2c, 0x09, 0x27, 0x07, 0xdd, 0x04, - 0x38, 0xc5, 0x34, 0xca, 0x90, 0xe2, 0xff, 0x17, 0x42, 0x0f, 0x0b, 0x8b, 0x5a, 0x7e, 0x93, 0x20, - 0x75, 0x4c, 0x28, 0x7e, 0xf5, 0xde, 0x5f, 0x85, 0xf9, 0x70, 0xa5, 0x78, 0xd1, 0x3b, 0xcf, 0x8c, - 0xf0, 0x91, 0x35, 0x4f, 0x88, 0x6d, 0x62, 0x56, 0x42, 0xee, 0xaa, 0x47, 0x56, 0x61, 0x18, 0x4d, - 0x60, 0x67, 0x3e, 0x82, 0xff, 0xc7, 0x5b, 0xf0, 0x96, 0x05, 0x69, 0x7e, 0x24, 0xba, 0x0e, 0x48, - 0xf9, 0xb8, 0xd5, 0x50, 0xd4, 0xf8, 0x95, 0x43, 0xcb, 0x90, 0x11, 0xfe, 0x66, 0x2b, 0x2f, 0xa1, - 0x1c, 0x80, 0x30, 0xbf, 0x50, 0xf5, 0x7c, 0x02, 0x21, 0xc8, 0x09, 0xbb, 0x56, 0xd7, 0xdb, 0xb5, - 0x46, 0x33, 0x9f, 0x44, 0x2b, 0x90, 0x15, 0xbe, 0x63, 0xb5, 0xdd, 0xca, 0xa7, 0xea, 0x77, 0x9f, - 0x3e, 0x2f, 0x49, 0xcf, 0x9e, 0x97, 0xa4, 0xbf, 0x9e, 0x97, 0xa4, 0xef, 0x5f, 0x94, 0xe6, 0x9e, - 0xbd, 0x28, 0xcd, 0xfd, 0xfe, 0xa2, 0x34, 0x77, 0x7f, 0xbb, 0x6f, 0xd3, 0x93, 0xa0, 0x57, 0x31, - 0xc9, 0xa0, 0xca, 0x04, 0xd9, 0x76, 0x31, 0x7d, 0x48, 0xbc, 0xaf, 0x85, 0xe5, 0x60, 0xab, 0x8f, - 0xbd, 0xea, 0x23, 0xfe, 0x77, 0xba, 0x97, 0x66, 0x5d, 0xbd, 0xf3, 0x5f, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x65, 0x8d, 0xd3, 0x7f, 0x64, 0x0b, 0x00, 0x00, + // 1250 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x6f, 0x1b, 0xc5, + 0x1b, 0xf6, 0xda, 0x8e, 0x13, 0xbf, 0x76, 0x1c, 0x6b, 0x7e, 0x69, 0xeb, 0x38, 0xa9, 0xb3, 0x75, + 0x7f, 0x48, 0x11, 0x28, 0xb6, 0x12, 0xe0, 0x40, 0x44, 0x2b, 0xec, 0xcd, 0xa6, 0x18, 0xa5, 0x76, + 0xd8, 0xb5, 0x03, 0xf4, 0x80, 0xb5, 0xde, 0x9d, 0x3a, 0x0b, 0xf6, 0x8e, 0xb5, 0x3b, 0x1b, 0x6a, + 0x3e, 0x00, 0x2a, 0x3e, 0x71, 0xe1, 0xc0, 0xc1, 0x52, 0x25, 0xbe, 0x02, 0x1f, 0xa2, 0xe2, 0x54, + 0x21, 0x0e, 0x88, 0x03, 0x42, 0xed, 0x85, 0x0b, 0x12, 0x1f, 0x01, 0xed, 0xcc, 0x6c, 0x92, 0x6d, + 0x1c, 0xb7, 0x07, 0x4e, 0xbb, 0xef, 0x3b, 0xcf, 0xf3, 0xfe, 0x79, 0xde, 0xd9, 0x99, 0x05, 0xd9, + 0xc5, 0x7d, 0xec, 0x54, 0xfb, 0x2e, 0xf1, 0x47, 0xd5, 0xd3, 0x1d, 0x63, 0x30, 0x3a, 0x31, 0x76, + 0xaa, 0x74, 0x3c, 0xc2, 0x5e, 0x65, 0xe4, 0x12, 0x4a, 0xd0, 0x2a, 0x43, 0x54, 0x18, 0xa2, 0x12, + 0x22, 0x8a, 0xab, 0x7d, 0xd2, 0x27, 0x0c, 0x50, 0x0d, 0xde, 0x38, 0xb6, 0x58, 0xea, 0x13, 0xd2, + 0x1f, 0xe0, 0x2a, 0xb3, 0x7a, 0xfe, 0xc3, 0xaa, 0xe5, 0xbb, 0x06, 0xb5, 0x89, 0x23, 0xd6, 0x37, + 0x5f, 0x5e, 0xa7, 0xf6, 0x10, 0x7b, 0xd4, 0x18, 0x8e, 0x04, 0x20, 0x6b, 0x12, 0x6f, 0x48, 0x44, + 0xea, 0xe2, 0xda, 0xcb, 0x70, 0xc3, 0x19, 0xf3, 0xa5, 0xf2, 0x31, 0xa4, 0xee, 0xe3, 0x61, 0x0f, + 0xbb, 0xa8, 0x00, 0x8b, 0x86, 0x65, 0xb9, 0xd8, 0xf3, 0x0a, 0x92, 0x2c, 0x6d, 0xa5, 0xb5, 0xd0, + 0x44, 0xd7, 0x21, 0xf5, 0x15, 0xb6, 0xfb, 0x27, 0xb4, 0x10, 0x67, 0x0b, 0xc2, 0x42, 0x45, 0x58, + 0x1a, 0x62, 0x6a, 0x58, 0x06, 0x35, 0x0a, 0x09, 0x59, 0xda, 0xca, 0x6a, 0x67, 0x76, 0xf9, 0x1e, + 0x2c, 0xf2, 0xb8, 0x1e, 0x7a, 0x1f, 0x16, 0x87, 0xfc, 0xb5, 0x20, 0xc9, 0x89, 0xad, 0xcc, 0xee, + 0x46, 0x65, 0x96, 0x14, 0x15, 0x8e, 0xaf, 0x27, 0x9f, 0xfe, 0xb1, 0x19, 0xd3, 0x42, 0x4a, 0xf9, + 0x1b, 0x09, 0x6e, 0xb4, 0x4f, 0x5c, 0xec, 0x9d, 0x90, 0x81, 0xb5, 0x8f, 0x4d, 0xdb, 0xb3, 0x89, + 0x73, 0x44, 0x06, 0xb6, 0x39, 0x46, 0x1b, 0x90, 0xa6, 0xe1, 0x92, 0x28, 0xfa, 0xdc, 0x81, 0xde, + 0x83, 0xc5, 0x40, 0x16, 0xe2, 0xf3, 0xba, 0x33, 0xbb, 0x6b, 0x15, 0xae, 0x43, 0x25, 0xd4, 0xa1, + 0xb2, 0x2f, 0x64, 0x0d, 0x93, 0x0a, 0xfc, 0x1e, 0xfa, 0xe5, 0xa7, 0xed, 0x5c, 0x34, 0x59, 0xf9, + 0x7b, 0x09, 0xd2, 0xf7, 0x82, 0x8a, 0x1b, 0xce, 0x43, 0x82, 0xd6, 0x60, 0x89, 0x95, 0xdf, 0xb5, + 0x79, 0xe6, 0xa4, 0xb6, 0xc8, 0xec, 0x86, 0x85, 0x56, 0x61, 0xc1, 0xb0, 0x86, 0xb6, 0x23, 0xd4, + 0xe2, 0xc6, 0x3c, 0xb1, 0x02, 0xe9, 0x4f, 0xb1, 0x1b, 0xe4, 0x2a, 0x24, 0x79, 0x2c, 0x61, 0xa2, + 0x5b, 0x90, 0xa5, 0x84, 0x1a, 0x83, 0xae, 0x18, 0xc0, 0x02, 0x0b, 0x99, 0x61, 0xbe, 0x4f, 0x98, + 0xab, 0xfc, 0x39, 0x64, 0x58, 0x59, 0x62, 0x8c, 0x73, 0x0a, 0x7b, 0x07, 0x52, 0x5c, 0x55, 0xa1, + 0xc7, 0xdc, 0x39, 0x68, 0x02, 0x5b, 0xfe, 0x47, 0x82, 0x3c, 0x4b, 0x50, 0x33, 0x4d, 0xe2, 0x3b, + 0x94, 0xb5, 0x7f, 0xf5, 0x66, 0xb9, 0x98, 0x3f, 0x7e, 0x85, 0x30, 0x89, 0xab, 0x84, 0x49, 0x5e, + 0x2d, 0xcc, 0x42, 0x54, 0x98, 0x8f, 0x61, 0xc5, 0x12, 0xf3, 0xe9, 0x8e, 0xd8, 0x80, 0x0a, 0x29, + 0xd6, 0xd4, 0xea, 0xa5, 0x21, 0xd7, 0x9c, 0x71, 0x1d, 0xfd, 0x7c, 0x69, 0xa0, 0x5a, 0xce, 0x8a, + 0xd8, 0x7b, 0x4b, 0x8f, 0x9f, 0x6c, 0xc6, 0xfe, 0x7a, 0xb2, 0x29, 0x95, 0xff, 0x06, 0x58, 0x3a, + 0x72, 0xc9, 0x88, 0x78, 0xc6, 0x00, 0x6d, 0x42, 0x66, 0x24, 0xde, 0xcf, 0x35, 0x85, 0xd0, 0xd5, + 0xb0, 0x2e, 0x6a, 0x11, 0x8f, 0x6a, 0x31, 0x6f, 0xe6, 0x1b, 0x90, 0xe6, 0x31, 0x82, 0xef, 0x22, + 0x29, 0x27, 0x82, 0xbd, 0x7b, 0xe6, 0x40, 0x0a, 0x64, 0x3d, 0xbf, 0x37, 0xb4, 0x29, 0xc5, 0x56, + 0xd7, 0xe0, 0x73, 0xcf, 0xec, 0x16, 0x2f, 0xf5, 0xd6, 0x0e, 0xbf, 0x7b, 0xb1, 0x83, 0x33, 0x67, + 0xac, 0x1a, 0x45, 0xb7, 0x61, 0x99, 0x8f, 0x22, 0xd4, 0x30, 0xc5, 0x6a, 0xcf, 0x32, 0xe7, 0xb1, + 0x10, 0x72, 0x17, 0xae, 0x71, 0x90, 0xc1, 0xc7, 0x7b, 0x06, 0x5e, 0x64, 0xe0, 0xff, 0xf5, 0x2f, + 0x8c, 0x3e, 0xe4, 0xdc, 0x81, 0x94, 0x47, 0x0d, 0xea, 0x7b, 0x85, 0x25, 0x59, 0xda, 0xca, 0xed, + 0xbe, 0x31, 0x7b, 0x23, 0x85, 0x12, 0x56, 0x74, 0x06, 0xd6, 0x04, 0x29, 0xa0, 0xbb, 0xd8, 0xf3, + 0x07, 0xb4, 0x90, 0x7e, 0x2d, 0xba, 0xc6, 0xc0, 0x9a, 0x20, 0xa1, 0x0f, 0x00, 0x4e, 0x09, 0xc5, + 0xdd, 0x20, 0x1a, 0x2e, 0x00, 0x53, 0x66, 0x7d, 0x76, 0x88, 0xb6, 0x31, 0x18, 0x8c, 0x85, 0x34, + 0xe9, 0x80, 0x14, 0x54, 0x82, 0xd1, 0xde, 0xf9, 0xc9, 0x90, 0x79, 0x4d, 0x61, 0x43, 0x02, 0x3a, + 0x86, 0x15, 0xfc, 0x08, 0x9b, 0x3e, 0x25, 0x6e, 0x57, 0x74, 0x91, 0x65, 0x5d, 0x6c, 0xbf, 0xa2, + 0x0b, 0x55, 0xb0, 0x44, 0x37, 0x39, 0x1c, 0xb1, 0xd1, 0x16, 0x24, 0x87, 0x5e, 0xdf, 0x2b, 0x2c, + 0xb3, 0x23, 0x72, 0xe6, 0x2e, 0xd6, 0x18, 0xa2, 0xfc, 0x4c, 0x82, 0x14, 0x57, 0x14, 0xed, 0x00, + 0xd2, 0xdb, 0xb5, 0x76, 0x47, 0xef, 0x76, 0x9a, 0xfa, 0x91, 0xaa, 0x34, 0x0e, 0x1a, 0xea, 0x7e, + 0x3e, 0x56, 0x5c, 0x9b, 0x4c, 0xe5, 0x6b, 0x61, 0x66, 0x8e, 0x6d, 0x38, 0xa7, 0xc6, 0xc0, 0xb6, + 0xd0, 0x0e, 0xe4, 0x05, 0x45, 0xef, 0xd4, 0xef, 0x37, 0xda, 0x6d, 0x75, 0x3f, 0x2f, 0x15, 0xd7, + 0x27, 0x53, 0xf9, 0x46, 0x94, 0xa0, 0x87, 0x3b, 0x09, 0xbd, 0x05, 0xcb, 0x82, 0xa2, 0x1c, 0xb6, + 0x74, 0x75, 0x3f, 0x1f, 0x2f, 0x16, 0x26, 0x53, 0x79, 0x35, 0x8a, 0x57, 0x06, 0xc4, 0xc3, 0x16, + 0xda, 0x86, 0x9c, 0x00, 0xd7, 0xea, 0x2d, 0x2d, 0x88, 0x9e, 0x98, 0x55, 0x4e, 0xad, 0x47, 0x5c, + 0x8a, 0xad, 0x62, 0xf2, 0xf1, 0x8f, 0xa5, 0x58, 0xf9, 0x77, 0x09, 0x52, 0x42, 0x87, 0x1d, 0x40, + 0x9a, 0xaa, 0x77, 0x0e, 0xdb, 0xf3, 0x5a, 0xe2, 0xd8, 0xb0, 0xa5, 0x77, 0x2f, 0x50, 0x0e, 0x1a, + 0xcd, 0xda, 0x61, 0xe3, 0x01, 0x6b, 0xea, 0xe6, 0x64, 0x2a, 0xaf, 0x45, 0x29, 0x1d, 0xe7, 0xa1, + 0xed, 0x18, 0x03, 0xfb, 0x6b, 0x6c, 0xa1, 0x2a, 0xac, 0x08, 0x5a, 0x4d, 0x51, 0xd4, 0xa3, 0x36, + 0x6b, 0xac, 0x38, 0x99, 0xca, 0xd7, 0xa3, 0x9c, 0x9a, 0x69, 0xe2, 0x11, 0x8d, 0x10, 0x34, 0xf5, + 0x23, 0x55, 0xe1, 0xbd, 0xcd, 0x20, 0x68, 0xf8, 0x0b, 0x6c, 0x9e, 0x37, 0xf7, 0x43, 0x1c, 0x72, + 0xd1, 0xe1, 0xa3, 0x3a, 0xac, 0xab, 0x9f, 0xaa, 0x4a, 0xa7, 0xdd, 0xd2, 0xba, 0x33, 0xbb, 0xbd, + 0x35, 0x99, 0xca, 0x37, 0xc3, 0xa8, 0x51, 0x72, 0xd8, 0xf5, 0x1d, 0xb8, 0xf1, 0x72, 0x8c, 0x66, + 0xab, 0xdd, 0xd5, 0x3a, 0xcd, 0xbc, 0x54, 0x94, 0x27, 0x53, 0x79, 0x63, 0x36, 0xbf, 0x49, 0xa8, + 0xe6, 0x3b, 0xe8, 0xee, 0x65, 0xba, 0xde, 0x51, 0x14, 0x55, 0xd7, 0xf3, 0xf1, 0x79, 0xe9, 0x75, + 0xdf, 0x34, 0x83, 0xb3, 0x6d, 0x06, 0xff, 0xa0, 0xd6, 0x38, 0xec, 0x68, 0x6a, 0x3e, 0x31, 0x8f, + 0x7f, 0x60, 0xd8, 0x03, 0xdf, 0xc5, 0x5c, 0x9b, 0xbd, 0x64, 0x70, 0xe6, 0x96, 0xbf, 0x95, 0x60, + 0x81, 0x7d, 0xaa, 0x68, 0x1d, 0xd2, 0x63, 0xec, 0x75, 0xd9, 0x69, 0x23, 0x6e, 0x96, 0xa5, 0x31, + 0xf6, 0x94, 0xc0, 0x0e, 0xae, 0x16, 0x87, 0x88, 0x35, 0x71, 0xd2, 0x3a, 0x84, 0x2f, 0xdd, 0x86, + 0x65, 0xa3, 0xe7, 0x51, 0xc3, 0x76, 0xc4, 0x3a, 0xbf, 0x62, 0xb2, 0xc2, 0xc9, 0x41, 0x37, 0x01, + 0x4e, 0x31, 0x0d, 0x23, 0x24, 0xf9, 0xff, 0x42, 0xe0, 0x61, 0xcb, 0xa2, 0x96, 0x5f, 0x25, 0x48, + 0x1e, 0x13, 0x8a, 0x5f, 0x7d, 0xee, 0xaf, 0xc2, 0x42, 0x70, 0xa4, 0xb8, 0xe1, 0x3d, 0xcf, 0x8c, + 0xe0, 0x92, 0x35, 0x4f, 0x88, 0x6d, 0x62, 0x56, 0x42, 0xee, 0xaa, 0x4b, 0x56, 0x61, 0x18, 0x4d, + 0x60, 0xe7, 0x5e, 0x82, 0xff, 0xc5, 0x5d, 0xf0, 0xa6, 0x05, 0x29, 0x9e, 0x12, 0x5d, 0x07, 0xa4, + 0x7c, 0xd8, 0x6a, 0x28, 0x6a, 0x74, 0xcb, 0xa1, 0x65, 0x48, 0x0b, 0x7f, 0xb3, 0x95, 0x97, 0x50, + 0x0e, 0x40, 0x98, 0x9f, 0xa9, 0x7a, 0x3e, 0x8e, 0x10, 0xe4, 0x84, 0x5d, 0xab, 0xeb, 0xed, 0x5a, + 0xa3, 0x99, 0x4f, 0xa0, 0x15, 0xc8, 0x08, 0xdf, 0xb1, 0xda, 0x6e, 0xe5, 0x93, 0xf5, 0xbb, 0x4f, + 0x9f, 0x97, 0xa4, 0x67, 0xcf, 0x4b, 0xd2, 0x9f, 0xcf, 0x4b, 0xd2, 0x77, 0x2f, 0x4a, 0xb1, 0x67, + 0x2f, 0x4a, 0xb1, 0xdf, 0x5e, 0x94, 0x62, 0x0f, 0xfe, 0xdf, 0xb7, 0xe9, 0x89, 0xdf, 0xab, 0x98, + 0x64, 0x58, 0xe5, 0xff, 0xa6, 0xe2, 0xb1, 0xed, 0x59, 0x5f, 0x56, 0x1f, 0xf1, 0x1f, 0xe7, 0x5e, + 0x8a, 0x35, 0xf3, 0xf6, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x9a, 0x3a, 0x59, 0x02, 0x4e, 0x0b, + 0x00, 0x00, } func (this *GroupAccountInfo) Equal(that interface{}) bool { @@ -1757,10 +1757,7 @@ func (m *Member) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1844,10 +1841,7 @@ func (m *Members) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -1962,10 +1956,7 @@ func (m *ThresholdDecisionPolicy) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2151,10 +2142,7 @@ func (m *GroupInfo) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2259,10 +2247,7 @@ func (m *GroupMember) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2484,10 +2469,7 @@ func (m *GroupAccountInfo) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -2882,10 +2864,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -3063,10 +3042,7 @@ func (m *Tally) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { @@ -3253,10 +3229,7 @@ func (m *Vote) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTypes } if (iNdEx + skippy) > l { From b936f01056040521a7f85ab607eaf00811473686 Mon Sep 17 00:00:00 2001 From: kitty Date: Mon, 23 Aug 2021 14:00:08 +0100 Subject: [PATCH 20/34] add checking on empty messages/public keys --- crypto/keys/bls12381/multisig.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crypto/keys/bls12381/multisig.go b/crypto/keys/bls12381/multisig.go index d887951fce..dadfc0c3e1 100644 --- a/crypto/keys/bls12381/multisig.go +++ b/crypto/keys/bls12381/multisig.go @@ -71,10 +71,22 @@ func VerifyAggregateSignature(msgs [][]byte, msgCheck bool, sig []byte, pkss [][ return fmt.Errorf("messages cannot be empty") } + for i, msg := range msgs { + if len(msg) <= 0 { + return fmt.Errorf("%d-th message is empty", i) + } + } + if len(pkss) != n { return fmt.Errorf("the number of messages and public key sets must match") } + for i, pks := range pkss { + if len(pks) <= 0 { + return fmt.Errorf("%d-th public key set is empty", i) + } + } + if msgCheck { if !Unique(msgs) { return fmt.Errorf("messages must be pairwise distinct") From 9f5514930779723524495fa1c8adc5004e84474a Mon Sep 17 00:00:00 2001 From: kitty Date: Mon, 23 Aug 2021 14:34:39 +0100 Subject: [PATCH 21/34] add gas caclulation/consumption for verifying aggregated votes --- x/group/server/expected_keepers.go | 2 + x/group/server/gas.go | 73 ++++++++++++++++++++++++++++++ x/group/server/handler.go | 2 - x/group/server/msg_server.go | 53 +++++++++++++++++----- x/group/server/sigverify.go | 22 +++++++++ 5 files changed, 138 insertions(+), 14 deletions(-) create mode 100644 x/group/server/gas.go create mode 100644 x/group/server/sigverify.go diff --git a/x/group/server/expected_keepers.go b/x/group/server/expected_keepers.go index 83c583b6e9..1f5f4e268c 100644 --- a/x/group/server/expected_keepers.go +++ b/x/group/server/expected_keepers.go @@ -6,6 +6,8 @@ import ( ) type AccountKeeper interface { + GetParams(ctx sdk.Context) (params types.Params) + // Return a new account with the next account number. Does not save the new account to the store. NewAccount(sdk.Context, types.AccountI) types.AccountI diff --git a/x/group/server/gas.go b/x/group/server/gas.go new file mode 100644 index 0000000000..340de7c0ea --- /dev/null +++ b/x/group/server/gas.go @@ -0,0 +1,73 @@ +package server + +import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "math" +) + +func addUint64Overflow(a, b uint64) (uint64, bool) { + if math.MaxUint64-a < b { + return 0, true + } + + return a + b, false +} + +func mulUint64Overflow(a, b uint64) (uint64, bool) { + if math.MaxUint64/a < b { + return 0, true + } + return a*b, false +} + +func subUint64Overflow(a, b uint64) (uint64, bool) { + if a < b { + return 0, true + } + + return a - b, false +} + +// DefaultSigVerificationGasConsumer computes and consumes gas cost using the formula: +// gas := base + pairingCost * (numMsg - 1) + additionCost * (numPk - numMsg) +func DefaultAggSigVerifyGasConsumer(meter sdk.GasMeter, numPk uint64, numMsg uint64, params authtypes.Params) error { + base := params.SigVerifyCostBls12381 + pairingCost := base/3 + additionCost := base/1215 + + sub, overflow := subUint64Overflow(numMsg, 1) + if overflow { + return fmt.Errorf("subtraction between uint64 overflow") + } + + mul, overflow := mulUint64Overflow(pairingCost, sub) + if overflow { + return fmt.Errorf("multiplication between uint64 overflow") + } + + sub2, overflow := subUint64Overflow(numPk, numMsg) + if overflow { + return fmt.Errorf("subtraction between uint64 overflow") + } + + mul2, overflow := mulUint64Overflow(additionCost, sub2) + if overflow { + return fmt.Errorf("multiplication between uint64 overflow") + } + + sum, overflow := addUint64Overflow(base, mul) + if overflow { + return fmt.Errorf("addition between uint64 overflow") + } + + gas, overflow := addUint64Overflow(sum, mul2) + if overflow { + return fmt.Errorf("addition between uint64 overflow") + } + + meter.ConsumeGas(gas, "verify aggregated signature") + + return nil +} \ No newline at end of file diff --git a/x/group/server/handler.go b/x/group/server/handler.go index 65877b6a6e..a7053c7eca 100644 --- a/x/group/server/handler.go +++ b/x/group/server/handler.go @@ -1,7 +1,6 @@ package server import ( - "fmt" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/group" @@ -64,7 +63,6 @@ func NewHandler(configurator servermodule.Configurator, accountKeeper AccountKee return sdk.WrapServiceResult(ctx, res, err) case *group.MsgVoteAggRequest: - fmt.Println("\n\n\n in new handler \n\n\n") res, err := impl.VoteAgg(regenCtx, msg) return sdk.WrapServiceResult(ctx, res, err) diff --git a/x/group/server/msg_server.go b/x/group/server/msg_server.go index 2525b4412e..2df692c354 100644 --- a/x/group/server/msg_server.go +++ b/x/group/server/msg_server.go @@ -632,7 +632,7 @@ func (s serverImpl) VoteAgg(ctx types.Context, req *group.MsgVoteAggRequest) (*g } if votesExpire.Compare(blockTime) <= 0 { - return nil, fmt.Errorf("the aggregated votes have expired") + return nil, sdkerrors.Wrap(group.ErrExpired, "the aggregated votes have expired") } proposal, err := s.getProposal(ctx, id) @@ -643,14 +643,11 @@ func (s serverImpl) VoteAgg(ctx types.Context, req *group.MsgVoteAggRequest) (*g if proposal.Status != group.ProposalStatusSubmitted { return nil, sdkerrors.Wrap(group.ErrInvalid, "proposal not open for voting") } - votingPeriodEnd, err := gogotypes.TimestampFromProto(&proposal.Timeout) - if err != nil { - return nil, err - } - if votingPeriodEnd.Before(ctx.BlockTime()) || votingPeriodEnd.Equal(ctx.BlockTime()) { + if proposal.Timeout.Compare(ctx.BlockTime()) <= 0 { return nil, sdkerrors.Wrap(group.ErrExpired, "voting period has ended already") } + var accountInfo group.GroupAccountInfo // Ensure that group account hasn't been modified since the proposal submission. address, err := sdk.AccAddressFromBech32(proposal.Address) @@ -678,14 +675,19 @@ func (s serverImpl) VoteAgg(ctx types.Context, req *group.MsgVoteAggRequest) (*g return nil, err } - var pubKeys []cryptotypes.PubKey var votes []group.Vote var weights []string + choiceMap := make(map[group.Choice]bool, len(group.Choice_name)) + pkMap := make(map[group.Choice][]cryptotypes.PubKey, len(group.Choice_name)) + msgMap := make(map[group.Choice][]byte, len(group.Choice_name)) for i:=0; ; i++ { var mem group.GroupMember _, err := membersIter.LoadNext(&mem) if err != nil { if orm.ErrIteratorDone.Is(err) { + if i < len(choices) { + return nil, sdkerrors.Wrap(group.ErrInvalid, "too many votes") + } break } return nil, err @@ -697,18 +699,17 @@ func (s serverImpl) VoteAgg(ctx types.Context, req *group.MsgVoteAggRequest) (*g } if i >= len(choices) { - return nil, fmt.Errorf("wrong number of votes") + return nil, sdkerrors.Wrap(group.ErrInvalid, "not enough votes") } acc := s.accKeeper.GetAccount(ctx.Context, memAddr) if acc == nil { - return nil, fmt.Errorf("account does not exist") + return nil, sdkerrors.Wrap(group.ErrInvalid, "account does not exist") } pk := acc.GetPubKey() if pk == nil { - return nil, fmt.Errorf("public key not set yet") + return nil, sdkerrors.Wrap(group.ErrInvalid,"public key not set yet") } - pubKeys = append(pubKeys, pk) meta := fmt.Sprintf("submitted through aggregated vote by %s", req.Sender) if choices[i] != group.Choice_CHOICE_UNSPECIFIED { @@ -721,10 +722,38 @@ func (s serverImpl) VoteAgg(ctx types.Context, req *group.MsgVoteAggRequest) (*g } votes = append(votes, vote) weights = append(weights, mem.Member.Weight) + + _, ok := choiceMap[choices[i]] + if !ok { + choiceMap[choices[i]] = true + msg := group.MsgVoteBasicRequest{ + ProposalId: id, + Choice: choices[i], + Timeout: votesExpire, + } + msgMap[choices[i]] = msg.GetSignBytes() + } + pkMap[choices[i]] = append(pkMap[choices[i]], pk) } } - if err = req.VerifyAggSig(pubKeys); err != nil { + // calculate and consume gas before the verification of the aggregated signature + numChoice := uint64(len(choiceMap)) + numPk := uint64(len(votes)) + params := s.accKeeper.GetParams(ctx.Context) + err = DefaultAggSigVerifyGasConsumer(ctx.GasMeter(), numPk, numChoice, params) + if err!= nil { + return nil, sdkerrors.Wrap(err, "gas consumption for verifying aggregated signature") + } + + msgBytes := make([][]byte, 0, numChoice) + pkss := make([][]cryptotypes.PubKey, 0, numChoice) + for c := range msgMap { + msgBytes = append(msgBytes, msgMap[c]) + pkss = append(pkss, pkMap[c]) + } + + if err = VerifyAggSignature(msgBytes, false, req.AggSig, pkss); err!=nil { return nil, err } diff --git a/x/group/server/sigverify.go b/x/group/server/sigverify.go new file mode 100644 index 0000000000..0c6d16f2d2 --- /dev/null +++ b/x/group/server/sigverify.go @@ -0,0 +1,22 @@ +package server + +import ( + "fmt" + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" +) + +func VerifyAggSignature(msgs [][]byte, msgCheck bool, sig []byte, pkss [][]cryptotypes.PubKey) error { + pkssBls := make([][]*bls12381.PubKey, len(pkss)) + for i, pks := range pkss { + for _, pk := range pks { + pkBls, ok := pk.(*bls12381.PubKey) + if !ok { + return fmt.Errorf("only support bls public key") + } + pkssBls[i] = append(pkssBls[i], pkBls) + } + } + + return bls12381.VerifyAggregateSignature(msgs, msgCheck, sig, pkssBls) +} From ea33b8ffa04f9f3fbdc0109a7e2704831f505bb4 Mon Sep 17 00:00:00 2001 From: kitty Date: Tue, 24 Aug 2021 16:13:15 +0100 Subject: [PATCH 22/34] minor change to gas calculation for voteagg --- x/group/server/gas.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/group/server/gas.go b/x/group/server/gas.go index 340de7c0ea..ec6ce69798 100644 --- a/x/group/server/gas.go +++ b/x/group/server/gas.go @@ -34,7 +34,7 @@ func subUint64Overflow(a, b uint64) (uint64, bool) { // gas := base + pairingCost * (numMsg - 1) + additionCost * (numPk - numMsg) func DefaultAggSigVerifyGasConsumer(meter sdk.GasMeter, numPk uint64, numMsg uint64, params authtypes.Params) error { base := params.SigVerifyCostBls12381 - pairingCost := base/3 + pairingCost := base*33/10 additionCost := base/1215 sub, overflow := subUint64Overflow(numMsg, 1) From afef1be7017d25992ce890469aac1a5e77566136 Mon Sep 17 00:00:00 2001 From: kitty Date: Thu, 26 Aug 2021 11:05:44 +0100 Subject: [PATCH 23/34] initial commit for orm and types from regen-ledger v2.0.0-beta1 --- regen/orm/auto_uint64.go | 130 ++++ regen/orm/auto_uint64_test.go | 163 +++++ regen/orm/example_test.go | 53 ++ regen/orm/genesis.go | 88 +++ regen/orm/genesis_test.go | 54 ++ regen/orm/index.go | 219 ++++++ regen/orm/index_key_codec.go | 68 ++ regen/orm/index_key_codec_test.go | 115 +++ regen/orm/index_test.go | 348 +++++++++ regen/orm/indexer.go | 158 ++++ regen/orm/indexer_test.go | 527 ++++++++++++++ regen/orm/iterator.go | 304 ++++++++ regen/orm/iterator_test.go | 263 +++++++ regen/orm/orm.go | 177 +++++ regen/orm/orm_scenario_test.go | 405 +++++++++++ regen/orm/orm_test.go | 77 ++ regen/orm/primary_key.go | 208 ++++++ regen/orm/primary_key_property_test.go | 200 ++++++ regen/orm/primary_key_test.go | 337 +++++++++ regen/orm/sequence.go | 83 +++ regen/orm/sequence_property_test.go | 70 ++ regen/orm/sequence_test.go | 24 + regen/orm/table.go | 303 ++++++++ regen/orm/table_test.go | 129 ++++ regen/orm/testdata/codec.pb.go | 679 ++++++++++++++++++ regen/orm/testdata/codec.proto | 22 + regen/orm/testdata/model.go | 28 + regen/orm/testsupport.go | 135 ++++ regen/orm/uint64_index.go | 85 +++ regen/orm/uint64_index_test.go | 163 +++++ regen/types/address.go | 13 + regen/types/conn.go | 14 + regen/types/context.go | 33 + regen/types/id.go | 12 + regen/types/math/dec.go | 172 +++++ regen/types/math/dec_test.go | 485 +++++++++++++ regen/types/math/math.go | 147 ++++ regen/types/math/math_test.go | 34 + regen/types/module/base.go | 15 + regen/types/module/client/cli/module.go | 21 + .../module/client/grpc_gateway/module.go | 14 + regen/types/module/genesis.go | 12 + .../types/module/server/derived_module_key.go | 51 ++ regen/types/module/server/manager.go | 311 ++++++++ regen/types/module/server/module.go | 26 + regen/types/module/server/module_key.go | 20 + regen/types/module/server/msgs.go | 50 ++ regen/types/module/server/root_module_key.go | 68 ++ regen/types/module/server/router.go | 220 ++++++ regen/types/module/server/testutil.go | 153 ++++ regen/types/testutil/cli/cmd.go | 27 + regen/types/testutil/fixture.go | 57 ++ regen/types/testutil/network/doc.go | 65 ++ regen/types/testutil/network/network.go | 430 +++++++++++ regen/types/testutil/network/suite.go | 38 + regen/types/testutil/network/util.go | 190 +++++ 56 files changed, 8293 insertions(+) create mode 100644 regen/orm/auto_uint64.go create mode 100644 regen/orm/auto_uint64_test.go create mode 100644 regen/orm/example_test.go create mode 100644 regen/orm/genesis.go create mode 100644 regen/orm/genesis_test.go create mode 100644 regen/orm/index.go create mode 100644 regen/orm/index_key_codec.go create mode 100644 regen/orm/index_key_codec_test.go create mode 100644 regen/orm/index_test.go create mode 100644 regen/orm/indexer.go create mode 100644 regen/orm/indexer_test.go create mode 100644 regen/orm/iterator.go create mode 100644 regen/orm/iterator_test.go create mode 100644 regen/orm/orm.go create mode 100644 regen/orm/orm_scenario_test.go create mode 100644 regen/orm/orm_test.go create mode 100644 regen/orm/primary_key.go create mode 100644 regen/orm/primary_key_property_test.go create mode 100644 regen/orm/primary_key_test.go create mode 100644 regen/orm/sequence.go create mode 100644 regen/orm/sequence_property_test.go create mode 100644 regen/orm/sequence_test.go create mode 100644 regen/orm/table.go create mode 100644 regen/orm/table_test.go create mode 100644 regen/orm/testdata/codec.pb.go create mode 100644 regen/orm/testdata/codec.proto create mode 100644 regen/orm/testdata/model.go create mode 100644 regen/orm/testsupport.go create mode 100644 regen/orm/uint64_index.go create mode 100644 regen/orm/uint64_index_test.go create mode 100644 regen/types/address.go create mode 100644 regen/types/conn.go create mode 100644 regen/types/context.go create mode 100644 regen/types/id.go create mode 100644 regen/types/math/dec.go create mode 100644 regen/types/math/dec_test.go create mode 100644 regen/types/math/math.go create mode 100644 regen/types/math/math_test.go create mode 100644 regen/types/module/base.go create mode 100644 regen/types/module/client/cli/module.go create mode 100644 regen/types/module/client/grpc_gateway/module.go create mode 100644 regen/types/module/genesis.go create mode 100644 regen/types/module/server/derived_module_key.go create mode 100644 regen/types/module/server/manager.go create mode 100644 regen/types/module/server/module.go create mode 100644 regen/types/module/server/module_key.go create mode 100644 regen/types/module/server/msgs.go create mode 100644 regen/types/module/server/root_module_key.go create mode 100644 regen/types/module/server/router.go create mode 100644 regen/types/module/server/testutil.go create mode 100644 regen/types/testutil/cli/cmd.go create mode 100644 regen/types/testutil/fixture.go create mode 100644 regen/types/testutil/network/doc.go create mode 100644 regen/types/testutil/network/network.go create mode 100644 regen/types/testutil/network/suite.go create mode 100644 regen/types/testutil/network/util.go diff --git a/regen/orm/auto_uint64.go b/regen/orm/auto_uint64.go new file mode 100644 index 0000000000..90bbcbbc70 --- /dev/null +++ b/regen/orm/auto_uint64.go @@ -0,0 +1,130 @@ +package orm + +import ( + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ Indexable = &AutoUInt64TableBuilder{} + +// NewAutoUInt64TableBuilder creates a builder to setup a AutoUInt64Table object. +func NewAutoUInt64TableBuilder(prefixData byte, prefixSeq byte, storeKey sdk.StoreKey, model codec.ProtoMarshaler, cdc codec.Codec) *AutoUInt64TableBuilder { + if prefixData == prefixSeq { + panic("prefixData and prefixSeq must be unique") + } + + uInt64KeyCodec := FixLengthIndexKeys(EncodedSeqLength) + return &AutoUInt64TableBuilder{ + tableBuilder: newTableBuilder(prefixData, storeKey, model, uInt64KeyCodec, cdc), + seq: NewSequence(storeKey, prefixSeq), + } +} + +type AutoUInt64TableBuilder struct { + *tableBuilder + seq Sequence +} + +// Build create the AutoUInt64Table object. +func (a AutoUInt64TableBuilder) Build() AutoUInt64Table { + return AutoUInt64Table{ + table: a.tableBuilder.Build(), + seq: a.seq, + } +} + +var _ SequenceExportable = &AutoUInt64Table{} +var _ TableExportable = &AutoUInt64Table{} + +// AutoUInt64Table is the table type which an auto incrementing ID. +type AutoUInt64Table struct { + table table + seq Sequence +} + +// Create a new persistent object with an auto generated uint64 primary key. They key is returned. +// Create iterates though the registered callbacks and may add secondary index keys by them. +func (a AutoUInt64Table) Create(ctx HasKVStore, obj codec.ProtoMarshaler) (uint64, error) { + autoIncID := a.seq.NextVal(ctx) + err := a.table.Create(ctx, EncodeSequence(autoIncID), obj) + if err != nil { + return 0, err + } + return autoIncID, nil +} + +// Save updates the given object under the rowID key. It expects the key to exists already +// and fails with an `ErrNotFound` otherwise. Any caller must therefore make sure that this contract +// is fulfilled. Parameters must not be nil. +// +// Save iterates though the registered callbacks and may add or remove secondary index keys by them. +func (a AutoUInt64Table) Save(ctx HasKVStore, rowID uint64, newValue codec.ProtoMarshaler) error { + return a.table.Save(ctx, EncodeSequence(rowID), newValue) +} + +// Delete removes the object under the rowID key. It expects the key to exists already +// and fails with a `ErrNotFound` otherwise. Any caller must therefore make sure that this contract +// is fulfilled. +// +// Delete iterates though the registered callbacks and removes secondary index keys by them. +func (a AutoUInt64Table) Delete(ctx HasKVStore, rowID uint64) error { + return a.table.Delete(ctx, EncodeSequence(rowID)) +} + +// Has checks if a rowID exists. +func (a AutoUInt64Table) Has(ctx HasKVStore, rowID uint64) bool { + return a.table.Has(ctx, EncodeSequence(rowID)) +} + +// GetOne load the object persisted for the given RowID into the dest parameter. +// If none exists `ErrNotFound` is returned instead. Parameters must not be nil. +func (a AutoUInt64Table) GetOne(ctx HasKVStore, rowID uint64, dest codec.ProtoMarshaler) (RowID, error) { + rawRowID := EncodeSequence(rowID) + if err := a.table.GetOne(ctx, rawRowID, dest); err != nil { + return nil, err + } + return rawRowID, nil +} + +// PrefixScan returns an Iterator over a domain of keys in ascending order. End is exclusive. +// Start is an MultiKeyIndex key or prefix. It must be less than end, or the Iterator is invalid and error is returned. +// Iterator must be closed by caller. +// To iterate over entire domain, use PrefixScan(nil, nil) +// +// WARNING: The use of a PrefixScan can be very expensive in terms of Gas. Please make sure you do not expose +// this as an endpoint to the public without further limits. +// Example: +// it, err := idx.PrefixScan(ctx, start, end) +// if err !=nil { +// return err +// } +// const defaultLimit = 20 +// it = LimitIterator(it, defaultLimit) +// +// CONTRACT: No writes may happen within a domain while an iterator exists over it. +func (a AutoUInt64Table) PrefixScan(ctx HasKVStore, start, end uint64) (Iterator, error) { + return a.table.PrefixScan(ctx, EncodeSequence(start), EncodeSequence(end)) +} + +// ReversePrefixScan returns an Iterator over a domain of keys in descending order. End is exclusive. +// Start is an MultiKeyIndex key or prefix. It must be less than end, or the Iterator is invalid and error is returned. +// Iterator must be closed by caller. +// To iterate over entire domain, use PrefixScan(nil, nil) +// +// WARNING: The use of a ReversePrefixScan can be very expensive in terms of Gas. Please make sure you do not expose +// this as an endpoint to the public without further limits. See `LimitIterator` +// +// CONTRACT: No writes may happen within a domain while an iterator exists over it. +func (a AutoUInt64Table) ReversePrefixScan(ctx HasKVStore, start uint64, end uint64) (Iterator, error) { + return a.table.ReversePrefixScan(ctx, EncodeSequence(start), EncodeSequence(end)) +} + +// Sequence returns the sequence used by this table +func (a AutoUInt64Table) Sequence() Sequence { + return a.seq +} + +// Table satisfies the TableExportable interface and must not be used otherwise. +func (a AutoUInt64Table) Table() table { + return a.table +} diff --git a/regen/orm/auto_uint64_test.go b/regen/orm/auto_uint64_test.go new file mode 100644 index 0000000000..b6aebeeb31 --- /dev/null +++ b/regen/orm/auto_uint64_test.go @@ -0,0 +1,163 @@ +package orm_test + +import ( + "math" + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/regen/orm" + "github.com/cosmos/cosmos-sdk/regen/orm/testdata" +) + +func TestAutoUInt64PrefixScan(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + storeKey := sdk.NewKVStoreKey("test") + const ( + testTablePrefix = iota + testTableSeqPrefix + ) + tb := orm.NewAutoUInt64TableBuilder(testTablePrefix, testTableSeqPrefix, storeKey, &testdata.GroupInfo{}, cdc).Build() + ctx := orm.NewMockContext() + + g1 := testdata.GroupInfo{ + Description: "my test 1", + Admin: sdk.AccAddress([]byte("admin-address")), + } + g2 := testdata.GroupInfo{ + Description: "my test 2", + Admin: sdk.AccAddress([]byte("admin-address")), + } + g3 := testdata.GroupInfo{ + Description: "my test 3", + Admin: sdk.AccAddress([]byte("admin-address")), + } + for _, g := range []testdata.GroupInfo{g1, g2, g3} { + _, err := tb.Create(ctx, &g) + require.NoError(t, err) + } + + specs := map[string]struct { + start, end uint64 + expResult []testdata.GroupInfo + expRowIDs []orm.RowID + expError *errors.Error + method func(ctx orm.HasKVStore, start uint64, end uint64) (orm.Iterator, error) + }{ + "first element": { + start: 1, + end: 2, + method: tb.PrefixScan, + expResult: []testdata.GroupInfo{g1}, + expRowIDs: []orm.RowID{orm.EncodeSequence(1)}, + }, + "first 2 elements": { + start: 1, + end: 3, + method: tb.PrefixScan, + expResult: []testdata.GroupInfo{g1, g2}, + expRowIDs: []orm.RowID{orm.EncodeSequence(1), orm.EncodeSequence(2)}, + }, + "first 3 elements": { + start: 1, + end: 4, + method: tb.PrefixScan, + expResult: []testdata.GroupInfo{g1, g2, g3}, + expRowIDs: []orm.RowID{orm.EncodeSequence(1), orm.EncodeSequence(2), orm.EncodeSequence(3)}, + }, + "search with max end": { + start: 1, + end: math.MaxUint64, + method: tb.PrefixScan, + expResult: []testdata.GroupInfo{g1, g2, g3}, + expRowIDs: []orm.RowID{orm.EncodeSequence(1), orm.EncodeSequence(2), orm.EncodeSequence(3)}, + }, + "2 to end": { + start: 2, + end: 5, + method: tb.PrefixScan, + expResult: []testdata.GroupInfo{g2, g3}, + expRowIDs: []orm.RowID{orm.EncodeSequence(2), orm.EncodeSequence(3)}, + }, + "start before end should fail": { + start: 2, + end: 1, + method: tb.PrefixScan, + expError: orm.ErrArgument, + }, + "start equals end should fail": { + start: 1, + end: 1, + method: tb.PrefixScan, + expError: orm.ErrArgument, + }, + "reverse first element": { + start: 1, + end: 2, + method: tb.ReversePrefixScan, + expResult: []testdata.GroupInfo{g1}, + expRowIDs: []orm.RowID{orm.EncodeSequence(1)}, + }, + "reverse first 2 elements": { + start: 1, + end: 3, + method: tb.ReversePrefixScan, + expResult: []testdata.GroupInfo{g2, g1}, + expRowIDs: []orm.RowID{orm.EncodeSequence(2), orm.EncodeSequence(1)}, + }, + "reverse first 3 elements": { + start: 1, + end: 4, + method: tb.ReversePrefixScan, + expResult: []testdata.GroupInfo{g3, g2, g1}, + expRowIDs: []orm.RowID{orm.EncodeSequence(3), orm.EncodeSequence(2), orm.EncodeSequence(1)}, + }, + "reverse search with max end": { + start: 1, + end: math.MaxUint64, + method: tb.ReversePrefixScan, + expResult: []testdata.GroupInfo{g3, g2, g1}, + expRowIDs: []orm.RowID{orm.EncodeSequence(3), orm.EncodeSequence(2), orm.EncodeSequence(1)}, + }, + "reverse 2 to end": { + start: 2, + end: 5, + method: tb.ReversePrefixScan, + expResult: []testdata.GroupInfo{g3, g2}, + expRowIDs: []orm.RowID{orm.EncodeSequence(3), orm.EncodeSequence(2)}, + }, + "reverse start before end should fail": { + start: 2, + end: 1, + method: tb.ReversePrefixScan, + expError: orm.ErrArgument, + }, + "reverse start equals end should fail": { + start: 1, + end: 1, + method: tb.ReversePrefixScan, + expError: orm.ErrArgument, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + it, err := spec.method(ctx, spec.start, spec.end) + require.True(t, spec.expError.Is(err), "expected #+v but got #+v", spec.expError, err) + if spec.expError != nil { + return + } + var loaded []testdata.GroupInfo + rowIDs, err := orm.ReadAll(it, &loaded) + require.NoError(t, err) + assert.Equal(t, spec.expResult, loaded) + assert.Equal(t, spec.expRowIDs, rowIDs) + }) + } +} diff --git a/regen/orm/example_test.go b/regen/orm/example_test.go new file mode 100644 index 0000000000..3ff536f700 --- /dev/null +++ b/regen/orm/example_test.go @@ -0,0 +1,53 @@ +package orm_test + +import ( + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/cosmos-sdk/regen/orm" + "github.com/cosmos/cosmos-sdk/regen/orm/testdata" +) + +type GroupKeeper struct { + key sdk.StoreKey + groupTable orm.AutoUInt64Table + groupByAdminIndex orm.Index + groupMemberTable orm.PrimaryKeyTable + groupMemberByGroupIndex orm.Index + groupMemberByMemberIndex orm.Index +} + +var ( + GroupTablePrefix byte = 0x0 + GroupTableSeqPrefix byte = 0x1 + GroupByAdminIndexPrefix byte = 0x2 + GroupMemberTablePrefix byte = 0x3 + GroupMemberTableSeqPrefix byte = 0x4 + GroupMemberTableIndexPrefix byte = 0x5 + GroupMemberByGroupIndexPrefix byte = 0x6 + GroupMemberByMemberIndexPrefix byte = 0x7 +) + +func NewGroupKeeper(storeKey sdk.StoreKey, cdc codec.Codec) GroupKeeper { + k := GroupKeeper{key: storeKey} + + groupTableBuilder := orm.NewAutoUInt64TableBuilder(GroupTablePrefix, GroupTableSeqPrefix, storeKey, &testdata.GroupInfo{}, cdc) + // note: quite easy to mess with Index prefixes when managed outside. no fail fast on duplicates + k.groupByAdminIndex = orm.NewIndex(groupTableBuilder, GroupByAdminIndexPrefix, func(val interface{}) ([]orm.RowID, error) { + return []orm.RowID{[]byte(val.(*testdata.GroupInfo).Admin)}, nil + }) + k.groupTable = groupTableBuilder.Build() + + groupMemberTableBuilder := orm.NewPrimaryKeyTableBuilder(GroupMemberTablePrefix, storeKey, &testdata.GroupMember{}, orm.Max255DynamicLengthIndexKeyCodec{}, cdc) + + k.groupMemberByGroupIndex = orm.NewIndex(groupMemberTableBuilder, GroupMemberByGroupIndexPrefix, func(val interface{}) ([]orm.RowID, error) { + group := val.(*testdata.GroupMember).Group + return []orm.RowID{[]byte(group)}, nil + }) + k.groupMemberByMemberIndex = orm.NewIndex(groupMemberTableBuilder, GroupMemberByMemberIndexPrefix, func(val interface{}) ([]orm.RowID, error) { + return []orm.RowID{[]byte(val.(*testdata.GroupMember).Member)}, nil + }) + k.groupMemberTable = groupMemberTableBuilder.Build() + + return k +} diff --git a/regen/orm/genesis.go b/regen/orm/genesis.go new file mode 100644 index 0000000000..dc9afd49b8 --- /dev/null +++ b/regen/orm/genesis.go @@ -0,0 +1,88 @@ +package orm + +import ( + "reflect" + + "github.com/cosmos/cosmos-sdk/store/prefix" + "github.com/cosmos/cosmos-sdk/types/errors" +) + +// TableExportable +type TableExportable interface { + // Table returns the table to export + Table() table +} + +// SequenceExportable +type SequenceExportable interface { + // Sequence returns the sequence to export + Sequence() Sequence +} + +// ExportTableData iterates over the given table entries and stores them at the passed ModelSlicePtr. +// When the given table implements the `SequenceExportable` interface then it's current value +// is returned as well or otherwise defaults to 0. +func ExportTableData(ctx HasKVStore, t TableExportable, dest ModelSlicePtr) (uint64, error) { + it, err := t.Table().PrefixScan(ctx, nil, nil) + if err != nil { + return 0, errors.Wrap(err, "table PrefixScan failure when exporting table data") + } + _, err = ReadAll(it, dest) + if err != nil { + return 0, err + } + var seqValue uint64 + if st, ok := t.(SequenceExportable); ok { + seqValue = st.Sequence().CurVal(ctx) + } + return seqValue, err +} + +// ImportTableData initializes a table and attaches indexers from the given data interface{}. +// data should be a slice of structs that implement PrimaryKeyed (eg []*GroupInfo). +// The seqValue is optional and only used with tables that implement the `SequenceExportable` interface. +func ImportTableData(ctx HasKVStore, t TableExportable, data interface{}, seqValue uint64) error { + table := t.Table() + if err := clearAllInTable(ctx, table); err != nil { + return errors.Wrap(err, "clear old entries") + } + + if st, ok := t.(SequenceExportable); ok { + if err := st.Sequence().InitVal(ctx, seqValue); err != nil { + return errors.Wrap(err, "sequence") + } + } + + // Provided data must be a slice + modelSlice := reflect.ValueOf(data) + if modelSlice.Kind() != reflect.Slice { + return errors.Wrap(ErrArgument, "data must be a slice") + } + + // Create table entries + for i := 0; i < modelSlice.Len(); i++ { + obj, ok := modelSlice.Index(i).Interface().(PrimaryKeyed) + if !ok { + return errors.Wrapf(ErrArgument, "unsupported type :%s", reflect.TypeOf(data).Elem().Elem()) + } + err := table.Create(ctx, PrimaryKey(obj), obj) + if err != nil { + return err + } + } + + return nil +} + +// clearAllInTable deletes all entries in a table with delete interceptors called +func clearAllInTable(ctx HasKVStore, table table) error { + store := prefix.NewStore(ctx.KVStore(table.storeKey), []byte{table.prefix}) + it := store.Iterator(nil, nil) + defer it.Close() + for ; it.Valid(); it.Next() { + if err := table.Delete(ctx, it.Key()); err != nil { + return err + } + } + return nil +} diff --git a/regen/orm/genesis_test.go b/regen/orm/genesis_test.go new file mode 100644 index 0000000000..8f06cccdec --- /dev/null +++ b/regen/orm/genesis_test.go @@ -0,0 +1,54 @@ +package orm_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/regen/orm" + "github.com/cosmos/cosmos-sdk/regen/orm/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +func TestImportExportTableData(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + storeKey := sdk.NewKVStoreKey("test") + const prefix = iota + table := orm.NewAutoUInt64TableBuilder(prefix, 0x1, storeKey, &testdata.GroupInfo{}, cdc).Build() + + ctx := orm.NewMockContext() + + groups := []*testdata.GroupInfo{ + { + GroupId: 1, + Admin: sdk.AccAddress([]byte("admin1-address")), + }, + { + GroupId: 2, + Admin: sdk.AccAddress([]byte("admin2-address")), + }, + } + + err := orm.ImportTableData(ctx, table, groups, 2) + require.NoError(t, err) + + for _, g := range groups { + var loaded testdata.GroupInfo + _, err := table.GetOne(ctx, g.GroupId, &loaded) + require.NoError(t, err) + + require.Equal(t, g, &loaded) + } + + var exported []*testdata.GroupInfo + seq, err := orm.ExportTableData(ctx, table, &exported) + require.NoError(t, err) + require.Equal(t, seq, uint64(2)) + + for i, g := range exported { + require.Equal(t, g, groups[i]) + } +} diff --git a/regen/orm/index.go b/regen/orm/index.go new file mode 100644 index 0000000000..c918f446b1 --- /dev/null +++ b/regen/orm/index.go @@ -0,0 +1,219 @@ +package orm + +import ( + "bytes" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" + "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/query" +) + +// indexer creates and modifies the second MultiKeyIndex based on the operations and changes on the primary object. +type indexer interface { + OnCreate(store sdk.KVStore, rowID RowID, value interface{}) error + OnDelete(store sdk.KVStore, rowID RowID, value interface{}) error + OnUpdate(store sdk.KVStore, rowID RowID, newValue, oldValue interface{}) error +} + +// MultiKeyIndex is an index where multiple entries can point to the same underlying object as opposite to a unique index +// where only one entry is allowed. +type MultiKeyIndex struct { + storeKey sdk.StoreKey + prefix byte + rowGetter RowGetter + indexer indexer + indexKeyCodec IndexKeyCodec +} + +// NewIndex builds a MultiKeyIndex +func NewIndex(builder Indexable, prefix byte, indexer IndexerFunc) MultiKeyIndex { + return newIndex(builder, prefix, NewIndexer(indexer, builder.IndexKeyCodec())) +} + +func newIndex(builder Indexable, prefix byte, indexer *Indexer) MultiKeyIndex { + codec := builder.IndexKeyCodec() + if codec == nil { + panic("IndexKeyCodec must not be nil") + } + storeKey := builder.StoreKey() + if storeKey == nil { + panic("StoreKey must not be nil") + } + rowGetter := builder.RowGetter() + if rowGetter == nil { + panic("RowGetter must not be nil") + } + + idx := MultiKeyIndex{ + storeKey: storeKey, + prefix: prefix, + rowGetter: rowGetter, + indexer: indexer, + indexKeyCodec: codec, + } + builder.AddAfterSaveInterceptor(idx.onSave) + builder.AddAfterDeleteInterceptor(idx.onDelete) + return idx +} + +// Has checks if a key exists. Panics on nil key. +func (i MultiKeyIndex) Has(ctx HasKVStore, key []byte) bool { + store := prefix.NewStore(ctx.KVStore(i.storeKey), []byte{i.prefix}) + it := store.Iterator(PrefixRange(key)) + defer it.Close() + return it.Valid() +} + +// Get returns a result iterator for the searchKey. Parameters must not be nil. +func (i MultiKeyIndex) Get(ctx HasKVStore, searchKey []byte) (Iterator, error) { + store := prefix.NewStore(ctx.KVStore(i.storeKey), []byte{i.prefix}) + it := store.Iterator(PrefixRange(searchKey)) + return indexIterator{ctx: ctx, it: it, rowGetter: i.rowGetter, keyCodec: i.indexKeyCodec}, nil +} + +// GetPaginated creates an iterator for the searchKey +// starting from pageRequest.Key if provided. +// The pageRequest.Key is the rowID while searchKey is a MultiKeyIndex key. +func (i MultiKeyIndex) GetPaginated(ctx HasKVStore, searchKey []byte, pageRequest *query.PageRequest) (Iterator, error) { + store := prefix.NewStore(ctx.KVStore(i.storeKey), []byte{i.prefix}) + start, end := PrefixRange(searchKey) + + if pageRequest != nil && len(pageRequest.Key) != 0 { + start = i.indexKeyCodec.BuildIndexKey(searchKey, RowID(pageRequest.Key)) + } + it := store.Iterator(start, end) + return indexIterator{ctx: ctx, it: it, rowGetter: i.rowGetter, keyCodec: i.indexKeyCodec}, nil +} + +// PrefixScan returns an Iterator over a domain of keys in ascending order. End is exclusive. +// Start is an MultiKeyIndex key or prefix. It must be less than end, or the Iterator is invalid and error is returned. +// Iterator must be closed by caller. +// To iterate over entire domain, use PrefixScan(nil, nil) +// +// WARNING: The use of a PrefixScan can be very expensive in terms of Gas. Please make sure you do not expose +// this as an endpoint to the public without further limits. +// Example: +// it, err := idx.PrefixScan(ctx, start, end) +// if err !=nil { +// return err +// } +// const defaultLimit = 20 +// it = LimitIterator(it, defaultLimit) +// +// CONTRACT: No writes may happen within a domain while an iterator exists over it. +func (i MultiKeyIndex) PrefixScan(ctx HasKVStore, start []byte, end []byte) (Iterator, error) { + if start != nil && end != nil && bytes.Compare(start, end) >= 0 { + return NewInvalidIterator(), errors.Wrap(ErrArgument, "start must be less than end") + } + store := prefix.NewStore(ctx.KVStore(i.storeKey), []byte{i.prefix}) + it := store.Iterator(start, end) + return indexIterator{ctx: ctx, it: it, rowGetter: i.rowGetter, keyCodec: i.indexKeyCodec}, nil +} + +// ReversePrefixScan returns an Iterator over a domain of keys in descending order. End is exclusive. +// Start is an MultiKeyIndex key or prefix. It must be less than end, or the Iterator is invalid and error is returned. +// Iterator must be closed by caller. +// To iterate over entire domain, use PrefixScan(nil, nil) +// +// WARNING: The use of a ReversePrefixScan can be very expensive in terms of Gas. Please make sure you do not expose +// this as an endpoint to the public without further limits. See `LimitIterator` +// +// CONTRACT: No writes may happen within a domain while an iterator exists over it. +func (i MultiKeyIndex) ReversePrefixScan(ctx HasKVStore, start []byte, end []byte) (Iterator, error) { + if start != nil && end != nil && bytes.Compare(start, end) >= 0 { + return NewInvalidIterator(), errors.Wrap(ErrArgument, "start must be less than end") + } + store := prefix.NewStore(ctx.KVStore(i.storeKey), []byte{i.prefix}) + it := store.ReverseIterator(start, end) + return indexIterator{ctx: ctx, it: it, rowGetter: i.rowGetter, keyCodec: i.indexKeyCodec}, nil +} + +func (i MultiKeyIndex) onSave(ctx HasKVStore, rowID RowID, newValue, oldValue codec.ProtoMarshaler) error { + store := prefix.NewStore(ctx.KVStore(i.storeKey), []byte{i.prefix}) + if oldValue == nil { + return i.indexer.OnCreate(store, rowID, newValue) + } + return i.indexer.OnUpdate(store, rowID, newValue, oldValue) +} + +func (i MultiKeyIndex) onDelete(ctx HasKVStore, rowID RowID, oldValue codec.ProtoMarshaler) error { + store := prefix.NewStore(ctx.KVStore(i.storeKey), []byte{i.prefix}) + return i.indexer.OnDelete(store, rowID, oldValue) +} + +type UniqueIndex struct { + MultiKeyIndex +} + +// NewUniqueIndex create a new Index object where duplicate keys are prohibited. +func NewUniqueIndex(builder Indexable, prefix byte, uniqueIndexerFunc UniqueIndexerFunc) UniqueIndex { + return UniqueIndex{ + MultiKeyIndex: newIndex(builder, prefix, NewUniqueIndexer(uniqueIndexerFunc, builder.IndexKeyCodec())), + } +} + +// indexIterator uses rowGetter to lazy load new model values on request. +type indexIterator struct { + ctx HasKVStore + rowGetter RowGetter + it types.Iterator + keyCodec IndexKeyCodec +} + +// LoadNext loads the next value in the sequence into the pointer passed as dest and returns the key. If there +// are no more items the ErrIteratorDone error is returned +// The key is the rowID and not any MultiKeyIndex key. +func (i indexIterator) LoadNext(dest codec.ProtoMarshaler) (RowID, error) { + if !i.it.Valid() { + return nil, ErrIteratorDone + } + indexPrefixKey := i.it.Key() + rowID := i.keyCodec.StripRowID(indexPrefixKey) + i.it.Next() + return rowID, i.rowGetter(i.ctx, rowID, dest) +} + +// Close releases the iterator and should be called at the end of iteration +func (i indexIterator) Close() error { + i.it.Close() + return nil +} + +// PrefixRange turns a prefix into a (start, end) range. The start is the given prefix value and +// the end is calculated by adding 1 bit to the start value. Nil is not allowed as prefix. +// Example: []byte{1, 3, 4} becomes []byte{1, 3, 5} +// []byte{15, 42, 255, 255} becomes []byte{15, 43, 0, 0} +// +// In case of an overflow the end is set to nil. +// Example: []byte{255, 255, 255, 255} becomes nil +// +func PrefixRange(prefix []byte) ([]byte, []byte) { + if prefix == nil { + panic("nil key not allowed") + } + // special case: no prefix is whole range + if len(prefix) == 0 { + return nil, nil + } + + // copy the prefix and update last byte + end := make([]byte, len(prefix)) + copy(end, prefix) + l := len(end) - 1 + end[l]++ + + // wait, what if that overflowed?.... + for end[l] == 0 && l > 0 { + l-- + end[l]++ + } + + // okay, funny guy, you gave us FFF, no end to this range... + if l == 0 && end[0] == 0 { + end = nil + } + return prefix, end +} diff --git a/regen/orm/index_key_codec.go b/regen/orm/index_key_codec.go new file mode 100644 index 0000000000..8ef01ab041 --- /dev/null +++ b/regen/orm/index_key_codec.go @@ -0,0 +1,68 @@ +package orm + +// Max255DynamicLengthIndexKeyCodec works with up to 255 byte dynamic size RowIDs. +// They are encoded as `concat(searchableKey, rowID, len(rowID)[0])` and can be used +// with PrimaryKey or external Key tables for example. +type Max255DynamicLengthIndexKeyCodec struct{} + +// BuildIndexKey builds the index key by appending searchableKey with rowID and length int. +// The RowID length must not be greater than 255. +func (Max255DynamicLengthIndexKeyCodec) BuildIndexKey(searchableKey []byte, rowID RowID) []byte { + rowIDLen := len(rowID) + switch { + case rowIDLen == 0: + panic("Empty RowID") + case rowIDLen > 255: + panic("RowID exceeds max size") + } + + searchableKeyLen := len(searchableKey) + res := make([]byte, searchableKeyLen+rowIDLen+1) + copy(res, searchableKey) + copy(res[searchableKeyLen:], rowID) + res[searchableKeyLen+rowIDLen] = byte(rowIDLen) + return res +} + +// StripRowID returns the RowID from the combined persistentIndexKey. It is the reverse operation to BuildIndexKey +// but with the searchableKey and length int dropped. +func (Max255DynamicLengthIndexKeyCodec) StripRowID(persistentIndexKey []byte) RowID { + n := len(persistentIndexKey) + searchableKeyLen := persistentIndexKey[n-1] + return persistentIndexKey[n-int(searchableKeyLen)-1 : n-1] +} + +// FixLengthIndexKeyCodec expects the RowID to always have the same length with all entries. +// They are encoded as `concat(searchableKey, rowID)` and can be used +// with AutoUint64Tables and length EncodedSeqLength for example. +type FixLengthIndexKeyCodec struct { + rowIDLength int +} + +// FixLengthIndexKeys is a constructor for FixLengthIndexKeyCodec. +func FixLengthIndexKeys(rowIDLength int) *FixLengthIndexKeyCodec { + return &FixLengthIndexKeyCodec{rowIDLength: rowIDLength} +} + +// BuildIndexKey builds the index key by appending searchableKey with rowID. +// The RowID length must not be greater than what is defined by rowIDLength in construction. +func (c FixLengthIndexKeyCodec) BuildIndexKey(searchableKey []byte, rowID RowID) []byte { + switch n := len(rowID); { + case n == 0: + panic("Empty RowID") + case n > c.rowIDLength: + panic("RowID exceeds max size") + } + n := len(searchableKey) + res := make([]byte, n+c.rowIDLength) + copy(res, searchableKey) + copy(res[n:], rowID) + return res +} + +// StripRowID returns the RowID from the combined persistentIndexKey. It is the reverse operation to BuildIndexKey +// but with the searchableKey dropped. +func (c FixLengthIndexKeyCodec) StripRowID(persistentIndexKey []byte) RowID { + n := len(persistentIndexKey) + return persistentIndexKey[n-c.rowIDLength:] +} diff --git a/regen/orm/index_key_codec_test.go b/regen/orm/index_key_codec_test.go new file mode 100644 index 0000000000..d7f49df545 --- /dev/null +++ b/regen/orm/index_key_codec_test.go @@ -0,0 +1,115 @@ +package orm + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestEncodeIndexKey(t *testing.T) { + specs := map[string]struct { + srcKey []byte + srcRowID RowID + enc IndexKeyCodec + expKey []byte + expPanic bool + }{ + "dynamic length example 1": { + srcKey: []byte{0x0, 0x1, 0x2}, + srcRowID: []byte{0x3, 0x4}, + enc: Max255DynamicLengthIndexKeyCodec{}, + expKey: []byte{0x0, 0x1, 0x2, 0x3, 0x4, 0x2}, + }, + "dynamic length example 2": { + srcKey: []byte{0x0, 0x1}, + srcRowID: []byte{0x2, 0x3, 0x4}, + enc: Max255DynamicLengthIndexKeyCodec{}, + expKey: []byte{0x0, 0x1, 0x2, 0x3, 0x4, 0x3}, + }, + "dynamic length max row ID": { + srcKey: []byte{0x0, 0x1}, + srcRowID: []byte(strings.Repeat("a", 255)), + enc: Max255DynamicLengthIndexKeyCodec{}, + expKey: append(append([]byte{0x0, 0x1}, []byte(strings.Repeat("a", 255))...), 0xff), + }, + "dynamic length panics with empty rowID": { + srcKey: []byte{0x0, 0x1}, + srcRowID: []byte{}, + enc: Max255DynamicLengthIndexKeyCodec{}, + expPanic: true, + }, + "dynamic length exceeds max row ID": { + srcKey: []byte{0x0, 0x1}, + srcRowID: []byte(strings.Repeat("a", 256)), + enc: Max255DynamicLengthIndexKeyCodec{}, + expPanic: true, + }, + "uint64 example": { + srcKey: []byte{0x0, 0x1, 0x2}, + srcRowID: []byte{0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8}, + enc: FixLengthIndexKeys(8), + expKey: []byte{0x0, 0x1, 0x2, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8}, + }, + "uint64 panics with empty rowID": { + srcKey: []byte{0x0, 0x1}, + srcRowID: []byte{}, + enc: FixLengthIndexKeys(8), + expPanic: true, + }, + "uint64 exceeds max bytes in rowID": { + srcKey: []byte{0x0, 0x1}, + srcRowID: []byte{0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9}, + enc: FixLengthIndexKeys(8), + expPanic: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + if spec.expPanic { + require.Panics(t, + func() { + _ = spec.enc.BuildIndexKey(spec.srcKey, spec.srcRowID) + }) + return + } + got := spec.enc.BuildIndexKey(spec.srcKey, spec.srcRowID) + assert.Equal(t, spec.expKey, got) + }) + } +} +func TestDecodeIndexKey(t *testing.T) { + specs := map[string]struct { + srcKey []byte + enc IndexKeyCodec + expRowID RowID + }{ + "dynamic length example 1": { + srcKey: []byte{0x0, 0x1, 0x2, 0x3, 0x4, 0x2}, + enc: Max255DynamicLengthIndexKeyCodec{}, + expRowID: []byte{0x3, 0x4}, + }, + "dynamic length example 2": { + srcKey: []byte{0x0, 0x1, 0x2, 0x3, 0x4, 0x3}, + enc: Max255DynamicLengthIndexKeyCodec{}, + expRowID: []byte{0x2, 0x3, 0x4}, + }, + "dynamic length max row ID": { + srcKey: append(append([]byte{0x0, 0x1}, []byte(strings.Repeat("a", 255))...), 0xff), + enc: Max255DynamicLengthIndexKeyCodec{}, + expRowID: []byte(strings.Repeat("a", 255)), + }, + "uint64 example": { + srcKey: []byte{0x0, 0x1, 0x2, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8}, + expRowID: []byte{0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8}, + enc: FixLengthIndexKeys(8), + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + gotRow := spec.enc.StripRowID(spec.srcKey) + assert.Equal(t, spec.expRowID, gotRow) + }) + } +} diff --git a/regen/orm/index_test.go b/regen/orm/index_test.go new file mode 100644 index 0000000000..2becc94f99 --- /dev/null +++ b/regen/orm/index_test.go @@ -0,0 +1,348 @@ +package orm_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/regen/orm" + "github.com/cosmos/cosmos-sdk/regen/orm/testdata" +) + +func TestIndexPrefixScan(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + storeKey := sdk.NewKVStoreKey("test") + const ( + testTablePrefix = iota + testTableSeqPrefix + ) + tBuilder := orm.NewAutoUInt64TableBuilder(testTablePrefix, testTableSeqPrefix, storeKey, &testdata.GroupInfo{}, cdc) + idx := orm.NewIndex(tBuilder, GroupByAdminIndexPrefix, func(val interface{}) ([]orm.RowID, error) { + return []orm.RowID{[]byte(val.(*testdata.GroupInfo).Admin)}, nil + }) + tb := tBuilder.Build() + ctx := orm.NewMockContext() + + g1 := testdata.GroupInfo{ + Description: "my test 1", + Admin: sdk.AccAddress([]byte("admin-address-a")), + } + g2 := testdata.GroupInfo{ + Description: "my test 2", + Admin: sdk.AccAddress([]byte("admin-address-b")), + } + g3 := testdata.GroupInfo{ + Description: "my test 3", + Admin: sdk.AccAddress([]byte("admin-address-b")), + } + for _, g := range []testdata.GroupInfo{g1, g2, g3} { + _, err := tb.Create(ctx, &g) + require.NoError(t, err) + } + + specs := map[string]struct { + start, end []byte + expResult []testdata.GroupInfo + expRowIDs []orm.RowID + expError *errors.Error + method func(ctx orm.HasKVStore, start, end []byte) (orm.Iterator, error) + }{ + "exact match with a single result": { + start: []byte("admin-address-a"), + end: []byte("admin-address-b"), + method: idx.PrefixScan, + expResult: []testdata.GroupInfo{g1}, + expRowIDs: []orm.RowID{orm.EncodeSequence(1)}, + }, + "one result by prefix": { + start: []byte("admin-address"), + end: []byte("admin-address-b"), + method: idx.PrefixScan, + expResult: []testdata.GroupInfo{g1}, + expRowIDs: []orm.RowID{orm.EncodeSequence(1)}, + }, + "multi key elements by exact match": { + start: []byte("admin-address-b"), + end: []byte("admin-address-c"), + method: idx.PrefixScan, + expResult: []testdata.GroupInfo{g2, g3}, + expRowIDs: []orm.RowID{orm.EncodeSequence(2), orm.EncodeSequence(3)}, + }, + "open end query": { + start: []byte("admin-address-b"), + end: nil, + method: idx.PrefixScan, + expResult: []testdata.GroupInfo{g2, g3}, + expRowIDs: []orm.RowID{orm.EncodeSequence(2), orm.EncodeSequence(3)}, + }, + "open start query": { + start: nil, + end: []byte("admin-address-b"), + method: idx.PrefixScan, + expResult: []testdata.GroupInfo{g1}, + expRowIDs: []orm.RowID{orm.EncodeSequence(1)}, + }, + "open start and end query": { + start: nil, + end: nil, + method: idx.PrefixScan, + expResult: []testdata.GroupInfo{g1, g2, g3}, + expRowIDs: []orm.RowID{orm.EncodeSequence(1), orm.EncodeSequence(2), orm.EncodeSequence(3)}, + }, + "all matching prefix": { + start: []byte("admin"), + end: nil, + method: idx.PrefixScan, + expResult: []testdata.GroupInfo{g1, g2, g3}, + expRowIDs: []orm.RowID{orm.EncodeSequence(1), orm.EncodeSequence(2), orm.EncodeSequence(3)}, + }, + "non matching prefix": { + start: []byte("nobody"), + end: nil, + method: idx.PrefixScan, + expResult: []testdata.GroupInfo{}, + }, + "start equals end": { + start: []byte("any"), + end: []byte("any"), + method: idx.PrefixScan, + expError: orm.ErrArgument, + }, + "start after end": { + start: []byte("b"), + end: []byte("a"), + method: idx.PrefixScan, + expError: orm.ErrArgument, + }, + "reverse: exact match with a single result": { + start: []byte("admin-address-a"), + end: []byte("admin-address-b"), + method: idx.ReversePrefixScan, + expResult: []testdata.GroupInfo{g1}, + expRowIDs: []orm.RowID{orm.EncodeSequence(1)}, + }, + "reverse: one result by prefix": { + start: []byte("admin-address"), + end: []byte("admin-address-b"), + method: idx.ReversePrefixScan, + expResult: []testdata.GroupInfo{g1}, + expRowIDs: []orm.RowID{orm.EncodeSequence(1)}, + }, + "reverse: multi key elements by exact match": { + start: []byte("admin-address-b"), + end: []byte("admin-address-c"), + method: idx.ReversePrefixScan, + expResult: []testdata.GroupInfo{g3, g2}, + expRowIDs: []orm.RowID{orm.EncodeSequence(3), orm.EncodeSequence(2)}, + }, + "reverse: open end query": { + start: []byte("admin-address-b"), + end: nil, + method: idx.ReversePrefixScan, + expResult: []testdata.GroupInfo{g3, g2}, + expRowIDs: []orm.RowID{orm.EncodeSequence(3), orm.EncodeSequence(2)}, + }, + "reverse: open start query": { + start: nil, + end: []byte("admin-address-b"), + method: idx.ReversePrefixScan, + expResult: []testdata.GroupInfo{g1}, + expRowIDs: []orm.RowID{orm.EncodeSequence(1)}, + }, + "reverse: open start and end query": { + start: nil, + end: nil, + method: idx.ReversePrefixScan, + expResult: []testdata.GroupInfo{g3, g2, g1}, + expRowIDs: []orm.RowID{orm.EncodeSequence(3), orm.EncodeSequence(2), orm.EncodeSequence(1)}, + }, + "reverse: all matching prefix": { + start: []byte("admin"), + end: nil, + method: idx.ReversePrefixScan, + expResult: []testdata.GroupInfo{g3, g2, g1}, + expRowIDs: []orm.RowID{orm.EncodeSequence(3), orm.EncodeSequence(2), orm.EncodeSequence(1)}, + }, + "reverse: non matching prefix": { + start: []byte("nobody"), + end: nil, + method: idx.ReversePrefixScan, + expResult: []testdata.GroupInfo{}, + }, + "reverse: start equals end": { + start: []byte("any"), + end: []byte("any"), + method: idx.ReversePrefixScan, + expError: orm.ErrArgument, + }, + "reverse: start after end": { + start: []byte("b"), + end: []byte("a"), + method: idx.ReversePrefixScan, + expError: orm.ErrArgument, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + it, err := spec.method(ctx, spec.start, spec.end) + require.True(t, spec.expError.Is(err), "expected #+v but got #+v", spec.expError, err) + if spec.expError != nil { + return + } + var loaded []testdata.GroupInfo + rowIDs, err := orm.ReadAll(it, &loaded) + require.NoError(t, err) + assert.Equal(t, spec.expResult, loaded) + assert.Equal(t, spec.expRowIDs, rowIDs) + }) + } +} + +func TestUniqueIndex(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + storeKey := sdk.NewKVStoreKey("test") + + tableBuilder := orm.NewPrimaryKeyTableBuilder(GroupMemberTablePrefix, storeKey, &testdata.GroupMember{}, orm.Max255DynamicLengthIndexKeyCodec{}, cdc) + uniqueIdx := orm.NewUniqueIndex(tableBuilder, 0x10, func(val interface{}) (orm.RowID, error) { + return []byte{val.(*testdata.GroupMember).Member[0]}, nil + }) + myTable := tableBuilder.Build() + + ctx := orm.NewMockContext() + + m := testdata.GroupMember{ + Group: sdk.AccAddress(orm.EncodeSequence(1)), + Member: sdk.AccAddress([]byte("member-address")), + Weight: 10, + } + err := myTable.Create(ctx, &m) + require.NoError(t, err) + + indexedKey := []byte{byte('m')} + + // Has + assert.True(t, uniqueIdx.Has(ctx, indexedKey)) + + // Get + it, err := uniqueIdx.Get(ctx, indexedKey) + require.NoError(t, err) + var loaded testdata.GroupMember + rowID, err := it.LoadNext(&loaded) + require.NoError(t, err) + require.Equal(t, orm.RowID(orm.PrimaryKey(&m)), rowID) + require.Equal(t, m, loaded) + + // GetPaginated + cases := map[string]struct { + pageReq *query.PageRequest + expErr bool + }{ + "nil key": { + pageReq: &query.PageRequest{Key: nil}, + expErr: false, + }, + "after indexed key": { + pageReq: &query.PageRequest{Key: indexedKey}, + expErr: true, + }, + } + + for testName, tc := range cases { + t.Run(testName, func(t *testing.T) { + it, err := uniqueIdx.GetPaginated(ctx, indexedKey, tc.pageReq) + require.NoError(t, err) + rowID, err := it.LoadNext(&loaded) + if tc.expErr { // iterator done + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, orm.RowID(orm.PrimaryKey(&m)), rowID) + require.Equal(t, m, loaded) + } + }) + } + + // PrefixScan match + it, err = uniqueIdx.PrefixScan(ctx, []byte{byte('m')}, []byte{byte('n')}) + require.NoError(t, err) + rowID, err = it.LoadNext(&loaded) + require.NoError(t, err) + require.Equal(t, orm.RowID(orm.PrimaryKey(&m)), rowID) + require.Equal(t, m, loaded) + + // PrefixScan no match + it, err = uniqueIdx.PrefixScan(ctx, []byte{byte('n')}, nil) + require.NoError(t, err) + rowID, err = it.LoadNext(&loaded) + require.Error(t, orm.ErrIteratorDone, err) + + // ReversePrefixScan match + it, err = uniqueIdx.ReversePrefixScan(ctx, []byte{byte('a')}, []byte{byte('z')}) + require.NoError(t, err) + rowID, err = it.LoadNext(&loaded) + require.NoError(t, err) + require.Equal(t, orm.RowID(orm.PrimaryKey(&m)), rowID) + require.Equal(t, m, loaded) + + // ReversePrefixScan no match + it, err = uniqueIdx.ReversePrefixScan(ctx, []byte{byte('l')}, nil) + require.NoError(t, err) + rowID, err = it.LoadNext(&loaded) + require.Error(t, orm.ErrIteratorDone, err) + // create with same index key should fail + new := testdata.GroupMember{ + Group: sdk.AccAddress(orm.EncodeSequence(1)), + Member: sdk.AccAddress([]byte("my-other")), + Weight: 10, + } + err = myTable.Create(ctx, &new) + require.Error(t, orm.ErrUniqueConstraint, err) + + // and when delete + err = myTable.Delete(ctx, &m) + require.NoError(t, err) + + // then no persistent element + assert.False(t, uniqueIdx.Has(ctx, indexedKey)) +} + +func TestPrefixRange(t *testing.T) { + cases := map[string]struct { + src []byte + expStart []byte + expEnd []byte + expPanic bool + }{ + "normal": {src: []byte{1, 3, 4}, expStart: []byte{1, 3, 4}, expEnd: []byte{1, 3, 5}}, + "normal short": {src: []byte{79}, expStart: []byte{79}, expEnd: []byte{80}}, + "empty case": {src: []byte{}}, + "roll-over example 1": {src: []byte{17, 28, 255}, expStart: []byte{17, 28, 255}, expEnd: []byte{17, 29, 0}}, + "roll-over example 2": {src: []byte{15, 42, 255, 255}, expStart: []byte{15, 42, 255, 255}, expEnd: []byte{15, 43, 0, 0}}, + "pathological roll-over": {src: []byte{255, 255, 255, 255}, expStart: []byte{255, 255, 255, 255}}, + "nil prohibited": {expPanic: true}, + } + + for testName, tc := range cases { + t.Run(testName, func(t *testing.T) { + if tc.expPanic { + require.Panics(t, func() { + orm.PrefixRange(tc.src) + }) + return + } + start, end := orm.PrefixRange(tc.src) + assert.Equal(t, tc.expStart, start) + assert.Equal(t, tc.expEnd, end) + }) + } +} diff --git a/regen/orm/indexer.go b/regen/orm/indexer.go new file mode 100644 index 0000000000..b02307b353 --- /dev/null +++ b/regen/orm/indexer.go @@ -0,0 +1,158 @@ +package orm + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" +) + +// IndexerFunc creates one or multiple index keys for the source object. +type IndexerFunc func(value interface{}) ([]RowID, error) + +// IndexerFunc creates exactly one index key for the source object. +type UniqueIndexerFunc func(value interface{}) (RowID, error) + +// Indexer manages the persistence for an Index based on searchable keys and operations. +type Indexer struct { + indexerFunc IndexerFunc + addFunc func(store sdk.KVStore, codec IndexKeyCodec, secondaryIndexKey []byte, rowID RowID) error + indexKeyCodec IndexKeyCodec +} + +// NewIndexer returns an indexer that supports multiple reference keys for an entity. +func NewIndexer(indexerFunc IndexerFunc, codec IndexKeyCodec) *Indexer { + if indexerFunc == nil { + panic("Indexer func must not be nil") + } + if codec == nil { + panic("IndexKeyCodec must not be nil") + } + return &Indexer{ + indexerFunc: pruneEmptyKeys(indexerFunc), + addFunc: multiKeyAddFunc, + indexKeyCodec: codec, + } +} + +// NewUniqueIndexer returns an indexer that requires exactly one reference keys for an entity. +func NewUniqueIndexer(f UniqueIndexerFunc, codec IndexKeyCodec) *Indexer { + if f == nil { + panic("indexer func must not be nil") + } + adaptor := func(indexerFunc UniqueIndexerFunc) IndexerFunc { + return func(v interface{}) ([]RowID, error) { + k, err := indexerFunc(v) + return []RowID{k}, err + } + } + idx := NewIndexer(adaptor(f), codec) + idx.addFunc = uniqueKeysAddFunc + return idx +} + +// OnCreate persists the secondary index entries for the new object. +func (i Indexer) OnCreate(store sdk.KVStore, rowID RowID, value interface{}) error { + secondaryIndexKeys, err := i.indexerFunc(value) + if err != nil { + return err + } + + for _, secondaryIndexKey := range secondaryIndexKeys { + if err := i.addFunc(store, i.indexKeyCodec, secondaryIndexKey, rowID); err != nil { + return err + } + } + return nil +} + +// OnDelete removes the secondary index entries for the deleted object. +func (i Indexer) OnDelete(store sdk.KVStore, rowID RowID, value interface{}) error { + secondaryIndexKeys, err := i.indexerFunc(value) + if err != nil { + return err + } + + for _, secondaryIndexKey := range secondaryIndexKeys { + indexKey := i.indexKeyCodec.BuildIndexKey(secondaryIndexKey, rowID) + store.Delete(indexKey) + } + return nil +} + +// OnUpdate rebuilds the secondary index entries for the updated object. +func (i Indexer) OnUpdate(store sdk.KVStore, rowID RowID, newValue, oldValue interface{}) error { + oldSecIdxKeys, err := i.indexerFunc(oldValue) + if err != nil { + return err + } + newSecIdxKeys, err := i.indexerFunc(newValue) + if err != nil { + return err + } + for _, oldIdxKey := range difference(oldSecIdxKeys, newSecIdxKeys) { + store.Delete(i.indexKeyCodec.BuildIndexKey(oldIdxKey, rowID)) + } + for _, newIdxKey := range difference(newSecIdxKeys, oldSecIdxKeys) { + if err := i.addFunc(store, i.indexKeyCodec, newIdxKey, rowID); err != nil { + return err + } + } + return nil +} + +// uniqueKeysAddFunc enforces keys to be unique +func uniqueKeysAddFunc(store sdk.KVStore, codec IndexKeyCodec, secondaryIndexKey []byte, rowID RowID) error { + if len(secondaryIndexKey) == 0 { + return errors.Wrap(ErrArgument, "empty index key") + } + it := store.Iterator(PrefixRange(secondaryIndexKey)) + defer it.Close() + if it.Valid() { + return ErrUniqueConstraint + } + indexKey := codec.BuildIndexKey(secondaryIndexKey, rowID) + store.Set(indexKey, []byte{}) + return nil +} + +// multiKeyAddFunc allows multiple entries for a key +func multiKeyAddFunc(store sdk.KVStore, codec IndexKeyCodec, secondaryIndexKey []byte, rowID RowID) error { + if len(secondaryIndexKey) == 0 { + return errors.Wrap(ErrArgument, "empty index key") + } + + indexKey := codec.BuildIndexKey(secondaryIndexKey, rowID) + store.Set(indexKey, []byte{}) + return nil +} + +// difference returns the list of elements that are in a but not in b. +func difference(a []RowID, b []RowID) []RowID { + set := make(map[string]struct{}, len(b)) + for _, v := range b { + set[string(v)] = struct{}{} + } + var result []RowID + for _, v := range a { + if _, ok := set[string(v)]; !ok { + result = append(result, v) + } + } + return result +} + +// pruneEmptyKeys drops any empty key from IndexerFunc f returned +func pruneEmptyKeys(f IndexerFunc) IndexerFunc { + return func(v interface{}) ([]RowID, error) { + keys, err := f(v) + if err != nil || keys == nil { + return keys, err + } + r := make([]RowID, 0, len(keys)) + for i := range keys { + if len(keys[i]) != 0 { + r = append(r, keys[i]) + } + } + return r, nil + } +} diff --git a/regen/orm/indexer_test.go b/regen/orm/indexer_test.go new file mode 100644 index 0000000000..05843181e2 --- /dev/null +++ b/regen/orm/indexer_test.go @@ -0,0 +1,527 @@ +package orm + +import ( + stdErrors "errors" + "testing" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestIndexerOnCreate(t *testing.T) { + var myRowID RowID = EncodeSequence(1) + + specs := map[string]struct { + srcFunc IndexerFunc + expIndexKeys []RowID + expRowIDs []RowID + expAddFuncCalled bool + expErr error + }{ + "single key": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{{0, 0, 0, 0, 0, 0, 0, 1}}, nil + }, + expAddFuncCalled: true, + expIndexKeys: []RowID{{0, 0, 0, 0, 0, 0, 0, 1}}, + expRowIDs: []RowID{myRowID}, + }, + "multi key": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{{0, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 0}}, nil + }, + expAddFuncCalled: true, + expIndexKeys: []RowID{{0, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 0}}, + expRowIDs: []RowID{myRowID, myRowID}, + }, + "empty key in slice": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{{}}, nil + }, + expAddFuncCalled: false, + }, + "nil key in slice": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{nil}, nil + }, + expAddFuncCalled: false, + }, + "empty key": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{}, nil + }, + expAddFuncCalled: false, + }, + "nil key": { + srcFunc: func(value interface{}) ([]RowID, error) { + return nil, nil + }, + expAddFuncCalled: false, + }, + "error case": { + srcFunc: func(value interface{}) ([]RowID, error) { + return nil, stdErrors.New("test") + }, + expErr: stdErrors.New("test"), + expAddFuncCalled: false, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + mockPolicy := &addFuncRecorder{} + idx := NewIndexer(spec.srcFunc, Max255DynamicLengthIndexKeyCodec{}) + idx.addFunc = mockPolicy.add + + err := idx.OnCreate(nil, myRowID, nil) + if spec.expErr != nil { + require.Equal(t, spec.expErr, err) + return + } + require.NoError(t, err) + assert.Equal(t, spec.expIndexKeys, mockPolicy.secondaryIndexKeys) + assert.Equal(t, spec.expRowIDs, mockPolicy.rowIDs) + assert.Equal(t, spec.expAddFuncCalled, mockPolicy.called) + }) + } +} + +func TestIndexerOnDelete(t *testing.T) { + myRowID := EncodeSequence(1) + + var multiKeyIndex MultiKeyIndex + ctx := NewMockContext() + storeKey := sdk.NewKVStoreKey("test") + store := prefix.NewStore(ctx.KVStore(storeKey), []byte{multiKeyIndex.prefix}) + + specs := map[string]struct { + srcFunc IndexerFunc + expIndexKeys []RowID + expErr error + }{ + "single key": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{{0, 0, 0, 0, 0, 0, 0, 1}}, nil + }, + expIndexKeys: []RowID{append([]byte{0, 0, 0, 0, 0, 0, 0, 1}, myRowID...)}, + }, + "multi key": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{{0, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 0}}, nil + }, + expIndexKeys: []RowID{ + append([]byte{0, 0, 0, 0, 0, 0, 0, 1}, myRowID...), + append([]byte{1, 0, 0, 0, 0, 0, 0, 0}, myRowID...), + }, + }, + "empty key": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{}, nil + }, + }, + "nil key": { + srcFunc: func(value interface{}) ([]RowID, error) { + return nil, nil + }, + }, + "empty key in slice": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{{}}, nil + }, + }, + "nil key in slice": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{nil}, nil + }, + }, + "error case": { + srcFunc: func(value interface{}) ([]RowID, error) { + return nil, stdErrors.New("test") + }, + expErr: stdErrors.New("test"), + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + codec := FixLengthIndexKeys(EncodedSeqLength) + idx := NewIndexer(spec.srcFunc, codec) + err := idx.OnDelete(store, myRowID, nil) + if spec.expErr != nil { + require.Equal(t, spec.expErr, err) + return + } + require.NoError(t, err) + }) + } +} + +func TestIndexerOnUpdate(t *testing.T) { + myRowID := EncodeSequence(1) + codec := FixLengthIndexKeys(EncodedSeqLength) + + var multiKeyIndex MultiKeyIndex + ctx := NewMockContext() + storeKey := sdk.NewKVStoreKey("test") + store := prefix.NewStore(ctx.KVStore(storeKey), []byte{multiKeyIndex.prefix}) + + specs := map[string]struct { + srcFunc IndexerFunc + mockStore *updateKVStoreRecorder + expAddedKeys []RowID + expDeletedKeys []RowID + expErr error + addFunc func(sdk.KVStore, IndexKeyCodec, []byte, RowID) error + }{ + "single key - same key, no update": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{EncodeSequence(1)}, nil + }, + }, + "single key - different key, replaced": { + srcFunc: func(value interface{}) ([]RowID, error) { + keys := []RowID{EncodeSequence(1), EncodeSequence(2)} + return []RowID{keys[value.(int)]}, nil + }, + expAddedKeys: []RowID{ + append(EncodeSequence(2), myRowID...), + }, + expDeletedKeys: []RowID{ + append(EncodeSequence(1), myRowID...), + }, + }, + "multi key - same key, no update": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{EncodeSequence(1), EncodeSequence(2)}, nil + }, + }, + "multi key - replaced": { + srcFunc: func(value interface{}) ([]RowID, error) { + keys := []RowID{EncodeSequence(1), EncodeSequence(2), EncodeSequence(3), EncodeSequence(4)} + return []RowID{keys[value.(int)], keys[value.(int)+2]}, nil + }, + expAddedKeys: []RowID{ + append(EncodeSequence(2), myRowID...), + append(EncodeSequence(4), myRowID...), + }, + expDeletedKeys: []RowID{ + append(EncodeSequence(1), myRowID...), + append(EncodeSequence(3), myRowID...), + }, + }, + "empty key": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{}, nil + }, + }, + "nil key": { + srcFunc: func(value interface{}) ([]RowID, error) { + return nil, nil + }, + }, + "empty key in slice": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{{}}, nil + }, + }, + "nil key in slice": { + srcFunc: func(value interface{}) ([]RowID, error) { + return []RowID{nil}, nil + }, + }, + "error case with new value": { + srcFunc: func(value interface{}) ([]RowID, error) { + return nil, stdErrors.New("test") + }, + expErr: stdErrors.New("test"), + }, + "error case with old value": { + srcFunc: func(value interface{}) ([]RowID, error) { + var err error + if value.(int)%2 == 1 { + err = stdErrors.New("test") + } + return []RowID{myRowID}, err + }, + expErr: stdErrors.New("test"), + }, + "error case on persisting new keys": { + srcFunc: func(value interface{}) ([]RowID, error) { + keys := []RowID{EncodeSequence(1), EncodeSequence(2)} + return []RowID{keys[value.(int)]}, nil + }, + addFunc: func(_ sdk.KVStore, _ IndexKeyCodec, _ []byte, _ RowID) error { + return stdErrors.New("test") + }, + expErr: stdErrors.New("test"), + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + idx := NewIndexer(spec.srcFunc, codec) + if spec.addFunc != nil { + idx.addFunc = spec.addFunc + } + err := idx.OnUpdate(store, myRowID, 1, 0) + if spec.expErr != nil { + require.Equal(t, spec.expErr, err) + return + } + require.NoError(t, err) + + }) + } +} + +func TestUniqueKeyAddFunc(t *testing.T) { + myRowID := EncodeSequence(1) + myPresetKey := append([]byte("my-preset-key"), myRowID...) + + specs := map[string]struct { + srcKey []byte + expErr *errors.Error + expExistingEntry []byte + }{ + + "create when not exists": { + srcKey: []byte("my-index-key"), + expExistingEntry: append([]byte("my-index-key"), myRowID...), + }, + "error when exists already": { + srcKey: []byte("my-preset-key"), + expErr: ErrUniqueConstraint, + }, + "nil key not allowed": { + srcKey: nil, + expErr: ErrArgument, + }, + "empty key not allowed": { + srcKey: []byte{}, + expErr: ErrArgument, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + storeKey := sdk.NewKVStoreKey("test") + store := NewMockContext().KVStore(storeKey) + store.Set(myPresetKey, []byte{}) + + codec := FixLengthIndexKeys(EncodedSeqLength) + err := uniqueKeysAddFunc(store, codec, spec.srcKey, myRowID) + require.True(t, spec.expErr.Is(err)) + if spec.expErr != nil { + return + } + assert.True(t, store.Has(spec.expExistingEntry), "not found") + }) + } +} + +func TestMultiKeyAddFunc(t *testing.T) { + myRowID := EncodeSequence(1) + myPresetKey := append([]byte("my-preset-key"), myRowID...) + + specs := map[string]struct { + srcKey []byte + expErr *errors.Error + expExistingEntry []byte + }{ + + "create when not exists": { + srcKey: []byte("my-index-key"), + expExistingEntry: append([]byte("my-index-key"), myRowID...), + }, + "noop when exists already": { + srcKey: []byte("my-preset-key"), + expExistingEntry: myPresetKey, + }, + "nil key not allowed": { + srcKey: nil, + expErr: ErrArgument, + }, + "empty key not allowed": { + srcKey: []byte{}, + expErr: ErrArgument, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + storeKey := sdk.NewKVStoreKey("test") + store := NewMockContext().KVStore(storeKey) + store.Set(myPresetKey, []byte{}) + + codec := FixLengthIndexKeys(EncodedSeqLength) + err := multiKeyAddFunc(store, codec, spec.srcKey, myRowID) + require.True(t, spec.expErr.Is(err)) + if spec.expErr != nil { + return + } + assert.True(t, store.Has(spec.expExistingEntry)) + }) + } +} + +func TestDifference(t *testing.T) { + asByte := func(s []string) []RowID { + r := make([]RowID, len(s)) + for i := 0; i < len(s); i++ { + r[i] = []byte(s[i]) + } + return r + } + + specs := map[string]struct { + srcA []string + srcB []string + expResult []RowID + }{ + "all of A": { + srcA: []string{"a", "b"}, + srcB: []string{"c"}, + expResult: []RowID{[]byte("a"), []byte("b")}, + }, + "A - B": { + srcA: []string{"a", "b"}, + srcB: []string{"b", "c", "d"}, + expResult: []RowID{[]byte("a")}, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + got := difference(asByte(spec.srcA), asByte(spec.srcB)) + assert.Equal(t, spec.expResult, got) + }) + } +} + +func TestPruneEmptyKeys(t *testing.T) { + specs := map[string]struct { + srcFunc IndexerFunc + expResult []RowID + expError error + }{ + "non empty": { + srcFunc: func(v interface{}) ([]RowID, error) { + return []RowID{{0}, {1}}, nil + }, + expResult: []RowID{{0}, {1}}, + }, + "empty": { + srcFunc: func(v interface{}) ([]RowID, error) { + return []RowID{}, nil + }, + expResult: []RowID{}, + }, + "nil": { + srcFunc: func(v interface{}) ([]RowID, error) { + return nil, nil + }, + }, + "nil in the beginning": { + srcFunc: func(v interface{}) ([]RowID, error) { + return []RowID{nil, {0}, {1}}, nil + }, + expResult: []RowID{{0}, {1}}, + }, + "nil in the middle": { + srcFunc: func(v interface{}) ([]RowID, error) { + return []RowID{{0}, nil, {1}}, nil + }, + expResult: []RowID{{0}, {1}}, + }, + "nil at the end": { + srcFunc: func(v interface{}) ([]RowID, error) { + return []RowID{{0}, nil, {1}}, nil + }, + expResult: []RowID{{0}, {1}}, + }, + "empty in the beginning": { + srcFunc: func(v interface{}) ([]RowID, error) { + return []RowID{{}, {0}, {1}}, nil + }, + expResult: []RowID{{0}, {1}}, + }, + "empty in the middle": { + srcFunc: func(v interface{}) ([]RowID, error) { + return []RowID{{0}, {}, {1}}, nil + }, + expResult: []RowID{{0}, {1}}, + }, + "empty at the end": { + srcFunc: func(v interface{}) ([]RowID, error) { + return []RowID{{0}, {}, {1}}, nil + }, + expResult: []RowID{{0}, {1}}, + }, + "error passed": { + srcFunc: func(v interface{}) ([]RowID, error) { + return nil, stdErrors.New("test") + }, + expError: stdErrors.New("test"), + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + r, err := pruneEmptyKeys(spec.srcFunc)(nil) + require.Equal(t, spec.expError, err) + if spec.expError != nil { + return + } + assert.Equal(t, spec.expResult, r) + }) + } +} + +type addFuncRecorder struct { + secondaryIndexKeys []RowID + rowIDs []RowID + called bool +} + +func (c *addFuncRecorder) add(_ sdk.KVStore, _ IndexKeyCodec, key []byte, rowID RowID) error { + c.secondaryIndexKeys = append(c.secondaryIndexKeys, key) + c.rowIDs = append(c.rowIDs, rowID) + c.called = true + return nil +} + +type deleteKVStoreRecorder struct { + AlwaysPanicKVStore + deletes []RowID +} + +func (m *deleteKVStoreRecorder) Delete(key []byte) { + m.deletes = append(m.deletes, key) +} + +type updateKVStoreRecorder struct { + deleteKVStoreRecorder + stored tuples + hasResult bool +} + +func (u *updateKVStoreRecorder) Set(key, value []byte) { + u.stored = append(u.stored, tuple{key, value}) +} + +func (u updateKVStoreRecorder) Has(key []byte) bool { + return u.hasResult +} + +type tuple struct { + key, val []byte +} + +type tuples []tuple + +func (t tuples) Keys() []RowID { + if t == nil { + return nil + } + r := make([]RowID, len(t)) + for i, v := range t { + r[i] = v.key + } + return r +} diff --git a/regen/orm/iterator.go b/regen/orm/iterator.go new file mode 100644 index 0000000000..234cb39791 --- /dev/null +++ b/regen/orm/iterator.go @@ -0,0 +1,304 @@ +package orm + +import ( + "fmt" + "reflect" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/query" +) + +// IteratorFunc is a function type that satisfies the Iterator interface +// The passed function is called on LoadNext operations. +type IteratorFunc func(dest codec.ProtoMarshaler) (RowID, error) + +// LoadNext loads the next value in the sequence into the pointer passed as dest and returns the key. If there +// are no more items the ErrIteratorDone error is returned +// The key is the rowID and not any MultiKeyIndex key. +func (i IteratorFunc) LoadNext(dest codec.ProtoMarshaler) (RowID, error) { + return i(dest) +} + +// Close always returns nil +func (i IteratorFunc) Close() error { + return nil +} + +func NewSingleValueIterator(rowID RowID, val []byte) Iterator { + var closed bool + return IteratorFunc(func(dest codec.ProtoMarshaler) (RowID, error) { + if dest == nil { + return nil, errors.Wrap(ErrArgument, "destination object must not be nil") + } + if closed || val == nil { + return nil, ErrIteratorDone + } + closed = true + return rowID, dest.Unmarshal(val) + }) +} + +// Iterator that return ErrIteratorInvalid only. +func NewInvalidIterator() Iterator { + return IteratorFunc(func(dest codec.ProtoMarshaler) (RowID, error) { + return nil, ErrIteratorInvalid + }) +} + +// LimitedIterator returns up to defined maximum number of elements. +type LimitedIterator struct { + remainingCount int + parentIterator Iterator +} + +// LimitIterator returns a new iterator that returns max number of elements. +// The parent iterator must not be nil +// max can be 0 or any positive number +func LimitIterator(parent Iterator, max int) *LimitedIterator { + if max < 0 { + panic("quantity must not be negative") + } + if parent == nil { + panic("parent iterator must not be nil") + } + return &LimitedIterator{remainingCount: max, parentIterator: parent} +} + +// LoadNext loads the next value in the sequence into the pointer passed as dest and returns the key. If there +// are no more items or the defined max number of elements was returned the `ErrIteratorDone` error is returned +// The key is the rowID and not any MultiKeyIndex key. +func (i *LimitedIterator) LoadNext(dest codec.ProtoMarshaler) (RowID, error) { + if i.remainingCount == 0 { + return nil, ErrIteratorDone + } + i.remainingCount-- + return i.parentIterator.LoadNext(dest) +} + +// Close releases the iterator and should be called at the end of iteration +func (i LimitedIterator) Close() error { + return i.parentIterator.Close() +} + +// First loads the first element into the given destination type and closes the iterator. +// When the iterator is closed or has no elements the according error is passed as return value. +func First(it Iterator, dest codec.ProtoMarshaler) (RowID, error) { + if it == nil { + return nil, errors.Wrap(ErrArgument, "iterator must not be nil") + } + defer it.Close() + binKey, err := it.LoadNext(dest) + if err != nil { + return nil, err + } + return binKey, nil +} + +// Paginate does pagination with a given Iterator based on the provided +// PageRequest and unmarshals the results into the dest interface that must be +// an non-nil pointer to a slice. +// +// If pageRequest is nil, then we will use these default values: +// - Offset: 0 +// - Key: nil +// - Limit: 100 +// - CountTotal: true +// +// If pageRequest.Key was provided, it got used beforehand to instantiate the Iterator, +// using for instance UInt64Index.GetPaginated method. Only one of pageRequest.Offset or +// pageRequest.Key should be set. Using pageRequest.Key is more efficient for querying +// the next page. +// +// If pageRequest.CountTotal is set, we'll visit all iterators elements. +// pageRequest.CountTotal is only respected when offset is used. +// +// This function will call it.Close(). +func Paginate( + it Iterator, + pageRequest *query.PageRequest, + dest ModelSlicePtr, +) (*query.PageResponse, error) { + // if the PageRequest is nil, use default PageRequest + if pageRequest == nil { + pageRequest = &query.PageRequest{} + } + + offset := pageRequest.Offset + key := pageRequest.Key + limit := pageRequest.Limit + countTotal := pageRequest.CountTotal + + if offset > 0 && key != nil { + return nil, fmt.Errorf("invalid request, either offset or key is expected, got both") + } + + if limit == 0 { + limit = 100 + + // count total results when the limit is zero/not supplied + countTotal = true + } + + if it == nil { + return nil, errors.Wrap(ErrArgument, "iterator must not be nil") + } + defer it.Close() + + var destRef, tmpSlice reflect.Value + elemType, err := assertDest(dest, &destRef, &tmpSlice) + if err != nil { + return nil, err + } + + var end = offset + limit + var count uint64 + var nextKey []byte + for { + obj := reflect.New(elemType) + val := obj.Elem() + model := obj + if elemType.Kind() == reflect.Ptr { + val.Set(reflect.New(elemType.Elem())) + // if elemType is already a pointer (e.g. dest being some pointer to a slice of pointers, + // like []*GroupMember), then obj is a pointer to a pointer which might cause issues + // if we try to do obj.Interface().(codec.ProtoMarshaler). + // For that reason, we copy obj into model if we have a simple pointer + // but in case elemType.Kind() == reflect.Ptr, we overwrite it with model = val + // so we can safely call model.Interface().(codec.ProtoMarshaler) afterwards. + model = val + } + + modelProto, ok := model.Interface().(codec.ProtoMarshaler) + if !ok { + return nil, errors.Wrapf(ErrArgument, "%s should implement codec.ProtoMarshaler", elemType) + } + binKey, err := it.LoadNext(modelProto) + if err != nil { + if ErrIteratorDone.Is(err) { + break + } + return nil, err + } + + count++ + + // During the first loop, count value at this point will be 1, + // so if offset is >= 1, it will continue to load the next value until count > offset + // else (offset = 0, key might be set or not), + // it will start to append values to tmpSlice. + if count <= offset { + continue + } + + if count <= end { + tmpSlice = reflect.Append(tmpSlice, val) + } else if count == end+1 { + nextKey = binKey + + // countTotal is set to true to indicate that the result set should include + // a count of the total number of items available for pagination in UIs. + // countTotal is only respected when offset is used. It is ignored when key + // is set. + if !countTotal || len(key) != 0 { + break + } + } + } + destRef.Set(tmpSlice) + + res := &query.PageResponse{NextKey: nextKey} + if countTotal && len(key) == 0 { + res.Total = count + } + + return res, nil +} + +// ModelSlicePtr represents a pointer to a slice of models. Think of it as +// *[]Model Because of Go's type system, using []Model type would not work for us. +// Instead we use a placeholder type and the validation is done during the +// runtime. +type ModelSlicePtr interface{} + +// ReadAll consumes all values for the iterator and stores them in a new slice at the passed ModelSlicePtr. +// The slice can be empty when the iterator does not return any values but not nil. The iterator +// is closed afterwards. +// Example: +// var loaded []testdata.GroupInfo +// rowIDs, err := ReadAll(it, &loaded) +// require.NoError(t, err) +// +func ReadAll(it Iterator, dest ModelSlicePtr) ([]RowID, error) { + if it == nil { + return nil, errors.Wrap(ErrArgument, "iterator must not be nil") + } + defer it.Close() + + var destRef, tmpSlice reflect.Value + elemType, err := assertDest(dest, &destRef, &tmpSlice) + if err != nil { + return nil, err + } + + var rowIDs []RowID + for { + obj := reflect.New(elemType) + val := obj.Elem() + model := obj + if elemType.Kind() == reflect.Ptr { + val.Set(reflect.New(elemType.Elem())) + model = val + } + + binKey, err := it.LoadNext(model.Interface().(codec.ProtoMarshaler)) + switch { + case err == nil: + tmpSlice = reflect.Append(tmpSlice, val) + case ErrIteratorDone.Is(err): + destRef.Set(tmpSlice) + return rowIDs, nil + default: + return nil, err + } + rowIDs = append(rowIDs, binKey) + } +} + +// assertDest checks that the provided dest is not nil and a pointer to a slice. +// It also verifies that the slice elements implement *codec.ProtoMarshaler. +// It overwrites destRef and tmpSlice using reflection. +func assertDest(dest ModelSlicePtr, destRef *reflect.Value, tmpSlice *reflect.Value) (reflect.Type, error) { + if dest == nil { + return nil, errors.Wrap(ErrArgument, "destination must not be nil") + } + tp := reflect.ValueOf(dest) + if tp.Kind() != reflect.Ptr { + return nil, errors.Wrap(ErrArgument, "destination must be a pointer to a slice") + } + if tp.Elem().Kind() != reflect.Slice { + return nil, errors.Wrap(ErrArgument, "destination must point to a slice") + } + + // Since dest is just an interface{}, we overwrite destRef using reflection + // to have an assignable copy of it. + *destRef = tp.Elem() + // We need to verify that we can call Set() on destRef. + if !destRef.CanSet() { + return nil, errors.Wrap(ErrArgument, "destination not assignable") + } + + elemType := reflect.TypeOf(dest).Elem().Elem() + + protoMarshaler := reflect.TypeOf((*codec.ProtoMarshaler)(nil)).Elem() + if !elemType.Implements(protoMarshaler) && + !reflect.PtrTo(elemType).Implements(protoMarshaler) { + return nil, errors.Wrapf(ErrArgument, "unsupported type :%s", elemType) + } + + // tmpSlice is a slice value for the specified type + // that we'll use for appending new elements. + *tmpSlice = reflect.MakeSlice(reflect.SliceOf(elemType), 0, 0) + + return elemType, nil +} diff --git a/regen/orm/iterator_test.go b/regen/orm/iterator_test.go new file mode 100644 index 0000000000..cfd2372b39 --- /dev/null +++ b/regen/orm/iterator_test.go @@ -0,0 +1,263 @@ +package orm_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/regen/orm" + "github.com/cosmos/cosmos-sdk/regen/orm/testdata" +) + +func TestReadAll(t *testing.T) { + specs := map[string]struct { + srcIT orm.Iterator + destSlice func() orm.ModelSlicePtr + expErr *errors.Error + expIDs []orm.RowID + expResult orm.ModelSlicePtr + }{ + "all good with object slice": { + srcIT: mockIter(orm.EncodeSequence(1), &testdata.GroupInfo{Description: "test"}), + destSlice: func() orm.ModelSlicePtr { + x := make([]testdata.GroupInfo, 1) + return &x + }, + expIDs: []orm.RowID{orm.EncodeSequence(1)}, + expResult: &[]testdata.GroupInfo{{Description: "test"}}, + }, + "all good with pointer slice": { + srcIT: mockIter(orm.EncodeSequence(1), &testdata.GroupInfo{Description: "test"}), + destSlice: func() orm.ModelSlicePtr { + x := make([]*testdata.GroupInfo, 1) + return &x + }, + expIDs: []orm.RowID{orm.EncodeSequence(1)}, + expResult: &[]*testdata.GroupInfo{{Description: "test"}}, + }, + "dest slice empty": { + srcIT: mockIter(orm.EncodeSequence(1), &testdata.GroupInfo{}), + destSlice: func() orm.ModelSlicePtr { + x := make([]testdata.GroupInfo, 0) + return &x + }, + expIDs: []orm.RowID{orm.EncodeSequence(1)}, + expResult: &[]testdata.GroupInfo{{}}, + }, + "dest pointer with nil value": { + srcIT: mockIter(orm.EncodeSequence(1), &testdata.GroupInfo{}), + destSlice: func() orm.ModelSlicePtr { + return (*[]testdata.GroupInfo)(nil) + }, + expErr: orm.ErrArgument, + }, + "iterator is nil": { + srcIT: nil, + destSlice: func() orm.ModelSlicePtr { return new([]testdata.GroupInfo) }, + expErr: orm.ErrArgument, + }, + "dest slice is nil": { + srcIT: noopIter(), + destSlice: func() orm.ModelSlicePtr { return nil }, + expErr: orm.ErrArgument, + }, + "dest slice is not a pointer": { + srcIT: orm.IteratorFunc(nil), + destSlice: func() orm.ModelSlicePtr { return make([]testdata.GroupInfo, 1) }, + expErr: orm.ErrArgument, + }, + "error on loadNext is returned": { + srcIT: orm.NewInvalidIterator(), + destSlice: func() orm.ModelSlicePtr { + x := make([]testdata.GroupInfo, 1) + return &x + }, + expErr: orm.ErrIteratorInvalid, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + loaded := spec.destSlice() + ids, err := orm.ReadAll(spec.srcIT, loaded) + require.True(t, spec.expErr.Is(err), "expected %s but got %s", spec.expErr, err) + assert.Equal(t, spec.expIDs, ids) + if err == nil { + assert.Equal(t, spec.expResult, loaded) + } + }) + } +} + +func TestLimitedIterator(t *testing.T) { + specs := map[string]struct { + src orm.Iterator + exp []testdata.GroupInfo + }{ + "all from range with max > length": { + src: orm.LimitIterator(mockIter(orm.EncodeSequence(1), &testdata.GroupInfo{Description: "test"}), 2), + exp: []testdata.GroupInfo{{Description: "test"}}, + }, + "up to max": { + src: orm.LimitIterator(mockIter(orm.EncodeSequence(1), &testdata.GroupInfo{Description: "test"}), 1), + exp: []testdata.GroupInfo{{Description: "test"}}, + }, + "none when max = 0": { + src: orm.LimitIterator(mockIter(orm.EncodeSequence(1), &testdata.GroupInfo{Description: "test"}), 0), + exp: []testdata.GroupInfo{}, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + var loaded []testdata.GroupInfo + _, err := orm.ReadAll(spec.src, &loaded) + require.NoError(t, err) + assert.EqualValues(t, spec.exp, loaded) + }) + } +} + +func TestPaginate(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + storeKey := sdk.NewKVStoreKey("test") + const ( + testTablePrefix = iota + testTableSeqPrefix + ) + tBuilder := orm.NewAutoUInt64TableBuilder(testTablePrefix, testTableSeqPrefix, storeKey, &testdata.GroupInfo{}, cdc) + idx := orm.NewIndex(tBuilder, GroupByAdminIndexPrefix, func(val interface{}) ([]orm.RowID, error) { + return []orm.RowID{[]byte(val.(*testdata.GroupInfo).Admin)}, nil + }) + tb := tBuilder.Build() + ctx := orm.NewMockContext() + + admin := sdk.AccAddress([]byte("admin-address")) + g1 := testdata.GroupInfo{ + Description: "my test 1", + Admin: admin, + } + g2 := testdata.GroupInfo{ + Description: "my test 2", + Admin: admin, + } + g3 := testdata.GroupInfo{ + Description: "my test 3", + Admin: sdk.AccAddress([]byte("other-admin-address")), + } + g4 := testdata.GroupInfo{ + Description: "my test 4", + Admin: admin, + } + g5 := testdata.GroupInfo{ + Description: "my test 5", + Admin: sdk.AccAddress([]byte("other-admin-address")), + } + + for _, g := range []testdata.GroupInfo{g1, g2, g3, g4, g5} { + _, err := tb.Create(ctx, &g) + require.NoError(t, err) + } + + specs := map[string]struct { + pageReq *query.PageRequest + expPageRes *query.PageResponse + exp []testdata.GroupInfo + key []byte + expErr bool + }{ + "one item": { + pageReq: &query.PageRequest{Key: nil, Limit: 1}, + exp: []testdata.GroupInfo{g1}, + expPageRes: &query.PageResponse{Total: 0, NextKey: orm.EncodeSequence(2)}, + key: admin, + }, + "with both key and offset": { + pageReq: &query.PageRequest{Key: orm.EncodeSequence(2), Offset: 1}, + expErr: true, + key: admin, + }, + "up to max": { + pageReq: &query.PageRequest{Key: nil, Limit: 3, CountTotal: true}, + exp: []testdata.GroupInfo{g1, g2, g4}, + expPageRes: &query.PageResponse{Total: 3, NextKey: nil}, + key: admin, + }, + "no results": { + pageReq: &query.PageRequest{Key: nil, Limit: 2, CountTotal: true}, + exp: []testdata.GroupInfo{}, + expPageRes: &query.PageResponse{Total: 0, NextKey: nil}, + key: sdk.AccAddress([]byte("no-group-address")), + }, + "with offset and count total": { + pageReq: &query.PageRequest{Key: nil, Offset: 1, Limit: 2, CountTotal: true}, + exp: []testdata.GroupInfo{g2, g4}, + expPageRes: &query.PageResponse{Total: 3, NextKey: nil}, + key: admin, + }, + "nil/default page req (limit = 100 > number of items)": { + pageReq: nil, + exp: []testdata.GroupInfo{g1, g2, g4}, + expPageRes: &query.PageResponse{Total: 3, NextKey: nil}, + key: admin, + }, + "with key and limit < number of elem (count total is ignored in this case)": { + pageReq: &query.PageRequest{Key: orm.EncodeSequence(2), Limit: 1, CountTotal: true}, + exp: []testdata.GroupInfo{g2}, + expPageRes: &query.PageResponse{Total: 0, NextKey: orm.EncodeSequence(4)}, + key: admin, + }, + "with key and limit >= number of elem": { + pageReq: &query.PageRequest{Key: orm.EncodeSequence(2), Limit: 2}, + exp: []testdata.GroupInfo{g2, g4}, + expPageRes: &query.PageResponse{Total: 0, NextKey: nil}, + key: admin, + }, + "with nothing left to iterate from key": { + pageReq: &query.PageRequest{Key: orm.EncodeSequence(5)}, + exp: []testdata.GroupInfo{}, + expPageRes: &query.PageResponse{Total: 0, NextKey: nil}, + key: admin, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + var loaded []testdata.GroupInfo + + it, err := idx.GetPaginated(ctx, spec.key, spec.pageReq) + require.NoError(t, err) + + res, err := orm.Paginate(it, spec.pageReq, &loaded) + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + assert.EqualValues(t, spec.exp, loaded) + assert.EqualValues(t, spec.expPageRes.Total, res.Total) + assert.EqualValues(t, spec.expPageRes.NextKey, res.NextKey) + } + + }) + } +} + +// mockIter amino encodes + decodes value object. +func mockIter(rowID orm.RowID, val codec.ProtoMarshaler) orm.Iterator { + b, err := val.Marshal() + if err != nil { + panic(err) + } + return orm.NewSingleValueIterator(rowID, b) +} + +func noopIter() orm.Iterator { + return orm.IteratorFunc(func(dest codec.ProtoMarshaler) (orm.RowID, error) { + return nil, nil + }) +} diff --git a/regen/orm/orm.go b/regen/orm/orm.go new file mode 100644 index 0000000000..1797d9228e --- /dev/null +++ b/regen/orm/orm.go @@ -0,0 +1,177 @@ +/* +Package orm is a convenient object to data store mapper. +*/ +package orm + +import ( + "io" + "reflect" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/query" +) + +const ormCodespace = "orm" + +var ( + ErrNotFound = errors.Register(ormCodespace, 100, "not found") + ErrIteratorDone = errors.Register(ormCodespace, 101, "iterator done") + ErrIteratorInvalid = errors.Register(ormCodespace, 102, "iterator invalid") + ErrType = errors.Register(ormCodespace, 110, "invalid type") + ErrUniqueConstraint = errors.Register(ormCodespace, 111, "unique constraint violation") + ErrArgument = errors.Register(ormCodespace, 112, "invalid argument") + ErrIndexKeyMaxLength = errors.Register(ormCodespace, 113, "index key exceeds max length") + ErrEmptyKey = errors.Register(ormCodespace, 114, "cannot use empty key") +) + +// HasKVStore is a subset of the cosmos-sdk context defined for loose coupling and simpler test setups. +type HasKVStore interface { + KVStore(key sdk.StoreKey) sdk.KVStore +} + +// Unique identifier of a persistent table. +type RowID []byte + +// Bytes returns raw bytes. +func (r RowID) Bytes() []byte { + return r +} + +// Validateable is an interface that Persistent types can implement and is called on any orm save or update operation. +type Validateable interface { + // ValidateBasic is a sanity check on the data. Any error returned prevents create or updates. + ValidateBasic() error +} + +// Persistent supports Marshal and Unmarshal +// +// This is separated from Marshal, as this almost always requires +// a pointer, and functions that only need to marshal bytes can +// use the Marshaller interface to access non-pointers. +// +// As with Marshaller, this may do internal validation on the data +// and errors should be expected. +type Persistent interface { + // Marshal serializes object into binary representation + Marshal() ([]byte, error) + // Unmarshal deserializes the object from the binary representation + Unmarshal([]byte) error +} + +// Index allows efficient prefix scans is stored as key = concat(indexKeyBytes, rowIDUint64) with value empty +// so that the row PrimaryKey is allows a fixed with 8 byte integer. This allows the MultiKeyIndex key bytes to be +// variable length and scanned iteratively. The +type Index interface { + // Has checks if a key exists. Panics on nil key. + Has(ctx HasKVStore, key []byte) bool + + // Get returns a result iterator for the searchKey. + // searchKey must not be nil. + Get(ctx HasKVStore, searchKey []byte) (Iterator, error) + + // GetPaginated returns a result iterator for the searchKey and optional pageRequest. + // searchKey must not be nil. + GetPaginated(ctx HasKVStore, searchKey []byte, pageRequest *query.PageRequest) (Iterator, error) + + // PrefixScan returns an Iterator over a domain of keys in ascending order. End is exclusive. + // Start is an MultiKeyIndex key or prefix. It must be less than end, or the Iterator is invalid and error is returned. + // Iterator must be closed by caller. + // To iterate over entire domain, use PrefixScan(nil, nil) + // + // WARNING: The use of a PrefixScan can be very expensive in terms of Gas. Please make sure you do not expose + // this as an endpoint to the public without further limits. + // Example: + // it, err := idx.PrefixScan(ctx, start, end) + // if err !=nil { + // return err + // } + // const defaultLimit = 20 + // it = LimitIterator(it, defaultLimit) + // + // CONTRACT: No writes may happen within a domain while an iterator exists over it. + PrefixScan(ctx HasKVStore, start []byte, end []byte) (Iterator, error) + + // ReversePrefixScan returns an Iterator over a domain of keys in descending order. End is exclusive. + // Start is an MultiKeyIndex key or prefix. It must be less than end, or the Iterator is invalid and error is returned. + // Iterator must be closed by caller. + // To iterate over entire domain, use PrefixScan(nil, nil) + // + // WARNING: The use of a ReversePrefixScan can be very expensive in terms of Gas. Please make sure you do not expose + // this as an endpoint to the public without further limits. See `LimitIterator` + // + // CONTRACT: No writes may happen within a domain while an iterator exists over it. + ReversePrefixScan(ctx HasKVStore, start []byte, end []byte) (Iterator, error) +} + +// Iterator allows iteration through a sequence of key value pairs +type Iterator interface { + // LoadNext loads the next value in the sequence into the pointer passed as dest and returns the key. If there + // are no more items the ErrIteratorDone error is returned + // The key is the rowID and not any MultiKeyIndex key. + LoadNext(dest codec.ProtoMarshaler) (RowID, error) + // Close releases the iterator and should be called at the end of iteration + io.Closer +} + +// IndexKeyCodec defines the encoding/ decoding methods for building/ splitting index keys. +type IndexKeyCodec interface { + // BuildIndexKey encodes a searchable key and the target RowID. + BuildIndexKey(searchableKey []byte, rowID RowID) []byte + // StripRowID returns the RowID from the combined persistentIndexKey. It is the reverse operation to BuildIndexKey + // but with the searchableKey dropped. + StripRowID(persistentIndexKey []byte) RowID +} + +// Indexable types are used to setup new tables. +// This interface provides a set of functions that can be called by indexes to register and interact with the tables. +type Indexable interface { + StoreKey() sdk.StoreKey + RowGetter() RowGetter + IndexKeyCodec() IndexKeyCodec + AddAfterSaveInterceptor(interceptor AfterSaveInterceptor) + AddAfterDeleteInterceptor(interceptor AfterDeleteInterceptor) +} + +// AfterSaveInterceptor defines a callback function to be called on Create + Update. +type AfterSaveInterceptor func(ctx HasKVStore, rowID RowID, newValue, oldValue codec.ProtoMarshaler) error + +// AfterDeleteInterceptor defines a callback function to be called on Delete operations. +type AfterDeleteInterceptor func(ctx HasKVStore, rowID RowID, value codec.ProtoMarshaler) error + +// RowGetter loads a persistent object by row ID into the destination object. The dest parameter must therefore be a pointer. +// Any implementation must return `ErrNotFound` when no object for the rowID exists +type RowGetter func(ctx HasKVStore, rowID RowID, dest codec.ProtoMarshaler) error + +// NewTypeSafeRowGetter returns a `RowGetter` with type check on the dest parameter. +func NewTypeSafeRowGetter(storeKey sdk.StoreKey, prefixKey byte, model reflect.Type, cdc codec.Codec) RowGetter { + return func(ctx HasKVStore, rowID RowID, dest codec.ProtoMarshaler) error { + if len(rowID) == 0 { + return errors.Wrap(ErrArgument, "key must not be nil") + } + if err := assertCorrectType(model, dest); err != nil { + return err + } + + store := prefix.NewStore(ctx.KVStore(storeKey), []byte{prefixKey}) + it := store.Iterator(PrefixRange(rowID)) + defer it.Close() + if !it.Valid() { + return ErrNotFound + } + return cdc.Unmarshal(it.Value(), dest) + } +} + +func assertCorrectType(model reflect.Type, obj codec.ProtoMarshaler) error { + tp := reflect.TypeOf(obj) + if tp.Kind() != reflect.Ptr { + return errors.Wrap(ErrType, "model destination must be a pointer") + } + if model != tp.Elem() { + return errors.Wrapf(ErrType, "can not use %T with this bucket", obj) + } + return nil +} diff --git a/regen/orm/orm_scenario_test.go b/regen/orm/orm_scenario_test.go new file mode 100644 index 0000000000..68ee52bb2c --- /dev/null +++ b/regen/orm/orm_scenario_test.go @@ -0,0 +1,405 @@ +package orm_test + +import ( + "bytes" + "encoding/binary" + "fmt" + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/regen/orm" + "github.com/cosmos/cosmos-sdk/regen/orm/testdata" +) + +// Testing ORM with arbitrary address length +const addrLen = 10 + +func TestKeeperEndToEndWithAutoUInt64Table(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + storeKey := sdk.NewKVStoreKey("test") + ctx := orm.NewMockContext() + + k := NewGroupKeeper(storeKey, cdc) + + g := testdata.GroupInfo{ + GroupId: 1, + Description: "my test", + Admin: sdk.AccAddress([]byte("admin-address")), + } + // when stored + rowID, err := k.groupTable.Create(ctx, &g) + require.NoError(t, err) + // then we should find it + exists := k.groupTable.Has(ctx, rowID) + require.True(t, exists) + + // and load it + var loaded testdata.GroupInfo + + binKey, err := k.groupTable.GetOne(ctx, rowID, &loaded) + require.NoError(t, err) + + assert.Equal(t, rowID, binary.BigEndian.Uint64(binKey)) + assert.Equal(t, "my test", loaded.Description) + assert.Equal(t, sdk.AccAddress([]byte("admin-address")), loaded.Admin) + + // and exists in MultiKeyIndex + exists = k.groupByAdminIndex.Has(ctx, []byte("admin-address")) + require.True(t, exists) + + // and when loaded + it, err := k.groupByAdminIndex.Get(ctx, []byte("admin-address")) + require.NoError(t, err) + + // then + binKey, loaded = first(t, it) + assert.Equal(t, rowID, binary.BigEndian.Uint64(binKey)) + assert.Equal(t, g, loaded) + + // when updated + g.Admin = []byte("new-admin-address") + err = k.groupTable.Save(ctx, rowID, &g) + require.NoError(t, err) + + // then indexes are updated, too + exists = k.groupByAdminIndex.Has(ctx, []byte("new-admin-address")) + require.True(t, exists) + + exists = k.groupByAdminIndex.Has(ctx, []byte("admin-address")) + require.False(t, exists) + + // when deleted + err = k.groupTable.Delete(ctx, rowID) + require.NoError(t, err) + + // then removed from primary MultiKeyIndex + exists = k.groupTable.Has(ctx, rowID) + require.False(t, exists) + + // and also removed from secondary MultiKeyIndex + exists = k.groupByAdminIndex.Has(ctx, []byte("new-admin-address")) + require.False(t, exists) +} + +func TestKeeperEndToEndWithPrimaryKeyTable(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + storeKey := sdk.NewKVStoreKey("test") + ctx := orm.NewMockContext() + + k := NewGroupKeeper(storeKey, cdc) + + g := testdata.GroupInfo{ + GroupId: 1, + Description: "my test", + Admin: sdk.AccAddress([]byte("admin-address")), + } + + m := testdata.GroupMember{ + Group: sdk.AccAddress(orm.EncodeSequence(1)), + Member: sdk.AccAddress([]byte("member-address")), + Weight: 10, + } + groupRowID, err := k.groupTable.Create(ctx, &g) + require.NoError(t, err) + require.Equal(t, uint64(1), groupRowID) + // when stored + err = k.groupMemberTable.Create(ctx, &m) + require.NoError(t, err) + + // then we should find it by primary key + primaryKey := orm.PrimaryKey(&m) + exists := k.groupMemberTable.Has(ctx, primaryKey) + require.True(t, exists) + // and load it by primary key + var loaded testdata.GroupMember + err = k.groupMemberTable.GetOne(ctx, primaryKey, &loaded) + require.NoError(t, err) + + // then values should match expectations + require.Equal(t, m, loaded) + + // and then the data should exists in MultiKeyIndex + exists = k.groupMemberByGroupIndex.Has(ctx, orm.EncodeSequence(groupRowID)) + require.True(t, exists) + + // and when loaded from MultiKeyIndex + it, err := k.groupMemberByGroupIndex.Get(ctx, orm.EncodeSequence(groupRowID)) + require.NoError(t, err) + + // then values should match as before + _, err = orm.First(it, &loaded) + require.NoError(t, err) + + assert.Equal(t, m, loaded) + // and when we create another entry with the same primary key + err = k.groupMemberTable.Create(ctx, &m) + // then it should fail as the primary key must be unique + require.True(t, orm.ErrUniqueConstraint.Is(err), err) + + // and when entity updated with new primary key + updatedMember := &testdata.GroupMember{ + Group: m.Group, + Member: []byte("new-member-address"), + Weight: m.Weight, + } + // then it should fail as the primary key is immutable + err = k.groupMemberTable.Save(ctx, updatedMember) + require.Error(t, err) + + // and when entity updated with non primary key attribute modified + updatedMember = &testdata.GroupMember{ + Group: m.Group, + Member: m.Member, + Weight: 99, + } + // then it should not fail + err = k.groupMemberTable.Save(ctx, updatedMember) + require.NoError(t, err) + + // and when entity deleted + err = k.groupMemberTable.Delete(ctx, &m) + require.NoError(t, err) + + // then it is removed from primary key MultiKeyIndex + exists = k.groupMemberTable.Has(ctx, primaryKey) + require.False(t, exists) + + // and removed from secondary MultiKeyIndex + exists = k.groupMemberByGroupIndex.Has(ctx, orm.EncodeSequence(groupRowID)) + require.False(t, exists) +} + +func TestGasCostsPrimaryKeyTable(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + storeKey := sdk.NewKVStoreKey("test") + ctx := orm.NewMockContext() + + k := NewGroupKeeper(storeKey, cdc) + + g := testdata.GroupInfo{ + GroupId: 1, + Description: "my test", + Admin: sdk.AccAddress([]byte("admin-address")), + } + + m := testdata.GroupMember{ + Group: sdk.AccAddress(orm.EncodeSequence(1)), + Member: sdk.AccAddress([]byte("member-address")), + Weight: 10, + } + groupRowID, err := k.groupTable.Create(ctx, &g) + require.NoError(t, err) + require.Equal(t, uint64(1), groupRowID) + gCtx := orm.NewGasCountingMockContext(ctx) + err = k.groupMemberTable.Create(gCtx, &m) + require.NoError(t, err) + t.Logf("gas consumed on create: %d", gCtx.GasConsumed()) + + // get by primary key + gCtx.ResetGasMeter() + var loaded testdata.GroupMember + err = k.groupMemberTable.GetOne(gCtx, orm.PrimaryKey(&m), &loaded) + require.NoError(t, err) + t.Logf("gas consumed on get by primary key: %d", gCtx.GasConsumed()) + + // get by secondary index + gCtx.ResetGasMeter() + // and when loaded from MultiKeyIndex + it, err := k.groupMemberByGroupIndex.Get(gCtx, orm.EncodeSequence(groupRowID)) + require.NoError(t, err) + var loadedSlice []testdata.GroupMember + _, err = orm.ReadAll(it, &loadedSlice) + require.NoError(t, err) + + t.Logf("gas consumed on get by multi index key: %d", gCtx.GasConsumed()) + + // delete + gCtx.ResetGasMeter() + err = k.groupMemberTable.Delete(gCtx, &m) + require.NoError(t, err) + t.Logf("gas consumed on delete by primary key: %d", gCtx.GasConsumed()) + + // with 3 elements + for i := 1; i < 4; i++ { + gCtx.ResetGasMeter() + m := testdata.GroupMember{ + Group: sdk.AccAddress(orm.EncodeSequence(1)), + Member: sdk.AccAddress([]byte(fmt.Sprintf("member-address%d", i))), + Weight: 10, + } + err = k.groupMemberTable.Create(gCtx, &m) + require.NoError(t, err) + t.Logf("%d: gas consumed on create: %d", i, gCtx.GasConsumed()) + } + + for i := 1; i < 4; i++ { + gCtx.ResetGasMeter() + m := testdata.GroupMember{ + Group: sdk.AccAddress(orm.EncodeSequence(1)), + Member: sdk.AccAddress([]byte(fmt.Sprintf("member-address%d", i))), + Weight: 10, + } + err = k.groupMemberTable.GetOne(gCtx, orm.PrimaryKey(&m), &loaded) + require.NoError(t, err) + t.Logf("%d: gas consumed on get by primary key: %d", i, gCtx.GasConsumed()) + } + + // get by secondary index + gCtx.ResetGasMeter() + // and when loaded from MultiKeyIndex + it, err = k.groupMemberByGroupIndex.Get(gCtx, orm.EncodeSequence(groupRowID)) + require.NoError(t, err) + _, err = orm.ReadAll(it, &loadedSlice) + require.NoError(t, err) + require.Len(t, loadedSlice, 3) + t.Logf("gas consumed on get by multi index key: %d", gCtx.GasConsumed()) + + // delete + for i, m := range loadedSlice { + gCtx.ResetGasMeter() + + err = k.groupMemberTable.Delete(gCtx, &m) + require.NoError(t, err) + t.Logf("%d: gas consumed on delete: %d", i, gCtx.GasConsumed()) + } +} + +func TestExportImportStateAutoUInt64Table(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + storeKey := sdk.NewKVStoreKey("test") + ctx := orm.NewMockContext() + + k := NewGroupKeeper(storeKey, cdc) + + testRecords := 10 + for i := 1; i <= testRecords; i++ { + myAddr := sdk.AccAddress(bytes.Repeat([]byte{byte(i)}, addrLen)) + g := testdata.GroupInfo{ + GroupId: uint64(i), + Description: fmt.Sprintf("my test %d", i), + Admin: myAddr, + } + + groupRowID, err := k.groupTable.Create(ctx, &g) + require.NoError(t, err) + require.Equal(t, uint64(i), groupRowID) + } + var groups []*testdata.GroupInfo + seqVal, err := orm.ExportTableData(ctx, k.groupTable, &groups) + require.NoError(t, err) + + // when a new db seeded + ctx = orm.NewMockContext() + + err = orm.ImportTableData(ctx, k.groupTable, groups, seqVal) + require.NoError(t, err) + // then all data is set again + + for i := 1; i <= testRecords; i++ { + require.True(t, k.groupTable.Has(ctx, uint64(i))) + var loaded testdata.GroupInfo + groupRowID, err := k.groupTable.GetOne(ctx, uint64(i), &loaded) + require.NoError(t, err) + + require.Equal(t, orm.RowID(orm.EncodeSequence(uint64(i))), groupRowID) + assert.Equal(t, fmt.Sprintf("my test %d", i), loaded.Description) + exp := sdk.AccAddress(bytes.Repeat([]byte{byte(i)}, addrLen)) + assert.Equal(t, exp, loaded.Admin) + + // and also the indexes + require.True(t, k.groupByAdminIndex.Has(ctx, exp)) + it, err := k.groupByAdminIndex.Get(ctx, exp) + require.NoError(t, err) + var all []testdata.GroupInfo + orm.ReadAll(it, &all) + require.Len(t, all, 1) + assert.Equal(t, loaded, all[0]) + } + require.Equal(t, uint64(testRecords), k.groupTable.Sequence().CurVal(ctx)) +} + +func TestExportImportStatePrimaryKeyTable(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + storeKey := sdk.NewKVStoreKey("test") + ctx := orm.NewMockContext() + + k := NewGroupKeeper(storeKey, cdc) + myGroupAddr := sdk.AccAddress(bytes.Repeat([]byte{byte('a')}, addrLen)) + testRecordsNum := 10 + testRecords := make([]testdata.GroupMember, testRecordsNum) + for i := 1; i <= testRecordsNum; i++ { + myAddr := sdk.AccAddress(bytes.Repeat([]byte{byte(i)}, addrLen)) + g := testdata.GroupMember{ + Group: myGroupAddr, + Member: myAddr, + Weight: uint64(i), + } + err := k.groupMemberTable.Create(ctx, &g) + require.NoError(t, err) + testRecords[i-1] = g + } + var groupMembers []*testdata.GroupMember + _, err := orm.ExportTableData(ctx, k.groupMemberTable, &groupMembers) + require.NoError(t, err) + + // when a new db seeded + ctx = orm.NewMockContext() + + err = orm.ImportTableData(ctx, k.groupMemberTable, groupMembers, 0) + require.NoError(t, err) + + // then all data is set again + it, err := k.groupMemberTable.PrefixScan(ctx, nil, nil) + require.NoError(t, err) + var loaded []testdata.GroupMember + keys, err := orm.ReadAll(it, &loaded) + require.NoError(t, err) + for i := range keys { + assert.Equal(t, orm.PrimaryKey(&testRecords[i]), keys[i].Bytes()) + } + assert.Equal(t, testRecords, loaded) + + // and first index setup + it, err = k.groupMemberByGroupIndex.Get(ctx, myGroupAddr) + require.NoError(t, err) + loaded = nil + keys, err = orm.ReadAll(it, &loaded) + require.NoError(t, err) + for i := range keys { + assert.Equal(t, orm.PrimaryKey(&testRecords[i]), keys[i].Bytes()) + } + assert.Equal(t, testRecords, loaded) + + // and second index setup + for _, v := range testRecords { + it, err = k.groupMemberByMemberIndex.Get(ctx, v.Member) + require.NoError(t, err) + loaded = nil + keys, err = orm.ReadAll(it, &loaded) + require.NoError(t, err) + assert.Equal(t, []orm.RowID{orm.PrimaryKey(&v)}, keys) + assert.Equal(t, []testdata.GroupMember{v}, loaded) + } +} + +func first(t *testing.T, it orm.Iterator) ([]byte, testdata.GroupInfo) { + var loaded testdata.GroupInfo + key, err := orm.First(it, &loaded) + require.NoError(t, err) + return key, loaded +} diff --git a/regen/orm/orm_test.go b/regen/orm/orm_test.go new file mode 100644 index 0000000000..6f97274b5d --- /dev/null +++ b/regen/orm/orm_test.go @@ -0,0 +1,77 @@ +package orm_test + +import ( + "reflect" + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/regen/orm" + "github.com/cosmos/cosmos-sdk/regen/orm/testdata" +) + +func TestTypeSafeRowGetter(t *testing.T) { + storeKey := sdk.NewKVStoreKey("test") + ctx := orm.NewMockContext() + const prefixKey = 0x2 + store := prefix.NewStore(ctx.KVStore(storeKey), []byte{prefixKey}) + md := testdata.GroupInfo{Description: "foo"} + bz, err := md.Marshal() + require.NoError(t, err) + store.Set(orm.EncodeSequence(1), bz) + + specs := map[string]struct { + srcRowID orm.RowID + srcModelType reflect.Type + expObj interface{} + expErr *errors.Error + }{ + "happy path": { + srcRowID: orm.EncodeSequence(1), + srcModelType: reflect.TypeOf(testdata.GroupInfo{}), + expObj: testdata.GroupInfo{Description: "foo"}, + }, + "unknown rowID should return ErrNotFound": { + srcRowID: orm.EncodeSequence(999), + srcModelType: reflect.TypeOf(testdata.GroupInfo{}), + expErr: orm.ErrNotFound, + }, + "wrong type should cause ErrType": { + srcRowID: orm.EncodeSequence(1), + srcModelType: reflect.TypeOf(testdata.GroupMember{}), + expErr: orm.ErrType, + }, + "empty rowID not allowed": { + srcRowID: []byte{}, + srcModelType: reflect.TypeOf(testdata.GroupInfo{}), + expErr: orm.ErrArgument, + }, + "nil rowID not allowed": { + srcModelType: reflect.TypeOf(testdata.GroupInfo{}), + expErr: orm.ErrArgument, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + getter := orm.NewTypeSafeRowGetter(storeKey, prefixKey, spec.srcModelType, cdc) + var loadedObj testdata.GroupInfo + + err := getter(ctx, spec.srcRowID, &loadedObj) + if spec.expErr != nil { + require.True(t, spec.expErr.Is(err), err) + return + } + require.NoError(t, err) + assert.Equal(t, spec.expObj, loadedObj) + }) + } +} diff --git a/regen/orm/primary_key.go b/regen/orm/primary_key.go new file mode 100644 index 0000000000..0c3499c8cb --- /dev/null +++ b/regen/orm/primary_key.go @@ -0,0 +1,208 @@ +package orm + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ Indexable = &PrimaryKeyTableBuilder{} + +// NewPrimaryKeyTableBuilder creates a builder to setup a PrimaryKeyTable object. +func NewPrimaryKeyTableBuilder(prefixData byte, storeKey sdk.StoreKey, model PrimaryKeyed, codec IndexKeyCodec, cdc codec.Codec) *PrimaryKeyTableBuilder { + return &PrimaryKeyTableBuilder{ + tableBuilder: newTableBuilder(prefixData, storeKey, model, codec, cdc), + } +} + +type PrimaryKeyTableBuilder struct { + *tableBuilder +} + +func (a PrimaryKeyTableBuilder) Build() PrimaryKeyTable { + return PrimaryKeyTable{table: a.tableBuilder.Build()} + +} + +// PrimaryKeyed defines an object type that is aware of its immutable primary key. +type PrimaryKeyed interface { + // PrimaryKeyFields returns the fields of the object that will make up + // the primary key. The PrimaryKey function will encode and concatenate + // the fields to build the primary key. + // + // PrimaryKey parts can be []byte, string, and integer types. []byte is + // encoded with a length prefix, strings are null-terminated, and + // integers are encoded using 4 or 8 byte big endian. + // + // IMPORTANT: []byte parts are encoded with a single byte length prefix, + // so cannot be longer than 256 bytes. + // + // The `IndexKeyCodec` used with the `PrimaryKeyTable` may add certain + // constraints to the byte representation as max length = 255 in + // `Max255DynamicLengthIndexKeyCodec` or a fix length in + // `FixLengthIndexKeyCodec` for example. + PrimaryKeyFields() []interface{} + codec.ProtoMarshaler +} + +// PrimaryKey returns the immutable and serialized primary key of this object. +// The primary key has to be unique within it's domain so that not two with same +// value can exist in the same table. This means PrimaryKeyFields() has to +// return a unique value for each object. +// +// PrimaryKey parts can be []byte, string, and integer types. The function will panic if +// it there is a part of any other type. +// []byte is encoded with a length prefix, strings are null-terminated, and integers are +// encoded using 4 or 8 byte big endian. +// The function panics if obj.PrimaryKey contains an +func PrimaryKey(obj PrimaryKeyed) []byte { + fields := obj.PrimaryKeyFields() + return buildPrimaryKey(fields) +} + +// buildPrimaryKey encodes and concatenates the PrimaryKeyFields. See PrimaryKey +// for full documentation of the encoding. +// fields must have elements of type []byte, string or integer. If it contains other type +// the the function will panic. +func buildPrimaryKey(fields []interface{}) []byte { + bytesSlice := make([][]byte, len(fields)) + totalLen := 0 + for i, field := range fields { + bytesSlice[i] = primaryKeyFieldBytes(field) + totalLen += len(bytesSlice[i]) + } + primaryKey := make([]byte, 0, totalLen) + for _, bs := range bytesSlice { + primaryKey = append(primaryKey, bs...) + } + return primaryKey +} + +func primaryKeyFieldBytes(field interface{}) []byte { + switch v := field.(type) { + case []byte: + return AddLengthPrefix(v) + case string: + return NullTerminatedBytes(v) + case uint64: + return EncodeSequence(v) + default: + panic(fmt.Sprintf("Type %T not allowed as primary key field", v)) + } +} + +// Prefix the byte array with its length as 8 bytes. The function will panic +// if the bytes length is bigger than 256. +func AddLengthPrefix(bytes []byte) []byte { + byteLen := len(bytes) + if byteLen > 256 { + panic("Cannot create primary key with an []byte of length greater than 256 bytes. Try again with a smaller []byte.") + } + + prefixedBytes := make([]byte, 1+len(bytes)) + copy(prefixedBytes, []byte{uint8(byteLen)}) + copy(prefixedBytes[1:], bytes) + return prefixedBytes +} + +// Convert string to byte array and null terminate it +func NullTerminatedBytes(s string) []byte { + bytes := make([]byte, len(s)+1) + copy(bytes, s) + return bytes +} + +var _ TableExportable = &PrimaryKeyTable{} + +// PrimaryKeyTable provides simpler object style orm methods without passing database RowIDs. +// Entries are persisted and loaded with a reference to their unique primary key. +type PrimaryKeyTable struct { + table table +} + +// Create persists the given object under their primary key. It checks if the +// key already exists and may return an `ErrUniqueConstraint`. +// Create iterates though the registered callbacks and may add secondary index keys by them. +func (a PrimaryKeyTable) Create(ctx HasKVStore, obj PrimaryKeyed) error { + rowID := PrimaryKey(obj) + if a.table.Has(ctx, rowID) { + return ErrUniqueConstraint + } + return a.table.Create(ctx, rowID, obj) +} + +// Save updates the given object under the primary key. It expects the key to exists already +// and fails with an `ErrNotFound` otherwise. Any caller must therefore make sure that this contract +// is fulfilled. Parameters must not be nil. +// +// Save iterates though the registered callbacks and may add or remove secondary index keys by them. +func (a PrimaryKeyTable) Save(ctx HasKVStore, newValue PrimaryKeyed) error { + return a.table.Save(ctx, PrimaryKey(newValue), newValue) +} + +// Delete removes the object. It expects the primary key to exists already +// and fails with a `ErrNotFound` otherwise. Any caller must therefore make sure that this contract +// is fulfilled. +// +// Delete iterates though the registered callbacks and removes secondary index keys by them. +func (a PrimaryKeyTable) Delete(ctx HasKVStore, obj PrimaryKeyed) error { + return a.table.Delete(ctx, PrimaryKey(obj)) +} + +// Has checks if a key exists. Panics on nil key. +func (a PrimaryKeyTable) Has(ctx HasKVStore, primaryKey RowID) bool { + return a.table.Has(ctx, primaryKey) +} + +// Contains returns true when an object with same type and primary key is persisted in this table. +func (a PrimaryKeyTable) Contains(ctx HasKVStore, obj PrimaryKeyed) bool { + if err := assertCorrectType(a.table.model, obj); err != nil { + return false + } + return a.table.Has(ctx, PrimaryKey(obj)) +} + +// GetOne load the object persisted for the given primary Key into the dest parameter. +// If none exists `ErrNotFound` is returned instead. Parameters must not be nil. +func (a PrimaryKeyTable) GetOne(ctx HasKVStore, primKey RowID, dest codec.ProtoMarshaler) error { + return a.table.GetOne(ctx, primKey, dest) +} + +// PrefixScan returns an Iterator over a domain of keys in ascending order. End is exclusive. +// Start is an MultiKeyIndex key or prefix. It must be less than end, or the Iterator is invalid and error is returned. +// Iterator must be closed by caller. +// To iterate over entire domain, use PrefixScan(nil, nil) +// +// WARNING: The use of a PrefixScan can be very expensive in terms of Gas. Please make sure you do not expose +// this as an endpoint to the public without further limits. +// Example: +// it, err := idx.PrefixScan(ctx, start, end) +// if err !=nil { +// return err +// } +// const defaultLimit = 20 +// it = LimitIterator(it, defaultLimit) +// +// CONTRACT: No writes may happen within a domain while an iterator exists over it. +func (a PrimaryKeyTable) PrefixScan(ctx HasKVStore, start, end []byte) (Iterator, error) { + return a.table.PrefixScan(ctx, start, end) +} + +// ReversePrefixScan returns an Iterator over a domain of keys in descending order. End is exclusive. +// Start is an MultiKeyIndex key or prefix. It must be less than end, or the Iterator is invalid and error is returned. +// Iterator must be closed by caller. +// To iterate over entire domain, use PrefixScan(nil, nil) +// +// WARNING: The use of a ReversePrefixScan can be very expensive in terms of Gas. Please make sure you do not expose +// this as an endpoint to the public without further limits. See `LimitIterator` +// +// CONTRACT: No writes may happen within a domain while an iterator exists over it. +func (a PrimaryKeyTable) ReversePrefixScan(ctx HasKVStore, start, end []byte) (Iterator, error) { + return a.table.ReversePrefixScan(ctx, start, end) +} + +// Table satisfies the TableExportable interface and must not be used otherwise. +func (a PrimaryKeyTable) Table() table { + return a.table +} diff --git a/regen/orm/primary_key_property_test.go b/regen/orm/primary_key_property_test.go new file mode 100644 index 0000000000..663967d324 --- /dev/null +++ b/regen/orm/primary_key_property_test.go @@ -0,0 +1,200 @@ +package orm_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "pgregory.net/rapid" + + "github.com/cosmos/cosmos-sdk/regen/orm" + "github.com/cosmos/cosmos-sdk/regen/orm/testdata" +) + +func TestPrimaryKeyTable(t *testing.T) { + rapid.Check(t, rapid.Run(&primaryKeyMachine{})) +} + +// primaryKeyMachine is a state machine model of the PrimaryKeyTable. The state +// is modelled as a map of strings to GroupMembers. +type primaryKeyMachine struct { + ctx orm.HasKVStore + table *orm.PrimaryKeyTable + state map[string]*testdata.GroupMember +} + +// stateKeys gets all the keys in the model map +func (m *primaryKeyMachine) stateKeys() []string { + keys := make([]string, len(m.state)) + + i := 0 + for k := range m.state { + keys[i] = k + i++ + } + + return keys +} + +// Generate a GroupMember that has a 50% chance of being a part of the existing +// state +func (m *primaryKeyMachine) genGroupMember() *rapid.Generator { + genStateGroupMember := rapid.Custom(func(t *rapid.T) *testdata.GroupMember { + pk := rapid.SampledFrom(m.stateKeys()).Draw(t, "key").(string) + return m.state[pk] + }) + + if len(m.stateKeys()) == 0 { + return genGroupMember + } else { + return rapid.OneOf(genGroupMember, genStateGroupMember) + } +} + +// Init creates a new instance of the state machine model by building the real +// table and making the empty model map +func (m *primaryKeyMachine) Init(t *rapid.T) { + // Create context + m.ctx = orm.NewMockContext() + + // Create primary key table + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + storeKey := sdk.NewKVStoreKey("test") + const testTablePrefix = iota + table := orm.NewPrimaryKeyTableBuilder( + testTablePrefix, + storeKey, + &testdata.GroupMember{}, + orm.Max255DynamicLengthIndexKeyCodec{}, + cdc, + ).Build() + + m.table = &table + + // Create model state + m.state = make(map[string]*testdata.GroupMember) +} + +// Check that the real values match the state values. This is kind of overkill, +// because we should catch any discrepancies in a Has command. +func (m *primaryKeyMachine) Check(t *rapid.T) { + iter, err := m.table.PrefixScan(m.ctx, nil, nil) + require.NoError(t, err) + + for { + var dest testdata.GroupMember + rowID, err := iter.LoadNext(&dest) + if err == orm.ErrIteratorDone { + break + } else { + require.Equal(t, *m.state[string(rowID)], dest) + } + } +} + +// Create is one of the model commands. It adds an object to the table, creating +// an error if it already exists. +func (m *primaryKeyMachine) Create(t *rapid.T) { + g := genGroupMember.Draw(t, "g").(*testdata.GroupMember) + pk := string(orm.PrimaryKey(g)) + + t.Logf("pk: %v", pk) + t.Logf("m.state: %v", m.state) + + err := m.table.Create(m.ctx, g) + + if m.state[pk] != nil { + require.Error(t, err) + } else { + require.NoError(t, err) + m.state[pk] = g + } +} + +// Save is one of the model commands. It updates the value at a given primary +// key and fails if that primary key doesn't already exist in the table. +func (m *primaryKeyMachine) Save(t *rapid.T) { + gm := m.genGroupMember().Draw(t, "gm").(*testdata.GroupMember) + + // We can only really change the weight here, because Group and Member + // both form part of the PrimaryKey + newWeight := rapid.Uint64().Draw(t, "newWeight").(uint64) + gm.Weight = newWeight + + // Perform the real Save + err := m.table.Save(m.ctx, gm) + + if m.state[string(orm.PrimaryKey(gm))] == nil { + // If there's no value in the model, we expect an error + require.Error(t, err) + } else { + // If we have a value in the model, expect no error + require.NoError(t, err) + + // Update the model with the new value + m.state[string(orm.PrimaryKey(gm))] = gm + } +} + +// Delete is one of the model commands. It removes the object with the given +// primary key from the table and returns an error if that primary key doesn't +// already exist in the table. +func (m *primaryKeyMachine) Delete(t *rapid.T) { + gm := m.genGroupMember().Draw(t, "gm").(*testdata.GroupMember) + + // Perform the real Delete + err := m.table.Delete(m.ctx, gm) + + if m.state[string(orm.PrimaryKey(gm))] == nil { + // If there's no value in the model, we expect an error + require.Error(t, err) + } else { + // If we have a value in the model, expect no error + require.NoError(t, err) + + // Delete the value from the model + delete(m.state, string(orm.PrimaryKey(gm))) + } +} + +// Has is one of the model commands. It checks whether a key already exists in +// the table. +func (m *primaryKeyMachine) Has(t *rapid.T) { + pk := orm.PrimaryKey(m.genGroupMember().Draw(t, "g").(*testdata.GroupMember)) + + realHas := m.table.Has(m.ctx, pk) + modelHas := m.state[string(pk)] != nil + + require.Equal(t, realHas, modelHas) +} + +// GetOne is one of the model commands. It fetches an object from the table by +// its primary key and returns an error if that primary key isn't in the table. +func (m *primaryKeyMachine) GetOne(t *rapid.T) { + pk := orm.PrimaryKey(m.genGroupMember().Draw(t, "gm").(*testdata.GroupMember)) + + var gm testdata.GroupMember + + err := m.table.GetOne(m.ctx, pk, &gm) + t.Logf("gm: %v", gm) + + if m.state[string(pk)] == nil { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, *m.state[string(pk)], gm) + } +} + +// genGroupMember generates a new group member. At the moment it doesn't +// generate empty strings for Group or Member. +var genGroupMember = rapid.Custom(func(t *rapid.T) *testdata.GroupMember { + return &testdata.GroupMember{ + Group: []byte(rapid.StringN(1, 100, 150).Draw(t, "group").(string)), + Member: []byte(rapid.StringN(1, 100, 150).Draw(t, "member").(string)), + Weight: rapid.Uint64().Draw(t, "weight").(uint64), + } +}) diff --git a/regen/orm/primary_key_test.go b/regen/orm/primary_key_test.go new file mode 100644 index 0000000000..3673b4ec25 --- /dev/null +++ b/regen/orm/primary_key_test.go @@ -0,0 +1,337 @@ +package orm_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/regen/orm" + "github.com/cosmos/cosmos-sdk/regen/orm/testdata" +) + +func TestPrimaryKeyTablePrefixScan(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + storeKey := sdk.NewKVStoreKey("test") + const ( + testTablePrefix = iota + ) + + tb := orm.NewPrimaryKeyTableBuilder(testTablePrefix, storeKey, &testdata.GroupMember{}, orm.Max255DynamicLengthIndexKeyCodec{}, cdc). + Build() + + ctx := orm.NewMockContext() + + const anyWeight = 1 + m1 := testdata.GroupMember{ + Group: []byte("group-a"), + Member: []byte("member-one"), + Weight: anyWeight, + } + m2 := testdata.GroupMember{ + Group: []byte("group-a"), + Member: []byte("member-two"), + Weight: anyWeight, + } + m3 := testdata.GroupMember{ + Group: []byte("group-b"), + Member: []byte("member-two"), + Weight: anyWeight, + } + for _, g := range []testdata.GroupMember{m1, m2, m3} { + require.NoError(t, tb.Create(ctx, &g)) + } + + specs := map[string]struct { + start, end []byte + expResult []testdata.GroupMember + expRowIDs []orm.RowID + expError *errors.Error + method func(ctx orm.HasKVStore, start, end []byte) (orm.Iterator, error) + }{ + "exact match with a single result": { + start: append( + orm.AddLengthPrefix([]byte("group-a")), + orm.AddLengthPrefix([]byte("member-one"))..., + ), // == orm.PrimaryKey(&m1) + end: append( + orm.AddLengthPrefix([]byte("group-a")), + orm.AddLengthPrefix([]byte("member-two"))..., + ), // == orm.PrimaryKey(&m2) + method: tb.PrefixScan, + expResult: []testdata.GroupMember{m1}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m1)}, + }, + "one result by prefix": { + start: orm.AddLengthPrefix([]byte("group-a")), + end: append( + orm.AddLengthPrefix([]byte("group-a")), + orm.AddLengthPrefix([]byte("member-two"))..., + ), // == orm.PrimaryKey(&m2) + method: tb.PrefixScan, + expResult: []testdata.GroupMember{m1}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m1)}, + }, + "multi key elements by group prefix": { + start: orm.AddLengthPrefix([]byte("group-a")), + end: orm.AddLengthPrefix([]byte("group-b")), + method: tb.PrefixScan, + expResult: []testdata.GroupMember{m1, m2}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m1), orm.PrimaryKey(&m2)}, + }, + "open end query with second group": { + start: orm.AddLengthPrefix([]byte("group-b")), + end: nil, + method: tb.PrefixScan, + expResult: []testdata.GroupMember{m3}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m3)}, + }, + "open end query with all": { + start: orm.AddLengthPrefix([]byte("group-a")), + end: nil, + method: tb.PrefixScan, + expResult: []testdata.GroupMember{m1, m2, m3}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m1), orm.PrimaryKey(&m2), orm.PrimaryKey(&m3)}, + }, + "open start query": { + start: nil, + end: orm.AddLengthPrefix([]byte("group-b")), + method: tb.PrefixScan, + expResult: []testdata.GroupMember{m1, m2}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m1), orm.PrimaryKey(&m2)}, + }, + "open start and end query": { + start: nil, + end: nil, + method: tb.PrefixScan, + expResult: []testdata.GroupMember{m1, m2, m3}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m1), orm.PrimaryKey(&m2), orm.PrimaryKey(&m3)}, + }, + "all matching prefix": { + start: orm.AddLengthPrefix([]byte("group")), // == LengthPrefix + "group" + end: nil, + method: tb.PrefixScan, + expResult: []testdata.GroupMember{m1, m2, m3}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m1), orm.PrimaryKey(&m2), orm.PrimaryKey(&m3)}, + }, + "non matching prefix": { + start: []byte("nobody"), + end: nil, + method: tb.PrefixScan, + expResult: []testdata.GroupMember{}, + }, + "start equals end": { + start: []byte("any"), + end: []byte("any"), + method: tb.PrefixScan, + expError: orm.ErrArgument, + }, + "start after end": { + start: []byte("b"), + end: []byte("a"), + method: tb.PrefixScan, + expError: orm.ErrArgument, + }, + "reverse: exact match with a single result": { + start: append( + orm.AddLengthPrefix([]byte("group-a")), + orm.AddLengthPrefix([]byte("member-one"))..., + ), // == orm.PrimaryKey(&m1) + end: append( + orm.AddLengthPrefix([]byte("group-a")), + orm.AddLengthPrefix([]byte("member-two"))..., + ), // == orm.PrimaryKey(&m2) + method: tb.ReversePrefixScan, + expResult: []testdata.GroupMember{m1}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m1)}, + }, + "reverse: one result by prefix": { + start: orm.AddLengthPrefix([]byte("group-a")), + end: append( + orm.AddLengthPrefix([]byte("group-a")), + orm.AddLengthPrefix([]byte("member-two"))..., + ), // == orm.PrimaryKey(&m2) + method: tb.ReversePrefixScan, + expResult: []testdata.GroupMember{m1}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m1)}, + }, + "reverse: multi key elements by group prefix": { + start: orm.AddLengthPrefix([]byte("group-a")), + end: orm.AddLengthPrefix([]byte("group-b")), + method: tb.ReversePrefixScan, + expResult: []testdata.GroupMember{m2, m1}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m2), orm.PrimaryKey(&m1)}, + }, + "reverse: open end query with second group": { + start: orm.AddLengthPrefix([]byte("group-b")), + end: nil, + method: tb.ReversePrefixScan, + expResult: []testdata.GroupMember{m3}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m3)}, + }, + "reverse: open end query with all": { + start: orm.AddLengthPrefix([]byte("group-a")), + end: nil, + method: tb.ReversePrefixScan, + expResult: []testdata.GroupMember{m3, m2, m1}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m3), orm.PrimaryKey(&m2), orm.PrimaryKey(&m1)}, + }, + "reverse: open start query": { + start: nil, + end: orm.AddLengthPrefix([]byte("group-b")), + method: tb.ReversePrefixScan, + expResult: []testdata.GroupMember{m2, m1}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m2), orm.PrimaryKey(&m1)}, + }, + "reverse: open start and end query": { + start: nil, + end: nil, + method: tb.ReversePrefixScan, + expResult: []testdata.GroupMember{m3, m2, m1}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m3), orm.PrimaryKey(&m2), orm.PrimaryKey(&m1)}, + }, + "reverse: all matching prefix": { + start: orm.AddLengthPrefix([]byte("group")), // == LengthPrefix + "group" + end: nil, + method: tb.ReversePrefixScan, + expResult: []testdata.GroupMember{m3, m2, m1}, + expRowIDs: []orm.RowID{orm.PrimaryKey(&m3), orm.PrimaryKey(&m2), orm.PrimaryKey(&m1)}, + }, + "reverse: non matching prefix": { + start: []byte("nobody"), + end: nil, + method: tb.ReversePrefixScan, + expResult: []testdata.GroupMember{}, + }, + "reverse: start equals end": { + start: []byte("any"), + end: []byte("any"), + method: tb.ReversePrefixScan, + expError: orm.ErrArgument, + }, + "reverse: start after end": { + start: []byte("b"), + end: []byte("a"), + method: tb.ReversePrefixScan, + expError: orm.ErrArgument, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + it, err := spec.method(ctx, spec.start, spec.end) + require.True(t, spec.expError.Is(err), "expected #+v but got #+v", spec.expError, err) + if spec.expError != nil { + return + } + var loaded []testdata.GroupMember + rowIDs, err := orm.ReadAll(it, &loaded) + require.NoError(t, err) + assert.Equal(t, spec.expResult, loaded) + assert.Equal(t, spec.expRowIDs, rowIDs) + }) + } +} + +func TestContains(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + storeKey := sdk.NewKVStoreKey("test") + const testTablePrefix = iota + + tb := orm.NewPrimaryKeyTableBuilder(testTablePrefix, storeKey, &testdata.GroupMember{}, orm.Max255DynamicLengthIndexKeyCodec{}, cdc). + Build() + + ctx := orm.NewMockContext() + + myPersistentObj := testdata.GroupMember{ + Group: []byte("group-a"), + Member: []byte("member-one"), + Weight: 1, + } + err := tb.Create(ctx, &myPersistentObj) + require.NoError(t, err) + + specs := map[string]struct { + src orm.PrimaryKeyed + exp bool + }{ + + "same object": {src: &myPersistentObj, exp: true}, + "clone": { + src: &testdata.GroupMember{ + Group: []byte("group-a"), + Member: []byte("member-one"), + Weight: 1, + }, + exp: true, + }, + "different primary key": { + src: &testdata.GroupMember{ + Group: []byte("another group"), + Member: []byte("member-one"), + Weight: 1, + }, + exp: false, + }, + "different type, same key": { + src: mockPrimaryKeyed{&myPersistentObj}, + exp: false, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + got := tb.Contains(ctx, spec.src) + assert.Equal(t, spec.exp, got) + }) + } +} + +func TestAddLengthPrefix(t *testing.T) { + tcs := []struct { + name string + in []byte + expected []byte + }{ + {"empty", []byte{}, []byte{0}}, + {"nil", nil, []byte{0}}, + {"some data", []byte{0, 1, 100, 200}, []byte{4, 0, 1, 100, 200}}, + } + for _, tc := range tcs { + t.Run(tc.name, func(t *testing.T) { + out := orm.AddLengthPrefix(tc.in) + require.Equal(t, tc.expected, out) + }) + } + + require.Panics(t, func() { + orm.AddLengthPrefix(make([]byte, 300)) + }) +} + +func TestNullTerminatedBytes(t *testing.T) { + tcs := []struct { + name string + in string + expected []byte + }{ + {"empty", "", []byte{0}}, + {"some data", "abc", []byte{0x61, 0x62, 0x63, 0}}, + } + for _, tc := range tcs { + t.Run(tc.name, func(t *testing.T) { + out := orm.NullTerminatedBytes(tc.in) + require.Equal(t, tc.expected, out) + }) + } +} + +type mockPrimaryKeyed struct { + *testdata.GroupMember +} diff --git a/regen/orm/sequence.go b/regen/orm/sequence.go new file mode 100644 index 0000000000..11b1b186c7 --- /dev/null +++ b/regen/orm/sequence.go @@ -0,0 +1,83 @@ +package orm + +import ( + "encoding/binary" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" +) + +// sequenceStorageKey is a fix key to read/ write data on the storage layer +var sequenceStorageKey = []byte{0x1} + +// sequence is a persistent unique key generator based on a counter. +type Sequence struct { + storeKey sdk.StoreKey + prefix byte +} + +func NewSequence(storeKey sdk.StoreKey, prefix byte) Sequence { + return Sequence{ + prefix: prefix, + storeKey: storeKey, + } +} + +// NextVal increments and persists the counter by one and returns the value. +func (s Sequence) NextVal(ctx HasKVStore) uint64 { + store := prefix.NewStore(ctx.KVStore(s.storeKey), []byte{s.prefix}) + v := store.Get(sequenceStorageKey) + seq := DecodeSequence(v) + seq++ + store.Set(sequenceStorageKey, EncodeSequence(seq)) + return seq +} + +// CurVal returns the last value used. 0 if none. +func (s Sequence) CurVal(ctx HasKVStore) uint64 { + store := prefix.NewStore(ctx.KVStore(s.storeKey), []byte{s.prefix}) + v := store.Get(sequenceStorageKey) + return DecodeSequence(v) +} + +// PeekNextVal returns the CurVal + increment step. Not persistent. +func (s Sequence) PeekNextVal(ctx HasKVStore) uint64 { + store := prefix.NewStore(ctx.KVStore(s.storeKey), []byte{s.prefix}) + v := store.Get(sequenceStorageKey) + return DecodeSequence(v) + 1 +} + +// InitVal sets the start value for the sequence. It must be called only once on an empty DB. +// Otherwise an error is returned when the key exists. The given start value is stored as current +// value. +// +// It is recommended to call this method only for a sequence start value other than `1` as the +// method consumes unnecessary gas otherwise. A scenario would be an import from genesis. +func (s Sequence) InitVal(ctx HasKVStore, seq uint64) error { + store := prefix.NewStore(ctx.KVStore(s.storeKey), []byte{s.prefix}) + if store.Has(sequenceStorageKey) { + return errors.Wrap(ErrUniqueConstraint, "already initialized") + } + store.Set(sequenceStorageKey, EncodeSequence(seq)) + return nil +} + +// DecodeSequence converts the binary representation into an Uint64 value. +func DecodeSequence(bz []byte) uint64 { + if bz == nil { + return 0 + } + val := binary.BigEndian.Uint64(bz) + return val +} + +// EncodedSeqLength number of bytes used for the binary representation of a sequence value. +const EncodedSeqLength = 8 + +// EncodeSequence converts the sequence value into the binary representation. +func EncodeSequence(val uint64) []byte { + bz := make([]byte, EncodedSeqLength) + binary.BigEndian.PutUint64(bz, val) + return bz +} diff --git a/regen/orm/sequence_property_test.go b/regen/orm/sequence_property_test.go new file mode 100644 index 0000000000..459551f250 --- /dev/null +++ b/regen/orm/sequence_property_test.go @@ -0,0 +1,70 @@ +package orm_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "pgregory.net/rapid" + + "github.com/cosmos/cosmos-sdk/regen/orm" +) + +func TestSequence(t *testing.T) { + rapid.Check(t, rapid.Run(&sequenceMachine{})) +} + +// sequenceMachine is a state machine model of Sequence. It simply uses a uint64 +// as the model of the sequence. +type sequenceMachine struct { + ctx orm.HasKVStore + seq *orm.Sequence + state uint64 +} + +// Init sets up the real Sequence, including choosing a random initial value, +// and intialises the model state +func (m *sequenceMachine) Init(t *rapid.T) { + // Create context + m.ctx = orm.NewMockContext() + + // Create primary key table + storeKey := sdk.NewKVStoreKey("test") + seq := orm.NewSequence(storeKey, 0x1) + m.seq = &seq + + // Choose initial sequence value + initSeqVal := rapid.Uint64().Draw(t, "initSeqVal").(uint64) + err := m.seq.InitVal(m.ctx, initSeqVal) + require.NoError(t, err) + + // Create model state + m.state = initSeqVal +} + +// Check does nothing, because all our invariants are captured in the commands +func (m *sequenceMachine) Check(t *rapid.T) {} + +// NextVal is one of the model commands. It checks that the next value of the +// sequence matches the model and increments the model state. +func (m *sequenceMachine) NextVal(t *rapid.T) { + // Check that the next value in the sequence matches the model + require.Equal(t, m.state+1, m.seq.NextVal(m.ctx)) + + // Increment the model state + m.state++ +} + +// CurVal is one of the model commands. It checks that the current value of the +// sequence matches the model. +func (m *sequenceMachine) CurVal(t *rapid.T) { + // Check the the current value matches the model + require.Equal(t, m.state, m.seq.CurVal(m.ctx)) +} + +// PeekNextVal is one of the model commands. It checks that the next value of +// the sequence matches the model without modifying the state. +func (m *sequenceMachine) PeekNextVal(t *rapid.T) { + // Check that the next value in the sequence matches the model + require.Equal(t, m.state+1, m.seq.PeekNextVal(m.ctx)) +} diff --git a/regen/orm/sequence_test.go b/regen/orm/sequence_test.go new file mode 100644 index 0000000000..6addc09055 --- /dev/null +++ b/regen/orm/sequence_test.go @@ -0,0 +1,24 @@ +package orm + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" +) + +func TestSequenceIncrements(t *testing.T) { + storeKey := sdk.NewKVStoreKey("test") + ctx := NewMockContext() + + seq := NewSequence(storeKey, 0x1) + var i uint64 + for i = 1; i < 10; i++ { + autoID := seq.NextVal(ctx) + assert.Equal(t, i, autoID) + assert.Equal(t, i, seq.CurVal(ctx)) + } + // and persisted + seq = NewSequence(storeKey, 0x1) + assert.Equal(t, uint64(9), seq.CurVal(ctx)) +} diff --git a/regen/orm/table.go b/regen/orm/table.go new file mode 100644 index 0000000000..8708492bd1 --- /dev/null +++ b/regen/orm/table.go @@ -0,0 +1,303 @@ +package orm + +import ( + "bytes" + "reflect" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" + "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" +) + +var _ Indexable = &tableBuilder{} + +type tableBuilder struct { + model reflect.Type + prefixData byte + storeKey sdk.StoreKey + indexKeyCodec IndexKeyCodec + afterSave []AfterSaveInterceptor + afterDelete []AfterDeleteInterceptor + cdc codec.Codec +} + +// newTableBuilder creates a builder to setup a table object. +func newTableBuilder(prefixData byte, storeKey sdk.StoreKey, model codec.ProtoMarshaler, idxKeyCodec IndexKeyCodec, cdc codec.Codec) *tableBuilder { + if model == nil { + panic("Model must not be nil") + } + if storeKey == nil { + panic("StoreKey must not be nil") + } + if idxKeyCodec == nil { + panic("IndexKeyCodec must not be nil") + } + tp := reflect.TypeOf(model) + if tp.Kind() == reflect.Ptr { + tp = tp.Elem() + } + return &tableBuilder{ + prefixData: prefixData, + storeKey: storeKey, + model: tp, + indexKeyCodec: idxKeyCodec, + cdc: cdc, + } +} + +// TestTableBuilder exposes the private tableBuilder type for testing purposes. +// It is not safe to use this outside of test code. +func TestTableBuilder(prefixData byte, storeKey sdk.StoreKey, model codec.ProtoMarshaler, idxKeyCodec IndexKeyCodec, cdc codec.Codec) *tableBuilder { + return newTableBuilder(prefixData, storeKey, model, idxKeyCodec, cdc) +} + +func (a tableBuilder) IndexKeyCodec() IndexKeyCodec { + return a.indexKeyCodec +} + +// RowGetter returns a type safe RowGetter. +func (a tableBuilder) RowGetter() RowGetter { + return NewTypeSafeRowGetter(a.storeKey, a.prefixData, a.model, a.cdc) +} + +func (a tableBuilder) StoreKey() sdk.StoreKey { + return a.storeKey +} + +// Build creates a new table object. +func (a tableBuilder) Build() table { + return table{ + model: a.model, + prefix: a.prefixData, + storeKey: a.storeKey, + afterSave: a.afterSave, + afterDelete: a.afterDelete, + cdc: a.cdc, + } +} + +// AddAfterSaveInterceptor can be used to register a callback function that is executed after an object is created and/or updated. +func (a *tableBuilder) AddAfterSaveInterceptor(interceptor AfterSaveInterceptor) { + a.afterSave = append(a.afterSave, interceptor) +} + +// AddAfterDeleteInterceptor can be used to register a callback function that is executed after an object is deleted. +func (a *tableBuilder) AddAfterDeleteInterceptor(interceptor AfterDeleteInterceptor) { + a.afterDelete = append(a.afterDelete, interceptor) +} + +var _ TableExportable = &table{} + +// table is the high level object to storage mapper functionality. Persistent +// entities are stored by an unique identifier called `RowID`. The table struct +// does not: +// - enforce uniqueness of the `RowID` +// - enforce prefix uniqueness of keys, i.e. not allowing one key to be a prefix +// of another +// - optimize Gas usage conditions +// The caller must ensure that these things are handled. The table struct is +// private, so that we only custom tables built on top of table, that do satisfy +// these requirements. +type table struct { + model reflect.Type + prefix byte + storeKey sdk.StoreKey + afterSave []AfterSaveInterceptor + afterDelete []AfterDeleteInterceptor + cdc codec.Codec +} + +// Create persists the given object under the rowID key. It does not check if the +// key already exists. Any caller must either make sure that this contract is fulfilled +// by providing a universal unique ID or sequence that is guaranteed to not exist yet or +// by checking the state via `Has` function before. +// +// Create iterates though the registered callbacks and may add secondary index keys by them. +func (a table) Create(ctx HasKVStore, rowID RowID, obj codec.ProtoMarshaler) error { + if len(rowID) == 0 { + return ErrEmptyKey + } + if err := assertCorrectType(a.model, obj); err != nil { + return err + } + if err := assertValid(obj); err != nil { + return err + } + store := prefix.NewStore(ctx.KVStore(a.storeKey), []byte{a.prefix}) + v, err := a.cdc.Marshal(obj) + if err != nil { + return errors.Wrapf(err, "failed to serialize %T", obj) + } + store.Set(rowID, v) + for i, itc := range a.afterSave { + if err := itc(ctx, rowID, obj, nil); err != nil { + return errors.Wrapf(err, "interceptor %d failed", i) + } + } + return nil +} + +// Save updates the given object under the rowID key. It expects the key to exists already +// and fails with an `ErrNotFound` otherwise. Any caller must therefore make sure that this contract +// is fulfilled. Parameters must not be nil. +// +// Save iterates though the registered callbacks and may add or remove secondary index keys by them. +func (a table) Save(ctx HasKVStore, rowID RowID, newValue codec.ProtoMarshaler) error { + if err := assertCorrectType(a.model, newValue); err != nil { + return err + } + if err := assertValid(newValue); err != nil { + return err + } + + store := prefix.NewStore(ctx.KVStore(a.storeKey), []byte{a.prefix}) + var oldValue = reflect.New(a.model).Interface().(codec.ProtoMarshaler) + + if err := a.GetOne(ctx, rowID, oldValue); err != nil { + return errors.Wrap(err, "load old value") + } + newValueEncoded, err := a.cdc.Marshal(newValue) + if err != nil { + return errors.Wrapf(err, "failed to serialize %T", newValue) + } + + store.Set(rowID, newValueEncoded) + for i, itc := range a.afterSave { + if err := itc(ctx, rowID, newValue, oldValue); err != nil { + return errors.Wrapf(err, "interceptor %d failed", i) + } + } + return nil +} + +func assertValid(obj codec.ProtoMarshaler) error { + if v, ok := obj.(Validateable); ok { + if err := v.ValidateBasic(); err != nil { + return err + } + } + return nil +} + +// Delete removes the object under the rowID key. It expects the key to exists already +// and fails with a `ErrNotFound` otherwise. Any caller must therefore make sure that this contract +// is fulfilled. +// +// Delete iterates though the registered callbacks and removes secondary index keys by them. +func (a table) Delete(ctx HasKVStore, rowID RowID) error { + store := prefix.NewStore(ctx.KVStore(a.storeKey), []byte{a.prefix}) + + var oldValue = reflect.New(a.model).Interface().(codec.ProtoMarshaler) + if err := a.GetOne(ctx, rowID, oldValue); err != nil { + return errors.Wrap(err, "load old value") + } + store.Delete(rowID) + + for i, itc := range a.afterDelete { + if err := itc(ctx, rowID, oldValue); err != nil { + return errors.Wrapf(err, "delete interceptor %d failed", i) + } + } + return nil +} + +// Has checks if a key exists. Panics on nil key, and returns false on empty key. +func (a table) Has(ctx HasKVStore, key RowID) bool { + // We don't allow creation of values with an empty key, so Has will + // always return false + if len(key) == 0 { + return false + } + store := prefix.NewStore(ctx.KVStore(a.storeKey), []byte{a.prefix}) + it := store.Iterator(PrefixRange(key)) + defer it.Close() + return it.Valid() +} + +// GetOne load the object persisted for the given RowID into the dest parameter. +// If none exists `ErrNotFound` is returned instead. Parameters must not be nil. +func (a table) GetOne(ctx HasKVStore, rowID RowID, dest codec.ProtoMarshaler) error { + // We don't allow creation of values with an empty key, so we always + // return not found error + if len(rowID) == 0 { + return ErrNotFound + } + x := NewTypeSafeRowGetter(a.storeKey, a.prefix, a.model, a.cdc) + return x(ctx, rowID, dest) +} + +// PrefixScan returns an Iterator over a domain of keys in ascending order. End is exclusive. +// Start is an MultiKeyIndex key or prefix. It must be less than end, or the Iterator is invalid. +// Iterator must be closed by caller. +// To iterate over entire domain, use PrefixScan(nil, nil) +// +// WARNING: The use of a PrefixScan can be very expensive in terms of Gas. Please make sure you do not expose +// this as an endpoint to the public without further limits. +// Example: +// it, err := idx.PrefixScan(ctx, start, end) +// if err !=nil { +// return err +// } +// const defaultLimit = 20 +// it = LimitIterator(it, defaultLimit) +// +// CONTRACT: No writes may happen within a domain while an iterator exists over it. +func (a table) PrefixScan(ctx HasKVStore, start, end RowID) (Iterator, error) { + if start != nil && end != nil && bytes.Compare(start, end) >= 0 { + return NewInvalidIterator(), errors.Wrap(ErrArgument, "start must be before end") + } + store := prefix.NewStore(ctx.KVStore(a.storeKey), []byte{a.prefix}) + return &typeSafeIterator{ + ctx: ctx, + rowGetter: NewTypeSafeRowGetter(a.storeKey, a.prefix, a.model, a.cdc), + it: store.Iterator(start, end), + }, nil +} + +// ReversePrefixScan returns an Iterator over a domain of keys in descending order. End is exclusive. +// Start is an MultiKeyIndex key or prefix. It must be less than end, or the Iterator is invalid and error is returned. +// Iterator must be closed by caller. +// To iterate over entire domain, use PrefixScan(nil, nil) +// +// WARNING: The use of a ReversePrefixScan can be very expensive in terms of Gas. Please make sure you do not expose +// this as an endpoint to the public without further limits. See `LimitIterator` +// +// CONTRACT: No writes may happen within a domain while an iterator exists over it. +func (a table) ReversePrefixScan(ctx HasKVStore, start, end RowID) (Iterator, error) { + if start != nil && end != nil && bytes.Compare(start, end) >= 0 { + return NewInvalidIterator(), errors.Wrap(ErrArgument, "start must be before end") + } + store := prefix.NewStore(ctx.KVStore(a.storeKey), []byte{a.prefix}) + return &typeSafeIterator{ + ctx: ctx, + rowGetter: NewTypeSafeRowGetter(a.storeKey, a.prefix, a.model, a.cdc), + it: store.ReverseIterator(start, end), + }, nil +} + +func (a table) Table() table { + return a +} + +// typeSafeIterator is initialized with a type safe RowGetter only. +type typeSafeIterator struct { + ctx HasKVStore + rowGetter RowGetter + it types.Iterator +} + +func (i typeSafeIterator) LoadNext(dest codec.ProtoMarshaler) (RowID, error) { + if !i.it.Valid() { + return nil, ErrIteratorDone + } + rowID := i.it.Key() + i.it.Next() + return rowID, i.rowGetter(i.ctx, rowID, dest) +} + +func (i typeSafeIterator) Close() error { + i.it.Close() + return nil +} diff --git a/regen/orm/table_test.go b/regen/orm/table_test.go new file mode 100644 index 0000000000..26525f8bd5 --- /dev/null +++ b/regen/orm/table_test.go @@ -0,0 +1,129 @@ +package orm_test + +import ( + "fmt" + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/regen/orm" + "github.com/cosmos/cosmos-sdk/regen/orm/testdata" +) + +func TestCreate(t *testing.T) { + specs := map[string]struct { + src codec.ProtoMarshaler + expErr *errors.Error + }{ + "happy path": { + src: &testdata.GroupInfo{ + Description: "my group", + Admin: sdk.AccAddress([]byte("my-admin-address")), + }, + }, + "wrong type": { + src: &testdata.GroupMember{ + Group: sdk.AccAddress(orm.EncodeSequence(1)), + Member: sdk.AccAddress([]byte("member-address")), + Weight: 10, + }, + expErr: orm.ErrType, + }, + "model validation fails": { + src: &testdata.GroupInfo{Description: "invalid"}, + expErr: testdata.ErrTest, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + storeKey := sdk.NewKVStoreKey("test") + const anyPrefix = 0x10 + tableBuilder := orm.TestTableBuilder(anyPrefix, storeKey, &testdata.GroupInfo{}, orm.Max255DynamicLengthIndexKeyCodec{}, cdc) + myTable := tableBuilder.Build() + + ctx := orm.NewMockContext() + err := myTable.Create(ctx, []byte("my-id"), spec.src) + + require.True(t, spec.expErr.Is(err), err) + shouldExists := spec.expErr == nil + assert.Equal(t, shouldExists, myTable.Has(ctx, []byte("my-id")), fmt.Sprintf("expected %v", shouldExists)) + + // then + var loaded testdata.GroupInfo + err = myTable.GetOne(ctx, []byte("my-id"), &loaded) + if spec.expErr != nil { + require.True(t, orm.ErrNotFound.Is(err)) + return + } + require.NoError(t, err) + assert.Equal(t, spec.src, &loaded) + }) + } + +} +func TestUpdate(t *testing.T) { + specs := map[string]struct { + src codec.ProtoMarshaler + expErr *errors.Error + }{ + "happy path": { + src: &testdata.GroupInfo{ + Description: "my group", + Admin: sdk.AccAddress([]byte("my-admin-address")), + }, + }, + "wrong type": { + src: &testdata.GroupMember{ + Group: sdk.AccAddress(orm.EncodeSequence(1)), + Member: sdk.AccAddress([]byte("member-address")), + Weight: 9999, + }, + expErr: orm.ErrType, + }, + "model validation fails": { + src: &testdata.GroupInfo{Description: "invalid"}, + expErr: testdata.ErrTest, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + storeKey := sdk.NewKVStoreKey("test") + const anyPrefix = 0x10 + tableBuilder := orm.TestTableBuilder(anyPrefix, storeKey, &testdata.GroupInfo{}, orm.Max255DynamicLengthIndexKeyCodec{}, cdc) + myTable := tableBuilder.Build() + + initValue := testdata.GroupInfo{ + Description: "my old group description", + Admin: sdk.AccAddress([]byte("my-old-admin-address")), + } + ctx := orm.NewMockContext() + err := myTable.Create(ctx, []byte("my-id"), &initValue) + require.NoError(t, err) + + // when + err = myTable.Save(ctx, []byte("my-id"), spec.src) + require.True(t, spec.expErr.Is(err), "got ", err) + + // then + var loaded testdata.GroupInfo + require.NoError(t, myTable.GetOne(ctx, []byte("my-id"), &loaded)) + if spec.expErr == nil { + assert.Equal(t, spec.src, &loaded) + } else { + assert.Equal(t, initValue, loaded) + } + }) + } + +} diff --git a/regen/orm/testdata/codec.pb.go b/regen/orm/testdata/codec.pb.go new file mode 100644 index 0000000000..237ff71592 --- /dev/null +++ b/regen/orm/testdata/codec.pb.go @@ -0,0 +1,679 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: codec.proto + +package testdata + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/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 + +type GroupInfo struct { + GroupId uint64 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Admin github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,3,opt,name=admin,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"admin,omitempty"` +} + +func (m *GroupInfo) Reset() { *m = GroupInfo{} } +func (m *GroupInfo) String() string { return proto.CompactTextString(m) } +func (*GroupInfo) ProtoMessage() {} +func (*GroupInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_9610d574777ab505, []int{0} +} +func (m *GroupInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GroupInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GroupInfo.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 *GroupInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_GroupInfo.Merge(m, src) +} +func (m *GroupInfo) XXX_Size() int { + return m.Size() +} +func (m *GroupInfo) XXX_DiscardUnknown() { + xxx_messageInfo_GroupInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_GroupInfo proto.InternalMessageInfo + +func (m *GroupInfo) GetGroupId() uint64 { + if m != nil { + return m.GroupId + } + return 0 +} + +func (m *GroupInfo) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *GroupInfo) GetAdmin() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Admin + } + return nil +} + +type GroupMember struct { + Group github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=group,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"group,omitempty"` + Member github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=member,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"member,omitempty"` + Weight uint64 `protobuf:"varint,3,opt,name=weight,proto3" json:"weight,omitempty"` +} + +func (m *GroupMember) Reset() { *m = GroupMember{} } +func (m *GroupMember) String() string { return proto.CompactTextString(m) } +func (*GroupMember) ProtoMessage() {} +func (*GroupMember) Descriptor() ([]byte, []int) { + return fileDescriptor_9610d574777ab505, []int{1} +} +func (m *GroupMember) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GroupMember) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GroupMember.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 *GroupMember) XXX_Merge(src proto.Message) { + xxx_messageInfo_GroupMember.Merge(m, src) +} +func (m *GroupMember) XXX_Size() int { + return m.Size() +} +func (m *GroupMember) XXX_DiscardUnknown() { + xxx_messageInfo_GroupMember.DiscardUnknown(m) +} + +var xxx_messageInfo_GroupMember proto.InternalMessageInfo + +func (m *GroupMember) GetGroup() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Group + } + return nil +} + +func (m *GroupMember) GetMember() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Member + } + return nil +} + +func (m *GroupMember) GetWeight() uint64 { + if m != nil { + return m.Weight + } + return 0 +} + +func init() { + proto.RegisterType((*GroupInfo)(nil), "testdata.GroupInfo") + proto.RegisterType((*GroupMember)(nil), "testdata.GroupMember") +} + +func init() { proto.RegisterFile("codec.proto", fileDescriptor_9610d574777ab505) } + +var fileDescriptor_9610d574777ab505 = []byte{ + // 296 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0xb1, 0x4e, 0xc3, 0x30, + 0x10, 0x86, 0x6b, 0x28, 0xa5, 0x75, 0x99, 0x2c, 0x84, 0x0a, 0x83, 0x89, 0x3a, 0x75, 0x69, 0x23, + 0xe0, 0x09, 0xda, 0xa5, 0xaa, 0x04, 0x4b, 0x46, 0x16, 0x94, 0xd8, 0x87, 0x6b, 0x15, 0xe7, 0x22, + 0xdb, 0x55, 0xc5, 0x5b, 0xc0, 0xe3, 0xf0, 0x06, 0x8c, 0x1d, 0x99, 0x10, 0x4a, 0xde, 0x82, 0x09, + 0xc5, 0x0d, 0x52, 0xe7, 0x4e, 0xf6, 0x7f, 0xd6, 0x7d, 0xfe, 0x4e, 0x47, 0xfb, 0x02, 0x25, 0x88, + 0x49, 0x61, 0xd1, 0x23, 0xeb, 0x7a, 0x70, 0x5e, 0xa6, 0x3e, 0xbd, 0x3a, 0x57, 0xa8, 0x30, 0x14, + 0xe3, 0xfa, 0xb6, 0x7b, 0x1f, 0xbe, 0x13, 0xda, 0x9b, 0x5b, 0x5c, 0x17, 0x8b, 0xfc, 0x19, 0xd9, + 0x25, 0xed, 0xaa, 0x3a, 0x3c, 0x69, 0x39, 0x20, 0x11, 0x19, 0xb5, 0x93, 0xd3, 0x90, 0x17, 0x92, + 0x45, 0xb4, 0x2f, 0xc1, 0x09, 0xab, 0x0b, 0xaf, 0x31, 0x1f, 0x1c, 0x45, 0x64, 0xd4, 0x4b, 0xf6, + 0x4b, 0x6c, 0x4e, 0x4f, 0x52, 0x69, 0x74, 0x3e, 0x38, 0x8e, 0xc8, 0xe8, 0x6c, 0x76, 0xf3, 0xfb, + 0x7d, 0x3d, 0x56, 0xda, 0x2f, 0xd7, 0xd9, 0x44, 0xa0, 0x89, 0x05, 0x3a, 0x83, 0xae, 0x39, 0xc6, + 0x4e, 0xae, 0x62, 0xff, 0x5a, 0x80, 0x9b, 0x4c, 0x85, 0x98, 0x4a, 0x69, 0xc1, 0xb9, 0x64, 0xd7, + 0x3f, 0xfc, 0x20, 0xb4, 0x1f, 0x9c, 0x1e, 0xc0, 0x64, 0x60, 0x6b, 0x70, 0xb0, 0x08, 0x4a, 0x87, + 0x81, 0x43, 0x3f, 0x5b, 0xd0, 0x8e, 0x09, 0xc8, 0xa0, 0x7f, 0x10, 0xa9, 0x01, 0xb0, 0x0b, 0xda, + 0xd9, 0x80, 0x56, 0x4b, 0x1f, 0xa6, 0x6d, 0x27, 0x4d, 0x9a, 0xdd, 0x7f, 0x96, 0x9c, 0x6c, 0x4b, + 0x4e, 0x7e, 0x4a, 0x4e, 0xde, 0x2a, 0xde, 0xda, 0x56, 0xbc, 0xf5, 0x55, 0xf1, 0xd6, 0xe3, 0xed, + 0xde, 0x47, 0x16, 0x14, 0xe4, 0xe3, 0x1c, 0xfc, 0x06, 0xed, 0xaa, 0x49, 0x2f, 0x20, 0x15, 0xd8, + 0x18, 0xad, 0x89, 0xff, 0x77, 0x96, 0x75, 0xc2, 0x92, 0xee, 0xfe, 0x02, 0x00, 0x00, 0xff, 0xff, + 0xb9, 0xf0, 0xdf, 0xf7, 0xd3, 0x01, 0x00, 0x00, +} + +func (m *GroupInfo) 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 *GroupInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GroupInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintCodec(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintCodec(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if m.GroupId != 0 { + i = encodeVarintCodec(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *GroupMember) 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 *GroupMember) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GroupMember) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Weight != 0 { + i = encodeVarintCodec(dAtA, i, uint64(m.Weight)) + i-- + dAtA[i] = 0x18 + } + if len(m.Member) > 0 { + i -= len(m.Member) + copy(dAtA[i:], m.Member) + i = encodeVarintCodec(dAtA, i, uint64(len(m.Member))) + i-- + dAtA[i] = 0x12 + } + if len(m.Group) > 0 { + i -= len(m.Group) + copy(dAtA[i:], m.Group) + i = encodeVarintCodec(dAtA, i, uint64(len(m.Group))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintCodec(dAtA []byte, offset int, v uint64) int { + offset -= sovCodec(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GroupInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovCodec(uint64(m.GroupId)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovCodec(uint64(l)) + } + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovCodec(uint64(l)) + } + return n +} + +func (m *GroupMember) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Group) + if l > 0 { + n += 1 + l + sovCodec(uint64(l)) + } + l = len(m.Member) + if l > 0 { + n += 1 + l + sovCodec(uint64(l)) + } + if m.Weight != 0 { + n += 1 + sovCodec(uint64(m.Weight)) + } + return n +} + +func sovCodec(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCodec(x uint64) (n int) { + return sovCodec(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GroupInfo) 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 ErrIntOverflowCodec + } + 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: GroupInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GroupInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + 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 ErrIntOverflowCodec + } + 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 ErrInvalidLengthCodec + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = append(m.Admin[:0], dAtA[iNdEx:postIndex]...) + if m.Admin == nil { + m.Admin = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCodec(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCodec + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCodec + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GroupMember) 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 ErrIntOverflowCodec + } + 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: GroupMember: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GroupMember: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Group", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Group = append(m.Group[:0], dAtA[iNdEx:postIndex]...) + if m.Group == nil { + m.Group = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Member", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Member = append(m.Member[:0], dAtA[iNdEx:postIndex]...) + if m.Member == nil { + m.Member = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Weight", wireType) + } + m.Weight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Weight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipCodec(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCodec + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCodec + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCodec(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, ErrIntOverflowCodec + } + 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, ErrIntOverflowCodec + } + 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, ErrIntOverflowCodec + } + 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, ErrInvalidLengthCodec + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCodec + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCodec + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCodec = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCodec = fmt.Errorf("proto: unexpected end of group") +) diff --git a/regen/orm/testdata/codec.proto b/regen/orm/testdata/codec.proto new file mode 100644 index 0000000000..31e15fde63 --- /dev/null +++ b/regen/orm/testdata/codec.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package testdata; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/regen-network/regen-ledger/orm/testdata"; + +message GroupInfo { + uint64 group_id = 1; + string description = 2; + bytes admin = 3 [ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; +} + +message GroupMember { + bytes group = 1 [ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; + bytes member = 2 [ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; + uint64 weight = 3; +} diff --git a/regen/orm/testdata/model.go b/regen/orm/testdata/model.go new file mode 100644 index 0000000000..28b77df969 --- /dev/null +++ b/regen/orm/testdata/model.go @@ -0,0 +1,28 @@ +package testdata + +import ( + "github.com/cosmos/cosmos-sdk/types/errors" +) + +var ( + ErrTest = errors.Register("orm_testdata", 9999, "test") +) + +func (g GroupMember) PrimaryKeyFields() []interface{} { + return []interface{}{[]byte(g.Group), []byte(g.Member)} +} + +func (g GroupInfo) PrimaryKeyFields() []interface{} { + return []interface{}{g.GroupId} +} + +func (g GroupInfo) ValidateBasic() error { + if g.Description == "invalid" { + return errors.Wrap(ErrTest, "description") + } + return nil +} + +func (g GroupMember) ValidateBasic() error { + return nil +} diff --git a/regen/orm/testsupport.go b/regen/orm/testsupport.go new file mode 100644 index 0000000000..3f262150fb --- /dev/null +++ b/regen/orm/testsupport.go @@ -0,0 +1,135 @@ +package orm + +import ( + "fmt" + "io" + + "github.com/cosmos/cosmos-sdk/store" + "github.com/cosmos/cosmos-sdk/store/gaskv" + "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + dbm "github.com/tendermint/tm-db" +) + +type MockContext struct { + db *dbm.MemDB + store types.CommitMultiStore +} + +func NewMockContext() *MockContext { + db := dbm.NewMemDB() + return &MockContext{ + db: dbm.NewMemDB(), + store: store.NewCommitMultiStore(db), + } +} + +func (m MockContext) KVStore(key sdk.StoreKey) sdk.KVStore { + if s := m.store.GetCommitKVStore(key); s != nil { + return s + } + m.store.MountStoreWithDB(key, sdk.StoreTypeIAVL, m.db) + if err := m.store.LoadLatestVersion(); err != nil { + panic(err) + } + return m.store.GetCommitKVStore(key) +} + +type debuggingGasMeter struct { + g types.GasMeter +} + +func (d debuggingGasMeter) GasConsumed() types.Gas { + return d.g.GasConsumed() +} + +func (d debuggingGasMeter) GasConsumedToLimit() types.Gas { + return d.g.GasConsumedToLimit() +} + +func (d debuggingGasMeter) RefundGas(amount uint64, descriptor string) { + d.g.RefundGas(amount, descriptor) +} + +func (d debuggingGasMeter) Limit() types.Gas { + return d.g.Limit() +} + +func (d debuggingGasMeter) ConsumeGas(amount types.Gas, descriptor string) { + fmt.Printf("++ Consuming gas: %q :%d\n", descriptor, amount) + d.g.ConsumeGas(amount, descriptor) +} + +func (d debuggingGasMeter) IsPastLimit() bool { + return d.g.IsPastLimit() +} + +func (d debuggingGasMeter) IsOutOfGas() bool { + return d.g.IsOutOfGas() +} + +func (d debuggingGasMeter) String() string { + return d.g.String() +} + +type GasCountingMockContext struct { + parent HasKVStore + GasMeter sdk.GasMeter +} + +func NewGasCountingMockContext(parent HasKVStore) *GasCountingMockContext { + return &GasCountingMockContext{ + parent: parent, + GasMeter: &debuggingGasMeter{sdk.NewInfiniteGasMeter()}, + } +} + +func (g GasCountingMockContext) KVStore(key sdk.StoreKey) sdk.KVStore { + return gaskv.NewStore(g.parent.KVStore(key), g.GasMeter, types.KVGasConfig()) +} + +func (g GasCountingMockContext) GasConsumed() types.Gas { + return g.GasMeter.GasConsumed() +} + +func (g *GasCountingMockContext) ResetGasMeter() { + g.GasMeter = sdk.NewInfiniteGasMeter() +} + +type AlwaysPanicKVStore struct{} + +func (a AlwaysPanicKVStore) GetStoreType() types.StoreType { + panic("Not implemented") +} + +func (a AlwaysPanicKVStore) CacheWrap() types.CacheWrap { + panic("Not implemented") +} + +func (a AlwaysPanicKVStore) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap { + panic("Not implemented") +} + +func (a AlwaysPanicKVStore) Get(key []byte) []byte { + panic("Not implemented") +} + +func (a AlwaysPanicKVStore) Has(key []byte) bool { + panic("Not implemented") +} + +func (a AlwaysPanicKVStore) Set(key, value []byte) { + panic("Not implemented") +} + +func (a AlwaysPanicKVStore) Delete(key []byte) { + panic("Not implemented") +} + +func (a AlwaysPanicKVStore) Iterator(start, end []byte) types.Iterator { + panic("Not implemented") +} + +func (a AlwaysPanicKVStore) ReverseIterator(start, end []byte) types.Iterator { + panic("Not implemented") +} diff --git a/regen/orm/uint64_index.go b/regen/orm/uint64_index.go new file mode 100644 index 0000000000..98e9b8cf63 --- /dev/null +++ b/regen/orm/uint64_index.go @@ -0,0 +1,85 @@ +package orm + +import ( + "github.com/cosmos/cosmos-sdk/types/query" +) + +// UInt64IndexerFunc creates one or multiple multiKeyIndex keys of type uint64 for the source object. +type UInt64IndexerFunc func(value interface{}) ([]uint64, error) + +// UInt64MultiKeyAdapter converts UInt64IndexerFunc to IndexerFunc +func UInt64MultiKeyAdapter(indexer UInt64IndexerFunc) IndexerFunc { + return func(value interface{}) ([]RowID, error) { + d, err := indexer(value) + if err != nil { + return nil, err + } + r := make([]RowID, len(d)) + for i, v := range d { + r[i] = EncodeSequence(v) + } + return r, nil + } +} + +// UInt64Index is a typed index. +type UInt64Index struct { + multiKeyIndex MultiKeyIndex +} + +// NewUInt64Index creates a typed secondary index +func NewUInt64Index(builder Indexable, prefix byte, indexer UInt64IndexerFunc) UInt64Index { + return UInt64Index{ + multiKeyIndex: NewIndex(builder, prefix, UInt64MultiKeyAdapter(indexer)), + } +} + +// Has checks if a key exists. Panics on nil key. +func (i UInt64Index) Has(ctx HasKVStore, key uint64) bool { + return i.multiKeyIndex.Has(ctx, EncodeSequence(key)) +} + +// Get returns a result iterator for the searchKey. Parameters must not be nil. +func (i UInt64Index) Get(ctx HasKVStore, searchKey uint64) (Iterator, error) { + return i.multiKeyIndex.Get(ctx, EncodeSequence(searchKey)) +} + +// GetPaginated creates an iterator for the searchKey +// starting from pageRequest.Key if provided. +// The pageRequest.Key is the rowID while searchKey is a MultiKeyIndex key. +func (i UInt64Index) GetPaginated(ctx HasKVStore, searchKey uint64, pageRequest *query.PageRequest) (Iterator, error) { + return i.multiKeyIndex.GetPaginated(ctx, EncodeSequence(searchKey), pageRequest) +} + +// PrefixScan returns an Iterator over a domain of keys in ascending order. End is exclusive. +// Start is an MultiKeyIndex key or prefix. It must be less than end, or the Iterator is invalid and error is returned. +// Iterator must be closed by caller. +// To iterate over entire domain, use PrefixScan(nil, nil) +// +// WARNING: The use of a PrefixScan can be very expensive in terms of Gas. Please make sure you do not expose +// this as an endpoint to the public without further limits. +// Example: +// it, err := idx.PrefixScan(ctx, start, end) +// if err !=nil { +// return err +// } +// const defaultLimit = 20 +// it = LimitIterator(it, defaultLimit) +// +// CONTRACT: No writes may happen within a domain while an iterator exists over it. +func (i UInt64Index) PrefixScan(ctx HasKVStore, start, end uint64) (Iterator, error) { + return i.multiKeyIndex.PrefixScan(ctx, EncodeSequence(start), EncodeSequence(end)) +} + +// ReversePrefixScan returns an Iterator over a domain of keys in descending order. End is exclusive. +// Start is an MultiKeyIndex key or prefix. It must be less than end, or the Iterator is invalid and error is returned. +// Iterator must be closed by caller. +// To iterate over entire domain, use PrefixScan(nil, nil) +// +// WARNING: The use of a ReversePrefixScan can be very expensive in terms of Gas. Please make sure you do not expose +// this as an endpoint to the public without further limits. See `LimitIterator` +// +// CONTRACT: No writes may happen within a domain while an iterator exists over it. +func (i UInt64Index) ReversePrefixScan(ctx HasKVStore, start, end uint64) (Iterator, error) { + return i.multiKeyIndex.ReversePrefixScan(ctx, EncodeSequence(start), EncodeSequence(end)) +} diff --git a/regen/orm/uint64_index_test.go b/regen/orm/uint64_index_test.go new file mode 100644 index 0000000000..5582c9338e --- /dev/null +++ b/regen/orm/uint64_index_test.go @@ -0,0 +1,163 @@ +package orm_test + +import ( + "errors" + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/regen/orm" + "github.com/cosmos/cosmos-sdk/regen/orm/testdata" +) + +func TestUInt64Index(t *testing.T) { + interfaceRegistry := types.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + storeKey := sdk.NewKVStoreKey("test") + + const anyPrefix = 0x10 + tableBuilder := orm.NewPrimaryKeyTableBuilder(anyPrefix, storeKey, &testdata.GroupMember{}, orm.Max255DynamicLengthIndexKeyCodec{}, cdc) + myIndex := orm.NewUInt64Index(tableBuilder, GroupMemberByMemberIndexPrefix, func(val interface{}) ([]uint64, error) { + return []uint64{uint64(val.(*testdata.GroupMember).Member[0])}, nil + }) + myTable := tableBuilder.Build() + + ctx := orm.NewMockContext() + + m := testdata.GroupMember{ + Group: sdk.AccAddress(orm.EncodeSequence(1)), + Member: sdk.AccAddress([]byte("member-address")), + Weight: 10, + } + err := myTable.Create(ctx, &m) + require.NoError(t, err) + + indexedKey := uint64('m') + + // Has + assert.True(t, myIndex.Has(ctx, indexedKey)) + + // Get + it, err := myIndex.Get(ctx, indexedKey) + require.NoError(t, err) + var loaded testdata.GroupMember + rowID, err := it.LoadNext(&loaded) + require.NoError(t, err) + require.Equal(t, uint64(0x800000000000000), orm.DecodeSequence(rowID)) + require.Equal(t, m, loaded) + + // GetPaginated + cases := map[string]struct { + pageReq *query.PageRequest + expErr bool + }{ + "nil key": { + pageReq: &query.PageRequest{Key: nil}, + expErr: false, + }, + "after indexed key": { + pageReq: &query.PageRequest{Key: []byte{byte('m')}}, + expErr: true, + }, + } + + for testName, tc := range cases { + t.Run(testName, func(t *testing.T) { + it, err := myIndex.GetPaginated(ctx, indexedKey, tc.pageReq) + require.NoError(t, err) + rowID, err := it.LoadNext(&loaded) + if tc.expErr { // iterator done + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, orm.RowID(orm.PrimaryKey(&m)), rowID) + require.Equal(t, m, loaded) + } + }) + } + + // PrefixScan match + it, err = myIndex.PrefixScan(ctx, 0, 255) + require.NoError(t, err) + rowID, err = it.LoadNext(&loaded) + require.NoError(t, err) + require.Equal(t, uint64(0x800000000000000), orm.DecodeSequence(rowID)) + require.Equal(t, m, loaded) + + // PrefixScan no match + it, err = myIndex.PrefixScan(ctx, indexedKey+1, 255) + require.NoError(t, err) + rowID, err = it.LoadNext(&loaded) + require.Error(t, orm.ErrIteratorDone, err) + + // ReversePrefixScan match + it, err = myIndex.ReversePrefixScan(ctx, 0, 255) + require.NoError(t, err) + rowID, err = it.LoadNext(&loaded) + require.NoError(t, err) + require.Equal(t, uint64(0x800000000000000), orm.DecodeSequence(rowID)) + require.Equal(t, m, loaded) + + // ReversePrefixScan no match + it, err = myIndex.ReversePrefixScan(ctx, indexedKey+1, 255) + require.NoError(t, err) + rowID, err = it.LoadNext(&loaded) + require.Error(t, orm.ErrIteratorDone, err) +} + +func TestUInt64MultiKeyAdapter(t *testing.T) { + specs := map[string]struct { + srcFunc orm.UInt64IndexerFunc + exp []orm.RowID + expErr error + }{ + "single key": { + srcFunc: func(value interface{}) ([]uint64, error) { + return []uint64{1}, nil + }, + exp: []orm.RowID{{0, 0, 0, 0, 0, 0, 0, 1}}, + }, + "multi key": { + srcFunc: func(value interface{}) ([]uint64, error) { + return []uint64{1, 1 << 56}, nil + }, + exp: []orm.RowID{{0, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 0}}, + }, + "empty key": { + srcFunc: func(value interface{}) ([]uint64, error) { + return []uint64{}, nil + }, + exp: []orm.RowID{}, + }, + "nil key": { + srcFunc: func(value interface{}) ([]uint64, error) { + return nil, nil + }, + exp: []orm.RowID{}, + }, + "error case": { + srcFunc: func(value interface{}) ([]uint64, error) { + return nil, errors.New("test") + }, + expErr: errors.New("test"), + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + fn := orm.UInt64MultiKeyAdapter(spec.srcFunc) + r, err := fn(nil) + if spec.expErr != nil { + require.Equal(t, spec.expErr, err) + return + } + require.NoError(t, err) + assert.Equal(t, spec.exp, r) + }) + } +} diff --git a/regen/types/address.go b/regen/types/address.go new file mode 100644 index 0000000000..11b83ce01e --- /dev/null +++ b/regen/types/address.go @@ -0,0 +1,13 @@ +package types + +import "crypto/sha256" + +func AddressHash(prefix string, contents []byte) []byte { + preImage := []byte(prefix) + if len(contents) != 0 { + preImage = append(preImage, 0) + preImage = append(preImage, contents...) + } + sum := sha256.Sum256(preImage) + return sum[:20] +} diff --git a/regen/types/conn.go b/regen/types/conn.go new file mode 100644 index 0000000000..936aa167c1 --- /dev/null +++ b/regen/types/conn.go @@ -0,0 +1,14 @@ +package types + +import ( + "context" + + "google.golang.org/grpc" +) + +type InvokerConn interface { + grpc.ClientConnInterface + Invoker(methodName string) (Invoker, error) +} + +type Invoker func(ctx context.Context, request, response interface{}, opts ...interface{}) error diff --git a/regen/types/context.go b/regen/types/context.go new file mode 100644 index 0000000000..40b8f0eb8b --- /dev/null +++ b/regen/types/context.go @@ -0,0 +1,33 @@ +package types + +import ( + "context" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type Context struct { + sdk.Context +} + +var _ context.Context = Context{} + +func (c Context) Deadline() (deadline time.Time, ok bool) { + return c.Context.Context().Deadline() +} + +func (c Context) Done() <-chan struct{} { + return c.Context.Context().Done() +} + +func (c Context) Err() error { + return c.Context.Context().Err() +} + +func UnwrapSDKContext(ctx context.Context) Context { + if sdkCtx, ok := ctx.(Context); ok { + return sdkCtx + } + return Context{sdk.UnwrapSDKContext(ctx)} +} diff --git a/regen/types/id.go b/regen/types/id.go new file mode 100644 index 0000000000..92fd410b87 --- /dev/null +++ b/regen/types/id.go @@ -0,0 +1,12 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +type ModuleID struct { + ModuleName string + Path []byte +} + +func (m ModuleID) Address() sdk.AccAddress { + return AddressHash(m.ModuleName, m.Path) +} diff --git a/regen/types/math/dec.go b/regen/types/math/dec.go new file mode 100644 index 0000000000..8470340513 --- /dev/null +++ b/regen/types/math/dec.go @@ -0,0 +1,172 @@ +package math + +import ( + "fmt" + "github.com/cockroachdb/apd/v2" + "github.com/cosmos/cosmos-sdk/types/errors" +) + +// Dec is a wrapper struct around apd.Decimal that does no mutation of apd.Decimal's when performing +// arithmetic, instead creating a new apd.Decimal for every operation ensuring usage is safe. +// +// Using apd.Decimal directly can be unsafe because apd operations mutate the underlying Decimal, +// but when copying the big.Int structure can be shared between Decimal instances causing corruption. +// This was originally discovered in regen0-network/mainnet#15. +type Dec struct { + dec apd.Decimal +} + +// In cosmos-sdk#7773, decimal128 (with 34 digits of precision) was suggested for performing +// Quo/Mult arithmetic generically across the SDK. Even though the SDK +// has yet to support a GDA with decimal128 (34 digits), we choose to utilize it here. +// https://github.com/cosmos/cosmos-sdk/issues/7773#issuecomment-725006142 +var dec128Context = apd.Context{ + Precision: 34, + MaxExponent: apd.MaxExponent, + MinExponent: apd.MinExponent, + Traps: apd.DefaultTraps, +} + +func NewDecFromString(s string) (Dec, error) { + d, _, err := apd.NewFromString(s) + if err != nil { + return Dec{}, err + } + return Dec{*d}, nil +} + +func NewNonNegativeDecFromString(s string) (Dec, error) { + d, err := NewDecFromString(s) + if err != nil { + return Dec{}, err + } + if d.IsNegative() { + return Dec{}, fmt.Errorf("cannot parse non negative decimal: %s", d.String()) + } + return d, nil +} + +func NewNonNegativeFixedDecFromString(s string, max uint32) (Dec, error) { + d, err := NewDecFromString(s) + if err != nil { + return Dec{}, err + } + if d.IsNegative() { + return Dec{}, fmt.Errorf("cannot parse non negative decimal: %s", d.String()) + } + if d.NumDecimalPlaces() > max { + return Dec{}, fmt.Errorf("%s exceeds maximum decimal places: %d", s, max) + } + return d, nil +} + +func NewPositiveFixedDecFromString(s string, max uint32) (Dec, error) { + d, err := NewDecFromString(s) + if err != nil { + return Dec{}, err + } + if !d.IsPositive() { + return Dec{}, fmt.Errorf("%s is not a positive decimal", d.String()) + } + if d.NumDecimalPlaces() > max { + return Dec{}, fmt.Errorf("%s exceeds maximum decimal places: %d", s, max) + } + return d, nil +} + +func NewDecFromInt64(x int64) Dec { + var res Dec + res.dec.SetInt64(x) + return res +} + +// Add returns a new Dec with value `x+y` without mutating any argument and error if +// there is an overflow. +func (x Dec) Add(y Dec) (Dec, error) { + var z Dec + _, err := apd.BaseContext.Add(&z.dec, &x.dec, &y.dec) + return z, errors.Wrap(err, "decimal addition error") +} + +// Sub returns a new Dec with value `x-y` without mutating any argument and error if +// there is an overflow. +func (x Dec) Sub(y Dec) (Dec, error) { + var z Dec + _, err := apd.BaseContext.Sub(&z.dec, &x.dec, &y.dec) + return z, errors.Wrap(err, "decimal subtraction error") +} + +// Quo returns a new Dec with value `x/y` (formatted as decimal128, 34 digit precision) without mutating any +// argument and error if there is an overflow. +func (x Dec) Quo(y Dec) (Dec, error) { + var z Dec + _, err := dec128Context.Quo(&z.dec, &x.dec, &y.dec) + return z, errors.Wrap(err, "decimal quotient error") +} + +// QuoInteger returns a new integral Dec with value `x/y` (formatted as decimal128, with 34 digit precision) +// without mutating any argument and error if there is an overflow. +func (x Dec) QuoInteger(y Dec) (Dec, error) { + var z Dec + _, err := dec128Context.QuoInteger(&z.dec, &x.dec, &y.dec) + return z, errors.Wrap(err, "decimal quotient error") +} + +// Rem returns the integral remainder from `x/y` (formatted as decimal128, with 34 digit precision) without +// mutating any argument and error if the integer part of x/y cannot fit in 34 digit precision +func (x Dec) Rem(y Dec) (Dec, error) { + var z Dec + _, err := dec128Context.Rem(&z.dec, &x.dec, &y.dec) + return z, errors.Wrap(err, "decimal remainder error") +} + +// Mul returns a new Dec with value `x*y` (formatted as decimal128, with 34 digit precision) without +// mutating any argument and error if there is an overflow. +func (x Dec) Mul(y Dec) (Dec, error) { + var z Dec + _, err := dec128Context.Mul(&z.dec, &x.dec, &y.dec) + return z, errors.Wrap(err, "decimal multiplication error") +} + +func (x Dec) Int64() (int64, error) { + return x.dec.Int64() +} + +func (x Dec) String() string { + return x.dec.Text('f') +} + +func (x Dec) Cmp(y Dec) int { + return x.dec.Cmp(&y.dec) +} + +func (x Dec) IsEqual(y Dec) bool { + return x.dec.Cmp(&y.dec) == 0 +} + +func (x Dec) IsZero() bool { + return x.dec.IsZero() +} + +func (x Dec) IsNegative() bool { + return x.dec.Negative && !x.dec.IsZero() +} + +func (x Dec) IsPositive() bool { + return !x.dec.Negative && !x.dec.IsZero() +} + +// NumDecimalPlaces returns the number of decimal places in x. +func (x Dec) NumDecimalPlaces() uint32 { + exp := x.dec.Exponent + if exp >= 0 { + return 0 + } + return uint32(-exp) +} + +func (x Dec) Reduce() (Dec, int) { + y := Dec{} + _, n := y.dec.Reduce(&x.dec) + return y, n +} diff --git a/regen/types/math/dec_test.go b/regen/types/math/dec_test.go new file mode 100644 index 0000000000..dcbd29a1db --- /dev/null +++ b/regen/types/math/dec_test.go @@ -0,0 +1,485 @@ +package math + +import ( + "fmt" + "regexp" + "strconv" + "testing" + + "github.com/stretchr/testify/require" + "pgregory.net/rapid" +) + +func TestDec(t *testing.T) { + + // Property tests + t.Run("TestNewDecFromInt64", rapid.MakeCheck(testDecInt64)) + + // Properties about addition + t.Run("TestAddLeftIdentity", rapid.MakeCheck(testAddLeftIdentity)) + t.Run("TestAddRightIdentity", rapid.MakeCheck(testAddRightIdentity)) + t.Run("TestAddCommutative", rapid.MakeCheck(testAddCommutative)) + t.Run("TestAddAssociative", rapid.MakeCheck(testAddAssociative)) + + // Properties about subtraction + t.Run("TestSubRightIdentity", rapid.MakeCheck(testSubRightIdentity)) + t.Run("TestSubZero", rapid.MakeCheck(testSubZero)) + + // Properties about multiplication + t.Run("TestMulLeftIdentity", rapid.MakeCheck(testMulLeftIdentity)) + t.Run("TestMulRightIdentity", rapid.MakeCheck(testMulRightIdentity)) + t.Run("TestMulCommutative", rapid.MakeCheck(testMulCommutative)) + t.Run("TestMulAssociative", rapid.MakeCheck(testMulAssociative)) + t.Run("TestZeroIdentity", rapid.MakeCheck(testMulZero)) + + // Properties about division + t.Run("TestDivisionBySelf", rapid.MakeCheck(testSelfQuo)) + t.Run("TestDivisionByOne", rapid.MakeCheck(testQuoByOne)) + + // Properties combining operations + t.Run("TestSubAdd", rapid.MakeCheck(testSubAdd)) + t.Run("TestAddSub", rapid.MakeCheck(testAddSub)) + t.Run("TestMulQuoA", rapid.MakeCheck(testMulQuoA)) + t.Run("TestMulQuoB", rapid.MakeCheck(testMulQuoB)) + + // Properties about comparision and equality + t.Run("TestCmpInverse", rapid.MakeCheck(testCmpInverse)) + t.Run("TestEqualCommutative", rapid.MakeCheck(testEqualCommutative)) + + // Properties about tests on a single Dec + t.Run("TestIsZero", rapid.MakeCheck(testIsZero)) + t.Run("TestIsNegative", rapid.MakeCheck(testIsNegative)) + t.Run("TestIsPositive", rapid.MakeCheck(testIsPositive)) + t.Run("TestNumDecimalPlaces", rapid.MakeCheck(testNumDecimalPlaces)) + + // Unit tests + zero := Dec{} + one := NewDecFromInt64(1) + two := NewDecFromInt64(2) + three := NewDecFromInt64(3) + four := NewDecFromInt64(4) + five := NewDecFromInt64(5) + minusOne := NewDecFromInt64(-1) + + onePointOneFive, err := NewDecFromString("1.15") + require.NoError(t, err) + twoPointThreeFour, err := NewDecFromString("2.34") + require.NoError(t, err) + threePointFourNine, err := NewDecFromString("3.49") + require.NoError(t, err) + onePointFourNine, err := NewDecFromString("1.49") + require.NoError(t, err) + minusFivePointZero, err := NewDecFromString("-5.0") + require.NoError(t, err) + + res, err := two.Add(zero) + require.NoError(t, err) + require.True(t, res.IsEqual(two)) + + res, err = five.Sub(two) + require.NoError(t, err) + require.True(t, res.IsEqual(three)) + + res, err = SafeSubBalance(five, two) + require.NoError(t, err) + require.True(t, res.IsEqual(three)) + + res, err = SafeSubBalance(two, five) + require.Error(t, err, "Expected insufficient funds error") + + res, err = SafeAddBalance(three, two) + require.NoError(t, err) + require.True(t, res.IsEqual(five)) + + res, err = SafeAddBalance(minusFivePointZero, five) + require.Error(t, err, "Expected ErrInvalidRequest") + + res, err = four.Quo(two) + require.NoError(t, err) + require.True(t, res.IsEqual(two)) + + res, err = five.QuoInteger(two) + require.NoError(t, err) + require.True(t, res.IsEqual(two)) + + res, err = five.Rem(two) + require.NoError(t, err) + require.True(t, res.IsEqual(one)) + + x, err := four.Int64() + require.NoError(t, err) + require.Equal(t, int64(4), x) + + require.Equal(t, "5", five.String()) + + res, err = onePointOneFive.Add(twoPointThreeFour) + require.NoError(t, err) + require.True(t, res.IsEqual(threePointFourNine)) + + res, err = threePointFourNine.Sub(two) + require.NoError(t, err) + require.True(t, res.IsEqual(onePointFourNine)) + + res, err = minusOne.Sub(four) + require.NoError(t, err) + require.True(t, res.IsEqual(minusFivePointZero)) + + require.True(t, zero.IsZero()) + require.False(t, zero.IsPositive()) + require.False(t, zero.IsNegative()) + + require.False(t, one.IsZero()) + require.True(t, one.IsPositive()) + require.False(t, one.IsNegative()) + + require.False(t, minusOne.IsZero()) + require.False(t, minusOne.IsPositive()) + require.True(t, minusOne.IsNegative()) +} + +// TODO: Think a bit more about the probability distribution of Dec +var genDec *rapid.Generator = rapid.Custom(func(t *rapid.T) Dec { + f := rapid.Float64().Draw(t, "f").(float64) + dec, err := NewDecFromString(fmt.Sprintf("%g", f)) + require.NoError(t, err) + return dec +}) + +// A Dec value and the float used to create it +type floatAndDec struct { + float float64 + dec Dec +} + +// Generate a Dec value along with the float used to create it +var genFloatAndDec *rapid.Generator = rapid.Custom(func(t *rapid.T) floatAndDec { + f := rapid.Float64().Draw(t, "f").(float64) + dec, err := NewDecFromString(fmt.Sprintf("%g", f)) + require.NoError(t, err) + return floatAndDec{f, dec} +}) + +// Property: n == NewDecFromInt64(n).Int64() +func testDecInt64(t *rapid.T) { + nIn := rapid.Int64().Draw(t, "n").(int64) + nOut, err := NewDecFromInt64(nIn).Int64() + + require.NoError(t, err) + require.Equal(t, nIn, nOut) +} + +// Property: 0 + a == a +func testAddLeftIdentity(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + zero := NewDecFromInt64(0) + + b, err := zero.Add(a) + require.NoError(t, err) + + require.True(t, a.IsEqual(b)) +} + +// Property: a + 0 == a +func testAddRightIdentity(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + zero := NewDecFromInt64(0) + + b, err := a.Add(zero) + require.NoError(t, err) + + require.True(t, a.IsEqual(b)) +} + +// Property: a + b == b + a +func testAddCommutative(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + b := genDec.Draw(t, "b").(Dec) + + c, err := a.Add(b) + require.NoError(t, err) + + d, err := b.Add(a) + require.NoError(t, err) + + require.True(t, c.IsEqual(d)) +} + +// Property: (a + b) + c == a + (b + c) +func testAddAssociative(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + b := genDec.Draw(t, "b").(Dec) + c := genDec.Draw(t, "c").(Dec) + + // (a + b) + c + d, err := a.Add(b) + require.NoError(t, err) + + e, err := d.Add(c) + require.NoError(t, err) + + // a + (b + c) + f, err := b.Add(c) + require.NoError(t, err) + + g, err := a.Add(f) + require.NoError(t, err) + + require.True(t, e.IsEqual(g)) +} + +// Property: a - 0 == a +func testSubRightIdentity(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + zero := NewDecFromInt64(0) + + b, err := a.Sub(zero) + require.NoError(t, err) + + require.True(t, a.IsEqual(b)) +} + +// Property: a - a == 0 +func testSubZero(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + zero := NewDecFromInt64(0) + + b, err := a.Sub(a) + require.NoError(t, err) + + require.True(t, b.IsEqual(zero)) +} + +// Property: 1 * a == a +func testMulLeftIdentity(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + one := NewDecFromInt64(1) + + b, err := one.Mul(a) + require.NoError(t, err) + + require.True(t, a.IsEqual(b)) +} + +// Property: a * 1 == a +func testMulRightIdentity(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + one := NewDecFromInt64(1) + + b, err := a.Mul(one) + require.NoError(t, err) + + require.True(t, a.IsEqual(b)) +} + +// Property: a * b == b * a +func testMulCommutative(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + b := genDec.Draw(t, "b").(Dec) + + c, err := a.Mul(b) + require.NoError(t, err) + + d, err := b.Mul(a) + require.NoError(t, err) + + require.True(t, c.IsEqual(d)) +} + +// Property: (a * b) * c == a * (b * c) +func testMulAssociative(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + b := genDec.Draw(t, "b").(Dec) + c := genDec.Draw(t, "c").(Dec) + + // (a * b) * c + d, err := a.Mul(b) + require.NoError(t, err) + + e, err := d.Mul(c) + require.NoError(t, err) + + // a * (b * c) + f, err := b.Mul(c) + require.NoError(t, err) + + g, err := a.Mul(f) + require.NoError(t, err) + + require.True(t, e.IsEqual(g)) +} + +// Property: (a - b) + b == a +func testSubAdd(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + b := genDec.Draw(t, "b").(Dec) + + c, err := a.Sub(b) + require.NoError(t, err) + + d, err := c.Add(b) + require.NoError(t, err) + + require.True(t, a.IsEqual(d)) +} + +// Property: (a + b) - b == a +func testAddSub(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + b := genDec.Draw(t, "b").(Dec) + + c, err := a.Add(b) + require.NoError(t, err) + + d, err := c.Sub(b) + require.NoError(t, err) + + require.True(t, a.IsEqual(d)) +} + +// Property: a * 0 = 0 +func testMulZero(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + zero := Dec{} + + c, err := a.Mul(zero) + require.NoError(t, err) + require.True(t, c.IsZero()) +} + +// Property: a/a = 1 +func testSelfQuo(t *rapid.T) { + decNotZero := func(d Dec) bool { return !d.IsZero() } + a := genDec.Filter(decNotZero).Draw(t, "a").(Dec) + one := NewDecFromInt64(1) + + b, err := a.Quo(a) + require.NoError(t, err) + require.True(t, one.IsEqual(b)) +} + +// Property: a/1 = a +func testQuoByOne(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + one := NewDecFromInt64(1) + + b, err := a.Quo(one) + require.NoError(t, err) + require.True(t, a.IsEqual(b)) +} + +// Property: (a * b) / a == b +func testMulQuoA(t *rapid.T) { + decNotZero := func(d Dec) bool { return !d.IsZero() } + a := genDec.Filter(decNotZero).Draw(t, "a").(Dec) + b := genDec.Draw(t, "b").(Dec) + + c, err := a.Mul(b) + require.NoError(t, err) + + d, err := c.Quo(a) + require.NoError(t, err) + + require.True(t, b.IsEqual(d)) +} + +// Property: (a * b) / b == a +func testMulQuoB(t *rapid.T) { + decNotZero := func(d Dec) bool { return !d.IsZero() } + a := genDec.Draw(t, "a").(Dec) + b := genDec.Filter(decNotZero).Draw(t, "b").(Dec) + + c, err := a.Mul(b) + require.NoError(t, err) + + d, err := c.Quo(b) + require.NoError(t, err) + + require.True(t, a.IsEqual(d)) +} + +// Property: Cmp(a, b) == -Cmp(b, a) +func testCmpInverse(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + b := genDec.Draw(t, "b").(Dec) + + require.Equal(t, a.Cmp(b), -b.Cmp(a)) +} + +// Property: IsEqual(a, b) == IsEqual(b, a) +func testEqualCommutative(t *rapid.T) { + a := genDec.Draw(t, "a").(Dec) + b := genDec.Draw(t, "b").(Dec) + + require.Equal(t, a.IsEqual(b), b.IsEqual(a)) +} + +// Property: isZero(f) == isZero(NewDecFromString(f.String())) +func testIsZero(t *rapid.T) { + floatAndDec := genFloatAndDec.Draw(t, "floatAndDec").(floatAndDec) + f, dec := floatAndDec.float, floatAndDec.dec + + require.Equal(t, f == 0, dec.IsZero()) + +} + +// Property: isNegative(f) == isNegative(NewDecFromString(f.String())) +func testIsNegative(t *rapid.T) { + floatAndDec := genFloatAndDec.Draw(t, "floatAndDec").(floatAndDec) + f, dec := floatAndDec.float, floatAndDec.dec + + require.Equal(t, f < 0, dec.IsNegative()) +} + +// Property: isPositive(f) == isPositive(NewDecFromString(f.String())) +func testIsPositive(t *rapid.T) { + floatAndDec := genFloatAndDec.Draw(t, "floatAndDec").(floatAndDec) + f, dec := floatAndDec.float, floatAndDec.dec + + require.Equal(t, f > 0, dec.IsPositive()) +} + +// Property: floatDecimalPlaces(f) == NumDecimalPlaces(NewDecFromString(f.String())) +func testNumDecimalPlaces(t *rapid.T) { + floatAndDec := genFloatAndDec.Draw(t, "floatAndDec").(floatAndDec) + f, dec := floatAndDec.float, floatAndDec.dec + + require.Equal(t, floatDecimalPlaces(t, f), dec.NumDecimalPlaces()) +} + +func floatDecimalPlaces(t *rapid.T, f float64) uint32 { + reScientific := regexp.MustCompile(`^\-?(?:[[:digit:]]+(?:\.([[:digit:]]+))?|\.([[:digit:]]+))(?:e?(?:\+?([[:digit:]]+)|(-[[:digit:]]+)))?$`) + fStr := fmt.Sprintf("%g", f) + matches := reScientific.FindAllStringSubmatch(fStr, 1) + if len(matches) != 1 { + t.Fatalf("Didn't match float: %g", f) + } + + // basePlaces is the number of decimal places in the decimal part of the + // string + basePlaces := 0 + if matches[0][1] != "" { + basePlaces = len(matches[0][1]) + } else if matches[0][2] != "" { + basePlaces = len(matches[0][2]) + } + t.Logf("Base places: %d", basePlaces) + + // exp is the exponent + exp := 0 + if matches[0][3] != "" { + var err error + exp, err = strconv.Atoi(matches[0][3]) + require.NoError(t, err) + } else if matches[0][4] != "" { + var err error + exp, err = strconv.Atoi(matches[0][4]) + require.NoError(t, err) + } + + // Subtract exponent from base and check if negative + if res := basePlaces - exp; res <= 0 { + return 0 + } else { + return uint32(res) + } +} diff --git a/regen/types/math/math.go b/regen/types/math/math.go new file mode 100644 index 0000000000..9416271131 --- /dev/null +++ b/regen/types/math/math.go @@ -0,0 +1,147 @@ +// Package math provides helper functions for doing mathematical calculations and parsing for the ecocredit module. +package math + +import ( + "fmt" + + "github.com/cockroachdb/apd/v2" + + "github.com/cosmos/cosmos-sdk/types/errors" +) + +// Deprecated: ParseNonNegativeDecimal parses a non-negative decimal or returns an error. +func ParseNonNegativeDecimal(x string) (*apd.Decimal, error) { + res, _, err := apd.NewFromString(x) + if err != nil || res.Sign() < 0 { + return nil, errors.Wrap(errors.ErrInvalidRequest, fmt.Sprintf("expected a non-negative decimal, got %s", x)) + } + + return res, nil +} + +// Deprecated: ParsePositiveDecimal parses a positive decimal or returns an error. +func ParsePositiveDecimal(x string) (*apd.Decimal, error) { + res, _, err := apd.NewFromString(x) + if err != nil || res.Sign() <= 0 { + return nil, errors.Wrap(errors.ErrInvalidRequest, fmt.Sprintf("expected a positive decimal, got %s", x)) + } + + return res, nil +} + +// Deprecated: DecimalString prints x as a floating point string. +func DecimalString(x *apd.Decimal) string { + return x.Text('f') +} + +// Deprecated: NumDecimalPlaces returns the number of decimal places in x. +func NumDecimalPlaces(x *apd.Decimal) uint32 { + if x.Exponent >= 0 { + return 0 + } + return uint32(-x.Exponent) +} + +// Deprecated: ParseNonNegativeDecimal parses a non-negative decimal with a fixed maxDecimalPlaces or returns an error. +func ParseNonNegativeFixedDecimal(x string, maxDecimalPlaces uint32) (*apd.Decimal, error) { + res, err := ParseNonNegativeDecimal(x) + if err != nil { + return nil, err + } + + err = requireMaxDecimals(res, maxDecimalPlaces) + if err != nil { + return nil, err + } + + return res, nil +} + +// Deprecated: ParsePositiveFixedDecimal parses a positive decimal with a fixed maxDecimalPlaces or returns an error. +func ParsePositiveFixedDecimal(x string, maxDecimalPlaces uint32) (*apd.Decimal, error) { + res, err := ParsePositiveDecimal(x) + if err != nil { + return nil, err + } + + err = requireMaxDecimals(res, maxDecimalPlaces) + if err != nil { + return nil, err + } + + return res, nil +} + +func requireMaxDecimals(x *apd.Decimal, maxDecimalPlaces uint32) error { + n := NumDecimalPlaces(x) + if n > maxDecimalPlaces { + return errors.Wrap(errors.ErrInvalidRequest, fmt.Sprintf("expected no more than %d decimal places in %s, got %d", maxDecimalPlaces, x, n)) + } + return nil +} + +var exactContext = apd.Context{ + Precision: 0, + MaxExponent: apd.MaxExponent, + MinExponent: apd.MinExponent, + Traps: apd.DefaultTraps | apd.Inexact | apd.Rounded, +} + +// Deprecated: Add adds x and y and stores the result in res with arbitrary precision or returns an error. +func Add(res, x, y *apd.Decimal) error { + _, err := exactContext.Add(res, x, y) + if err != nil { + return errors.Wrap(err, "decimal addition error") + } + return nil +} + +// Deprecated: SafeSub subtracts the value of x from y and stores the result in res with arbitrary precision only +// if the result will be non-negative. An insufficient funds error is returned if the result would be negative. +func SafeSub(res, x, y *apd.Decimal) error { + _, err := exactContext.Sub(res, x, y) + if err != nil { + return errors.Wrap(err, "decimal subtraction error") + } + + if res.Sign() < 0 { + return errors.ErrInsufficientFunds + } + + return nil +} + +// SafeSubBalance subtracts the value of y from x and returns the result with arbitrary precision. +// Returns with ErrInsufficientFunds error if the result is negative. +func SafeSubBalance(x Dec, y Dec) (Dec, error) { + var z Dec + _, err := exactContext.Sub(&z.dec, &x.dec, &y.dec) + if err != nil { + return z, errors.Wrap(err, "decimal subtraction error") + } + + if z.IsNegative() { + return z, errors.ErrInsufficientFunds + } + + return z, nil +} + +// SafeAddBalance adds the value of x+y and returns the result with arbitrary precision. +// Returns with ErrInvalidRequest error if either x or y is negative. +func SafeAddBalance(x Dec, y Dec) (Dec, error) { + var z Dec + + if x.IsNegative() || y.IsNegative() { + return z, errors.Wrap( + errors.ErrInvalidRequest, + fmt.Sprintf("AddBalance() requires two non-negative Dec parameters, but received %s and %s", x, y)) + } + + _, err := exactContext.Add(&z.dec, &x.dec, &y.dec) + if err != nil { + return z, errors.Wrap(err, "decimal subtraction error") + } + + return z, nil +} diff --git a/regen/types/math/math_test.go b/regen/types/math/math_test.go new file mode 100644 index 0000000000..dd1d79c2ad --- /dev/null +++ b/regen/types/math/math_test.go @@ -0,0 +1,34 @@ +package math + +import ( + "testing" + + "github.com/cockroachdb/apd/v2" + "github.com/stretchr/testify/require" +) + +func Test_CountDecPlaces(t *testing.T) { + tests := []struct { + x string + want int32 + reduced int32 + }{ + {"0", 0, 0}, + {"1.0", 1, 0}, + {"1.0000", 4, 0}, + {"1.23", 2, 2}, + {"100", 0, 0}, + {"0.0003", 4, 4}, + } + for _, tt := range tests { + t.Run(tt.x, func(t *testing.T) { + x, _, err := apd.NewFromString(tt.x) + require.NoError(t, err) + got := NumDecimalPlaces(x) + require.Equal(t, uint32(tt.want), got) + x, _ = x.Reduce(x) + got = NumDecimalPlaces(x) + require.Equal(t, uint32(tt.reduced), got) + }) + } +} diff --git a/regen/types/module/base.go b/regen/types/module/base.go new file mode 100644 index 0000000000..a73b4c1f59 --- /dev/null +++ b/regen/types/module/base.go @@ -0,0 +1,15 @@ +package module + +import "github.com/cosmos/cosmos-sdk/codec/types" + +// Module is the base module type that all modules (client and server) must satisfy. +type Module interface { + Name() string +} + +// TypeModule is an interface that modules should implement to register types. +type TypeModule interface { + Module + + RegisterInterfaces(types.InterfaceRegistry) +} diff --git a/regen/types/module/client/cli/module.go b/regen/types/module/client/cli/module.go new file mode 100644 index 0000000000..6f99e9b205 --- /dev/null +++ b/regen/types/module/client/cli/module.go @@ -0,0 +1,21 @@ +package cli + +import ( + "encoding/json" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/regen/types/module" +) + +// Module is an interface that modules should implement to integrate with the CLI framework. +type Module interface { + module.TypeModule + + DefaultGenesis(codec.JSONCodec) json.RawMessage + ValidateGenesis(codec.JSONCodec, client.TxEncodingConfig, json.RawMessage) error + GetTxCmd() *cobra.Command + GetQueryCmd() *cobra.Command +} diff --git a/regen/types/module/client/grpc_gateway/module.go b/regen/types/module/client/grpc_gateway/module.go new file mode 100644 index 0000000000..b52e030479 --- /dev/null +++ b/regen/types/module/client/grpc_gateway/module.go @@ -0,0 +1,14 @@ +package grpc_gateway + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/cosmos/cosmos-sdk/regen/types/module" +) + +// Module is an interface that modules should implement to register grpc-gateway routes. +type Module interface { + module.Module + + RegisterGRPCGatewayRoutes(client.Context, *runtime.ServeMux) +} diff --git a/regen/types/module/genesis.go b/regen/types/module/genesis.go new file mode 100644 index 0000000000..00f41cfb30 --- /dev/null +++ b/regen/types/module/genesis.go @@ -0,0 +1,12 @@ +package module + +import ( + "encoding/json" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/regen/types" + abci "github.com/tendermint/tendermint/abci/types" +) + +type InitGenesisHandler func(ctx types.Context, cdc codec.Codec, data json.RawMessage) ([]abci.ValidatorUpdate, error) +type ExportGenesisHandler func(ctx types.Context, cdc codec.Codec) (json.RawMessage, error) diff --git a/regen/types/module/server/derived_module_key.go b/regen/types/module/server/derived_module_key.go new file mode 100644 index 0000000000..bac0a1cbef --- /dev/null +++ b/regen/types/module/server/derived_module_key.go @@ -0,0 +1,51 @@ +package server + +import ( + "context" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/cosmos-sdk/regen/types" + + "google.golang.org/grpc" +) + +type DerivedModuleKey struct { + moduleName string + path []byte + invokerFactory InvokerFactory +} + +var _ ModuleKey = DerivedModuleKey{} + +func (d DerivedModuleKey) Invoker(methodName string) (types.Invoker, error) { + return d.invokerFactory(CallInfo{ + Method: methodName, + Caller: d.ModuleID(), + }) +} + +func (d DerivedModuleKey) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, _ ...grpc.CallOption) error { + invoker, err := d.Invoker(method) + if err != nil { + return err + } + + return invoker(ctx, args, reply) +} + +func (d DerivedModuleKey) NewStream(context.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { + return nil, fmt.Errorf("unsupported") +} + +func (d DerivedModuleKey) ModuleID() types.ModuleID { + return types.ModuleID{ + ModuleName: d.moduleName, + Path: d.path, + } +} + +func (d DerivedModuleKey) Address() sdk.AccAddress { + return d.ModuleID().Address() +} diff --git a/regen/types/module/server/manager.go b/regen/types/module/server/manager.go new file mode 100644 index 0000000000..3e2178b826 --- /dev/null +++ b/regen/types/module/server/manager.go @@ -0,0 +1,311 @@ +package server + +import ( + "encoding/json" + "errors" + "fmt" + "reflect" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/server/api" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkmodule "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/types/simulation" + gogogrpc "github.com/gogo/protobuf/grpc" + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/cosmos-sdk/regen/types" + "github.com/cosmos/cosmos-sdk/regen/types/module" + restmodule "github.com/cosmos/cosmos-sdk/regen/types/module/client/grpc_gateway" +) + +// Manager is the server module manager +type Manager struct { + baseApp *baseapp.BaseApp + cdc *codec.ProtoCodec + keys map[string]ModuleKey + modules []module.Module + router *router + requiredServices map[reflect.Type]bool + initGenesisHandlers map[string]module.InitGenesisHandler + exportGenesisHandlers map[string]module.ExportGenesisHandler + registerInvariantsHandler map[string]RegisterInvariantsHandler + weightedOperationsHandlers map[string]WeightedOperationsHandler +} + +// RegisterInvariants registers all module routes and module querier routes +func (mm *Manager) RegisterInvariants(ir sdk.InvariantRegistry) { + for _, invariant := range mm.registerInvariantsHandler { + if invariant != nil { + invariant(ir) + } + } +} + +// NewManager creates a new Manager +func NewManager(baseApp *baseapp.BaseApp, cdc *codec.ProtoCodec) *Manager { + return &Manager{ + baseApp: baseApp, + cdc: cdc, + keys: map[string]ModuleKey{}, + registerInvariantsHandler: map[string]RegisterInvariantsHandler{}, + initGenesisHandlers: map[string]module.InitGenesisHandler{}, + exportGenesisHandlers: map[string]module.ExportGenesisHandler{}, + router: &router{ + handlers: map[string]handler{}, + providedServices: map[reflect.Type]bool{}, + msgServiceRouter: baseApp.MsgServiceRouter(), + }, + requiredServices: map[reflect.Type]bool{}, + weightedOperationsHandlers: map[string]WeightedOperationsHandler{}, + } +} + +func (mm *Manager) GetWeightedOperationsHandlers() map[string]WeightedOperationsHandler { + return mm.weightedOperationsHandlers +} + +// RegisterGRPCGatewayRoutes registers all module grpc-gateway routes +func (mm *Manager) RegisterGRPCGatewayRoutes(apiSvr *api.Server) { + for _, m := range mm.modules { + // check if we actually have a grpc-gateway module, otherwise skip + serverMod, ok := m.(restmodule.Module) + if !ok { + continue + } + serverMod.RegisterGRPCGatewayRoutes(apiSvr.ClientCtx, apiSvr.GRPCGatewayRouter) + } +} + +// RegisterModules registers modules with the Manager and registers their services. +func (mm *Manager) RegisterModules(modules []module.Module) error { + mm.modules = modules + // First we register all interface types. This is done for all modules first before registering + // any services in case there are any weird dependencies that will cause service initialization to fail. + for _, mod := range modules { + // check if we actually have a server module, otherwise skip + serverMod, ok := mod.(Module) + if !ok { + continue + } + + serverMod.RegisterInterfaces(mm.cdc.InterfaceRegistry()) + } + + // Next we register services + for _, mod := range modules { + // check if we actually have a server module, otherwise skip + serverMod, ok := mod.(Module) + if !ok { + continue + } + + name := serverMod.Name() + + invokerFactory := mm.router.invokerFactory(name) + + key := &rootModuleKey{ + moduleName: name, + invokerFactory: invokerFactory, + } + + if _, found := mm.keys[name]; found { + return fmt.Errorf("module named %s defined twice", name) + } + + mm.keys[name] = key + mm.baseApp.MountStore(key, sdk.StoreTypeIAVL) + + msgRegistrar := registrar{ + router: mm.router, + baseServer: mm.baseApp.MsgServiceRouter(), + commitWrites: true, + moduleName: name, + } + + queryRegistrar := registrar{ + router: mm.router, + baseServer: mm.baseApp.GRPCQueryRouter(), + commitWrites: false, + moduleName: name, + } + + cfg := &configurator{ + msgServer: msgRegistrar, + queryServer: queryRegistrar, + key: key, + cdc: mm.cdc, + requiredServices: map[reflect.Type]bool{}, + } + + serverMod.RegisterServices(cfg) + mm.registerInvariantsHandler[name] = cfg.registerInvariantsHandler + mm.initGenesisHandlers[name] = cfg.initGenesisHandler + mm.exportGenesisHandlers[name] = cfg.exportGenesisHandler + + if cfg.weightedOperationHandler != nil { + mm.weightedOperationsHandlers[name] = cfg.weightedOperationHandler + } + + for typ := range cfg.requiredServices { + mm.requiredServices[typ] = true + } + + } + + return nil +} + +// WeightedOperations returns all the modules' weighted operations of an application +func (mm *Manager) WeightedOperations(state sdkmodule.SimulationState, modules []sdkmodule.AppModuleSimulation) []simulation.WeightedOperation { + wOps := make([]simulation.WeightedOperation, 0, len(modules)+len(mm.weightedOperationsHandlers)) + // adding non ADR-33 modules weighted operations + for _, m := range modules { + wOps = append(wOps, m.WeightedOperations(state)...) + } + + // adding ADR-33 modules weighted operations + for _, weightedOperationHandler := range mm.weightedOperationsHandlers { + wOps = append(wOps, weightedOperationHandler(state)...) + } + + return wOps +} + +// AuthorizationMiddleware is a function that allows for more complex authorization than the default authorization scheme, +// such as delegated permissions. It will be called only if the default authorization fails. +type AuthorizationMiddleware func(ctx sdk.Context, methodName string, req sdk.Msg, signer sdk.AccAddress) bool + +// SetAuthorizationMiddleware sets AuthorizationMiddleware for the Manager. +func (mm *Manager) SetAuthorizationMiddleware(authzFunc AuthorizationMiddleware) { + mm.router.authzMiddleware = authzFunc +} + +// CompleteInitialization should be the last function on the Manager called before the application starts to perform +// any necessary validation and initialization. +func (mm *Manager) CompleteInitialization() error { + for typ := range mm.requiredServices { + if _, found := mm.router.providedServices[typ]; !found { + return fmt.Errorf("initialization error, service %s was required, but not provided", typ) + } + + } + + return nil +} + +// InitGenesis performs init genesis functionality for modules. +// We pass in existing validatorUpdates from the sdk module Manager.InitGenesis. +func (mm *Manager) InitGenesis(ctx sdk.Context, genesisData map[string]json.RawMessage, validatorUpdates []abci.ValidatorUpdate) abci.ResponseInitChain { + res, err := initGenesis(ctx, mm.cdc, genesisData, validatorUpdates, mm.initGenesisHandlers) + if err != nil { + panic(err) + } + return res +} + +func initGenesis(ctx sdk.Context, cdc codec.Codec, + genesisData map[string]json.RawMessage, validatorUpdates []abci.ValidatorUpdate, + initGenesisHandlers map[string]module.InitGenesisHandler) (abci.ResponseInitChain, error) { + for name, initGenesisHandler := range initGenesisHandlers { + if genesisData[name] == nil || initGenesisHandler == nil { + continue + } + moduleValUpdates, err := initGenesisHandler(types.Context{Context: ctx}, cdc, genesisData[name]) + if err != nil { + return abci.ResponseInitChain{}, err + } + + // use these validator updates if provided, the module manager assumes + // only one module will update the validator set + if len(moduleValUpdates) > 0 { + if len(validatorUpdates) > 0 { + return abci.ResponseInitChain{}, errors.New("validator InitGenesis updates already set by a previous module") + } + validatorUpdates = moduleValUpdates + } + } + + return abci.ResponseInitChain{ + Validators: validatorUpdates, + }, nil +} + +// ExportGenesis performs export genesis functionality for modules. +func (mm *Manager) ExportGenesis(ctx sdk.Context) map[string]json.RawMessage { + genesisData, err := exportGenesis(ctx, mm.cdc, mm.exportGenesisHandlers) + if err != nil { + panic(err) + } + + return genesisData +} + +func exportGenesis(ctx sdk.Context, cdc codec.Codec, exportGenesisHandlers map[string]module.ExportGenesisHandler) (map[string]json.RawMessage, error) { + var err error + genesisData := make(map[string]json.RawMessage) + for name, exportGenesisHandler := range exportGenesisHandlers { + if exportGenesisHandler == nil { + continue + } + genesisData[name], err = exportGenesisHandler(types.Context{Context: ctx}, cdc) + if err != nil { + return genesisData, err + } + } + + return genesisData, nil +} + +type RegisterInvariantsHandler func(ir sdk.InvariantRegistry) + +type configurator struct { + sdkmodule.Configurator + msgServer gogogrpc.Server + queryServer gogogrpc.Server + key *rootModuleKey + cdc codec.Codec + requiredServices map[reflect.Type]bool + initGenesisHandler module.InitGenesisHandler + exportGenesisHandler module.ExportGenesisHandler + weightedOperationHandler WeightedOperationsHandler + registerInvariantsHandler RegisterInvariantsHandler +} + +var _ Configurator = &configurator{} + +func (c *configurator) RegisterWeightedOperationsHandler(operationsHandler WeightedOperationsHandler) { + c.weightedOperationHandler = operationsHandler +} + +func (c *configurator) MsgServer() gogogrpc.Server { + return c.msgServer +} + +func (c *configurator) QueryServer() gogogrpc.Server { + return c.queryServer +} + +func (c *configurator) RegisterInvariantsHandler(registry RegisterInvariantsHandler) { + c.registerInvariantsHandler = registry +} + +func (c *configurator) RegisterGenesisHandlers(initGenesisHandler module.InitGenesisHandler, exportGenesisHandler module.ExportGenesisHandler) { + c.initGenesisHandler = initGenesisHandler + c.exportGenesisHandler = exportGenesisHandler +} + +func (c *configurator) ModuleKey() RootModuleKey { + return c.key +} + +func (c *configurator) Marshaler() codec.Codec { + return c.cdc +} + +func (c *configurator) RequireServer(serverInterface interface{}) { + c.requiredServices[reflect.TypeOf(serverInterface)] = true +} + +type WeightedOperationsHandler func(simstate sdkmodule.SimulationState) []simulation.WeightedOperation diff --git a/regen/types/module/server/module.go b/regen/types/module/server/module.go new file mode 100644 index 0000000000..f29a9ceeb7 --- /dev/null +++ b/regen/types/module/server/module.go @@ -0,0 +1,26 @@ +package server + +import ( + "github.com/cosmos/cosmos-sdk/codec" + sdkmodule "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/cosmos/cosmos-sdk/regen/types/module" +) + +// Module is the module type that all server modules must satisfy +type Module interface { + module.TypeModule + + RegisterServices(Configurator) +} + +type Configurator interface { + sdkmodule.Configurator + + ModuleKey() RootModuleKey + Marshaler() codec.Codec + RequireServer(interface{}) + RegisterInvariantsHandler(registry RegisterInvariantsHandler) + RegisterGenesisHandlers(module.InitGenesisHandler, module.ExportGenesisHandler) + RegisterWeightedOperationsHandler(WeightedOperationsHandler) +} diff --git a/regen/types/module/server/module_key.go b/regen/types/module/server/module_key.go new file mode 100644 index 0000000000..56fb8fa8f7 --- /dev/null +++ b/regen/types/module/server/module_key.go @@ -0,0 +1,20 @@ +package server + +import ( + "github.com/cosmos/cosmos-sdk/regen/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type ModuleKey interface { + types.InvokerConn + + ModuleID() types.ModuleID + Address() sdk.AccAddress +} + +type InvokerFactory func(callInfo CallInfo) (types.Invoker, error) + +type CallInfo struct { + Method string + Caller types.ModuleID +} diff --git a/regen/types/module/server/msgs.go b/regen/types/module/server/msgs.go new file mode 100644 index 0000000000..18ac10f60a --- /dev/null +++ b/regen/types/module/server/msgs.go @@ -0,0 +1,50 @@ +package server + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetMsgs takes a slice of sdk.Msg's and turn them into Any's. +// This is similar to what is in the cosmos-sdk tx builder +// and could eventually be merged in. +func SetMsgs(msgs []sdk.Msg) ([]*types.Any, error) { + anys := make([]*types.Any, len(msgs)) + for i, msg := range msgs { + var err error + anys[i], err = types.NewAnyWithValue(msg) + if err != nil { + return nil, err + } + } + return anys, nil +} + +// GetMsgs takes a slice of Any's and turn them into sdk.Msg's. +// This is similar to what is in the cosmos-sdk sdk.Tx +// and could eventually be merged in. +func GetMsgs(anys []*types.Any) ([]sdk.Msg, error) { + msgs := make([]sdk.Msg, len(anys)) + for i, any := range anys { + cached := any.GetCachedValue() + if cached == nil { + return nil, fmt.Errorf("any cached value is nil, proposal messages must be correctly packed Any values.") + } + msgs[i] = cached.(sdk.Msg) + } + return msgs, nil +} + +func UnpackInterfaces(unpacker types.AnyUnpacker, anys []*types.Any) error { + for _, any := range anys { + var msg sdk.Msg + err := unpacker.UnpackAny(any, &msg) + if err != nil { + return err + } + } + + return nil +} diff --git a/regen/types/module/server/root_module_key.go b/regen/types/module/server/root_module_key.go new file mode 100644 index 0000000000..c61e4374ec --- /dev/null +++ b/regen/types/module/server/root_module_key.go @@ -0,0 +1,68 @@ +package server + +import ( + "context" + "fmt" + + "github.com/cosmos/cosmos-sdk/regen/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc" +) + +type RootModuleKey interface { + ModuleKey + sdk.StoreKey + Derive(path []byte) DerivedModuleKey +} + +type rootModuleKey struct { + moduleName string + invokerFactory InvokerFactory +} + +var _ RootModuleKey = &rootModuleKey{} + +func (r *rootModuleKey) Name() string { + return r.moduleName +} + +func (r *rootModuleKey) String() string { + return fmt.Sprintf("rootModuleKey{%p, %s}", r, r.moduleName) +} + +func (r *rootModuleKey) Invoker(methodName string) (types.Invoker, error) { + return r.invokerFactory(CallInfo{ + Method: methodName, + Caller: r.ModuleID(), + }) +} + +func (r *rootModuleKey) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, _ ...grpc.CallOption) error { + invoker, err := r.Invoker(method) + if err != nil { + return err + } + + return invoker(ctx, args, reply) +} + +func (r *rootModuleKey) NewStream(context.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { + return nil, fmt.Errorf("unsupported") +} + +func (r *rootModuleKey) ModuleID() types.ModuleID { + return types.ModuleID{ModuleName: r.moduleName} +} + +func (r *rootModuleKey) Address() sdk.AccAddress { + return r.ModuleID().Address() +} + +func (r *rootModuleKey) Derive(path []byte) DerivedModuleKey { + return DerivedModuleKey{ + moduleName: r.moduleName, + path: path, + invokerFactory: r.invokerFactory, + } +} diff --git a/regen/types/module/server/router.go b/regen/types/module/server/router.go new file mode 100644 index 0000000000..899549470f --- /dev/null +++ b/regen/types/module/server/router.go @@ -0,0 +1,220 @@ +package server + +import ( + "bytes" + "context" + "fmt" + "reflect" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + gogogrpc "github.com/gogo/protobuf/grpc" + "github.com/gogo/protobuf/proto" + "google.golang.org/grpc" + + "github.com/cosmos/cosmos-sdk/regen/types" +) + +type handler struct { + f func(ctx context.Context, args, reply interface{}) error + commitWrites bool + moduleName string +} + +type router struct { + handlers map[string]handler + providedServices map[reflect.Type]bool + authzMiddleware AuthorizationMiddleware + msgServiceRouter *baseapp.MsgServiceRouter +} + +type registrar struct { + *router + baseServer gogogrpc.Server + commitWrites bool + moduleName string +} + +var _ gogogrpc.Server = registrar{} + +func (r registrar) RegisterService(sd *grpc.ServiceDesc, ss interface{}) { + r.providedServices[reflect.TypeOf(sd.HandlerType)] = true + + r.baseServer.RegisterService(sd, ss) + + for _, method := range sd.Methods { + fqName := fmt.Sprintf("/%s/%s", sd.ServiceName, method.MethodName) + methodHandler := method.Handler + + var requestTypeName string + + _, _ = methodHandler(nil, context.Background(), func(i interface{}) error { + req, ok := i.(proto.Message) + if !ok { + // We panic here because there is no other alternative and the app cannot be initialized correctly + // this should only happen if there is a problem with code generation in which case the app won't + // work correctly anyway. + panic(fmt.Errorf("can't register request type %T for service method %s", i, fqName)) + } + requestTypeName = TypeURL(req) + return nil + }, noopInterceptor) + + f := func(ctx context.Context, args, reply interface{}) error { + res, err := methodHandler(ss, ctx, func(i interface{}) error { return nil }, + func(ctx context.Context, _ interface{}, _ *grpc.UnaryServerInfo, unaryHandler grpc.UnaryHandler) (resp interface{}, err error) { + return unaryHandler(ctx, args) + }) + if err != nil { + return err + } + + resValue := reflect.ValueOf(res) + if !resValue.IsZero() && reply != nil { + reflect.ValueOf(reply).Elem().Set(resValue.Elem()) + } + return nil + } + r.handlers[requestTypeName] = handler{ + f: f, + commitWrites: r.commitWrites, + moduleName: r.moduleName, + } + } +} + +func (rtr *router) invoker(methodName string, writeCondition func(context.Context, string, sdk.Msg) error) (types.Invoker, error) { + return func(ctx context.Context, request interface{}, response interface{}, opts ...interface{}) error { + req, ok := request.(proto.Message) + if !ok { + return fmt.Errorf("expected proto.Message, got %T for service method %s", request, methodName) + } + + typeURL := TypeURL(req) + handler, found := rtr.handlers[typeURL] + + msg, isMsg := request.(sdk.Msg) + if !found && !isMsg { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("cannot find method named %s", methodName)) + } + + // cache wrap the multistore so that inter-module writes are atomic + // see https://github.com/cosmos/cosmos-sdk/issues/8030 + regenCtx := types.UnwrapSDKContext(ctx) + cacheMs := regenCtx.MultiStore().CacheMultiStore() + ctx = sdk.WrapSDKContext(regenCtx.WithMultiStore(cacheMs)) + + // msg handler + if writeCondition != nil && (handler.commitWrites || isMsg) { + err := msg.ValidateBasic() + if err != nil { + return err + } + + err = writeCondition(ctx, methodName, msg) + if err != nil { + return err + } + + // ADR-033 router + if found { + err = handler.f(ctx, request, response) + if err != nil { + return err + } + } else { + // routing using baseapp.MsgServiceRouter + sdkCtx := sdk.UnwrapSDKContext(ctx) + handler := rtr.msgServiceRouter.HandlerByTypeURL(typeURL) + if handler == nil { + return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized message route: %s;", typeURL) + } + + _, err = handler(sdkCtx, msg) + if err != nil { + return err + } + } + + // only commit writes if there is no error so that calls are atomic + cacheMs.Write() + } else { + // query handler + err := handler.f(ctx, request, response) + if err != nil { + return err + } + + cacheMs.Write() + } + return nil + + }, nil +} + +func (rtr *router) invokerFactory(moduleName string) InvokerFactory { + return func(callInfo CallInfo) (types.Invoker, error) { + moduleID := callInfo.Caller + if moduleName != moduleID.ModuleName { + return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, + fmt.Sprintf("expected a call from module %s, but module %s is calling", moduleName, moduleID.ModuleName)) + } + + moduleAddr := moduleID.Address() + + writeCondition := func(ctx context.Context, methodName string, msgReq sdk.Msg) error { + signers := msgReq.GetSigners() + if len(signers) != 1 { + return fmt.Errorf("inter module Msg invocation requires a single expected signer (%s), but %s expects multiple signers (%+v), ", moduleAddr, methodName, signers) + } + + signer := signers[0] + + if bytes.Equal(moduleAddr, signer) { + return nil + } + + if rtr.authzMiddleware != nil && rtr.authzMiddleware(sdk.UnwrapSDKContext(ctx), methodName, msgReq, moduleAddr) { + return nil + } + + return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, + fmt.Sprintf("expected %s, got %s", signers[0], moduleAddr)) + } + + return rtr.invoker(callInfo.Method, writeCondition) + } +} + +func (rtr *router) testTxFactory(signers []sdk.AccAddress) InvokerFactory { + signerMap := map[string]bool{} + for _, signer := range signers { + signerMap[signer.String()] = true + } + + return func(callInfo CallInfo) (types.Invoker, error) { + return rtr.invoker(callInfo.Method, func(_ context.Context, _ string, req sdk.Msg) error { + for _, signer := range req.GetSigners() { + if _, found := signerMap[signer.String()]; !found { + return sdkerrors.ErrUnauthorized + } + } + return nil + }) + } +} + +func (rtr *router) testQueryFactory() InvokerFactory { + return func(callInfo CallInfo) (types.Invoker, error) { + return rtr.invoker(callInfo.Method, nil) + } +} + +func TypeURL(req proto.Message) string { + return "/" + proto.MessageName(req) +} + +func noopInterceptor(_ context.Context, _ interface{}, _ *grpc.UnaryServerInfo, _ grpc.UnaryHandler) (interface{}, error) { + return nil, nil +} diff --git a/regen/types/module/server/testutil.go b/regen/types/module/server/testutil.go new file mode 100644 index 0000000000..dd4de30e86 --- /dev/null +++ b/regen/types/module/server/testutil.go @@ -0,0 +1,153 @@ +package server + +import ( + "context" + "encoding/json" + "fmt" + "testing" + + "github.com/cosmos/cosmos-sdk/regen/types/testutil" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + dbm "github.com/tendermint/tm-db" + "google.golang.org/grpc" + + regentypes "github.com/cosmos/cosmos-sdk/regen/types" + "github.com/cosmos/cosmos-sdk/regen/types/module" +) + +type FixtureFactory struct { + t *testing.T + modules []module.Module + signers []sdk.AccAddress + cdc *codec.ProtoCodec + baseApp *baseapp.BaseApp +} + +func NewFixtureFactory(t *testing.T, numSigners int) *FixtureFactory { + signers := makeTestAddresses(numSigners) + return &FixtureFactory{ + t: t, + signers: signers, + // cdc and baseApp are initialized here just for compatibility with legacy modules which don't use ADR 033 + // TODO: remove once all code using this uses ADR 033 module wiring + cdc: codec.NewProtoCodec(types.NewInterfaceRegistry()), + baseApp: baseapp.NewBaseApp("test", log.NewNopLogger(), dbm.NewMemDB(), nil), + } +} + +func (ff *FixtureFactory) SetModules(modules []module.Module) { + ff.modules = modules +} + +// Codec is exposed just for compatibility of these test suites with legacy modules and can be removed when everything +// has been migrated to ADR 033 +func (ff *FixtureFactory) Codec() *codec.ProtoCodec { + return ff.cdc +} + +// BaseApp is exposed just for compatibility of these test suites with legacy modules and can be removed when everything +// has been migrated to ADR 033 +func (ff *FixtureFactory) BaseApp() *baseapp.BaseApp { + return ff.baseApp +} + +func makeTestAddresses(count int) []sdk.AccAddress { + addrs := make([]sdk.AccAddress, count) + for i := 0; i < count; i++ { + _, _, addrs[i] = testdata.KeyTestPubAddr() + } + return addrs +} + +func (ff FixtureFactory) Setup() testutil.Fixture { + cdc := ff.cdc + registry := cdc.InterfaceRegistry() + baseApp := ff.baseApp + baseApp.MsgServiceRouter().SetInterfaceRegistry(registry) + baseApp.GRPCQueryRouter().SetInterfaceRegistry(registry) + mm := NewManager(baseApp, cdc) + err := mm.RegisterModules(ff.modules) + require.NoError(ff.t, err) + err = mm.CompleteInitialization() + require.NoError(ff.t, err) + err = baseApp.LoadLatestVersion() + require.NoError(ff.t, err) + + return fixture{ + baseApp: baseApp, + router: mm.router, + cdc: cdc, + initGenesisHandlers: mm.initGenesisHandlers, + exportGenesisHandlers: mm.exportGenesisHandlers, + t: ff.t, + signers: ff.signers, + } +} + +type fixture struct { + baseApp *baseapp.BaseApp + router *router + cdc *codec.ProtoCodec + initGenesisHandlers map[string]module.InitGenesisHandler + exportGenesisHandlers map[string]module.ExportGenesisHandler + t *testing.T + signers []sdk.AccAddress +} + +func (f fixture) Context() context.Context { + return regentypes.Context{Context: f.baseApp.NewUncachedContext(false, tmproto.Header{})} +} + +func (f fixture) TxConn() grpc.ClientConnInterface { + return testKey{invokerFactory: f.router.testTxFactory(f.signers)} +} + +func (f fixture) QueryConn() grpc.ClientConnInterface { + return testKey{invokerFactory: f.router.testQueryFactory()} +} + +func (f fixture) Signers() []sdk.AccAddress { + return f.signers +} + +func (f fixture) InitGenesis(ctx sdk.Context, genesisData map[string]json.RawMessage) (abci.ResponseInitChain, error) { + return initGenesis(ctx, f.cdc, genesisData, []abci.ValidatorUpdate{}, f.initGenesisHandlers) +} + +func (f fixture) ExportGenesis(ctx sdk.Context) (map[string]json.RawMessage, error) { + return exportGenesis(ctx, f.cdc, f.exportGenesisHandlers) +} + +func (f fixture) Codec() *codec.ProtoCodec { + return f.cdc +} + +func (f fixture) Teardown() {} + +type testKey struct { + invokerFactory InvokerFactory +} + +var _ grpc.ClientConnInterface = testKey{} + +func (t testKey) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, _ ...grpc.CallOption) error { + invoker, err := t.invokerFactory(CallInfo{Method: method}) + if err != nil { + return err + } + + return invoker(ctx, args, reply) +} + +func (t testKey) NewStream(context.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { + return nil, fmt.Errorf("unsupported") +} diff --git a/regen/types/testutil/cli/cmd.go b/regen/types/testutil/cli/cmd.go new file mode 100644 index 0000000000..1f09ae9296 --- /dev/null +++ b/regen/types/testutil/cli/cmd.go @@ -0,0 +1,27 @@ +package cli + +import ( + "context" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/testutil" +) + +// ExecTestCLICmd builds the client context, mocks the output and executes the command. +func ExecTestCLICmd(clientCtx client.Context, cmd *cobra.Command, extraArgs []string) (testutil.BufferWriter, error) { + cmd.SetArgs(extraArgs) + + _, out := testutil.ApplyMockIO(cmd) + clientCtx = clientCtx.WithOutput(out) + + ctx := context.Background() + ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) + + if err := cmd.ExecuteContext(ctx); err != nil { + return out, err + } + + return out, nil +} diff --git a/regen/types/testutil/fixture.go b/regen/types/testutil/fixture.go new file mode 100644 index 0000000000..d426329653 --- /dev/null +++ b/regen/types/testutil/fixture.go @@ -0,0 +1,57 @@ +/*Package server defines fixture interfaces and implementations for testing +server implementations with multiple backends. + +Currently one backend - an in-memory store with no ABCI application is supported +in configuration.Fixture. + +A multi-node in-process ABCI-based backend for full integration tests is planned +based on to the Cosmos SDK in-process integration test framework. +*/ +package testutil + +import ( + "context" + "encoding/json" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + abci "github.com/tendermint/tendermint/abci/types" + "google.golang.org/grpc" +) + +// FixtureFactory defines an interface for creating server test fixtures +type FixtureFactory interface { + + // Setup runs necessary fixture setup and returns a fresh Fixture environment. + Setup() Fixture +} + +// Fixture defines an interface for interacting with app services in tests +// independent of the backend. +type Fixture interface { + + // Context is the context.Context to be used with gRPC generated client code. + Context() context.Context + + // TxConn is the grpc.ClientConnInterface to be used when constructing Msg service clients. + TxConn() grpc.ClientConnInterface + + // QueryConn is the grpc.ClientConnInterface to be used when constructing Query service clients. + QueryConn() grpc.ClientConnInterface + + // Signers are a list of addresses which can be used to sign transactions. They may either be + // random or correspond to nodes in a test network which have keyrings. + Signers() []sdk.AccAddress + + // InitGenesis initializes genesis for all modules with provided genesisData. + InitGenesis(ctx sdk.Context, genesisData map[string]json.RawMessage) (abci.ResponseInitChain, error) + + // ExportGenesis returns raw encoded JSON genesis state for all modules. + ExportGenesis(ctx sdk.Context) (map[string]json.RawMessage, error) + + // Codec is the app ProtoCodec. + Codec() *codec.ProtoCodec + + // Teardown performs any teardown actions for the fixture. + Teardown() +} diff --git a/regen/types/testutil/network/doc.go b/regen/types/testutil/network/doc.go new file mode 100644 index 0000000000..9e44f371ab --- /dev/null +++ b/regen/types/testutil/network/doc.go @@ -0,0 +1,65 @@ +/* +Package network implements and exposes a fully operational in-process Tendermint +test network that consists of at least one or potentially many validators. This +test network can be used primarily for integration tests or unit test suites. + +The test network utilizes SimApp as the ABCI application and uses all the modules +defined in the Cosmos SDK. An in-process test network can be configured with any +number of validators as well as account funds and even custom genesis state. + +When creating a test network, a series of Validator objects are returned. Each +Validator object has useful information such as their address and public key. A +Validator will also provide its RPC, P2P, and API addresses that can be useful +for integration testing. In addition, a Tendermint local RPC client is also provided +which can be handy for making direct RPC calls to Tendermint. + +Note, due to limitations in concurrency and the design of the RPC layer in +Tendermint, only the first Validator object will have an RPC and API client +exposed. Due to this exact same limitation, only a single test network can exist +at a time. A caller must be certain it calls Cleanup after it no longer needs +the network. + +A typical testing flow might look like the following: + + type IntegrationTestSuite struct { + suite.Suite + + cfg testutil.Config + network *testutil.Network + } + + func (s *IntegrationTestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + cfg := testutil.DefaultConfig() + cfg.NumValidators = 1 + + s.cfg = cfg + s.network = testutil.New(s.T(), cfg) + + _, err := s.network.WaitForHeight(1) + s.Require().NoError(err) + } + + func (s *IntegrationTestSuite) TearDownSuite() { + s.T().Log("tearing down integration test suite") + + // This is important and must be called to ensure other tests can create + // a network! + s.network.Cleanup() + } + + func (s *IntegrationTestSuite) TestQueryBalancesRequestHandlerFn() { + val := s.network.Validators[0] + baseURL := val.APIAddress + + // Use baseURL to make API HTTP requests or use val.RPCClient to make direct + // Tendermint RPC calls. + // ... + } + + func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) + } +*/ +package network diff --git a/regen/types/testutil/network/network.go b/regen/types/testutil/network/network.go new file mode 100644 index 0000000000..8f1802c02c --- /dev/null +++ b/regen/types/testutil/network/network.go @@ -0,0 +1,430 @@ +package network + +import ( + "bufio" + "context" + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "net/url" + "os" + "path/filepath" + "sync" + "testing" + "time" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/server" + "github.com/cosmos/cosmos-sdk/server/api" + srvconfig "github.com/cosmos/cosmos-sdk/server/config" + servertypes "github.com/cosmos/cosmos-sdk/server/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/genutil" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/stretchr/testify/require" + tmcfg "github.com/tendermint/tendermint/config" + tmflags "github.com/tendermint/tendermint/libs/cli/flags" + "github.com/tendermint/tendermint/libs/log" + "github.com/tendermint/tendermint/node" + tmclient "github.com/tendermint/tendermint/rpc/client" + "google.golang.org/grpc" +) + +// package-wide network lock to only allow one test network at a time +var lock = new(sync.Mutex) + +// AppConstructor defines a function which accepts a network configuration and +// creates an ABCI Application to provide to Tendermint. +type AppConstructor = func(val Validator) servertypes.Application + +// Config defines the necessary configuration used to bootstrap and start an +// in-process local testing network. +type Config struct { + Codec codec.Codec + LegacyAmino *codec.LegacyAmino // TODO: Remove! + InterfaceRegistry codectypes.InterfaceRegistry + + TxConfig client.TxConfig + AccountRetriever client.AccountRetriever + AppConstructor AppConstructor // the ABCI application constructor + GenesisState map[string]json.RawMessage // custom gensis state to provide + TimeoutCommit time.Duration // the consensus commitment timeout + ChainID string // the network chain-id + NumValidators int // the total number of validators to create and bond + BondDenom string // the staking bond denomination + MinGasPrices string // the minimum gas prices each validator will accept + AccountTokens sdk.Int // the amount of unique validator tokens (e.g. 1000node0) + StakingTokens sdk.Int // the amount of tokens each validator has available to stake + BondedTokens sdk.Int // the amount of tokens each validator stakes + PruningStrategy string // the pruning strategy each validator will have + EnableLogging bool // enable Tendermint logging to STDOUT + CleanupDir bool // remove base temporary directory during cleanup + SigningAlgo string // signing algorithm for keys + KeyringOptions []keyring.Option +} + +type ( + // Network defines a local in-process testing network using SimApp. It can be + // configured to start any number of validators, each with its own RPC and API + // clients. Typically, this test network would be used in client and integration + // testing where user input is expected. + // + // Note, due to Tendermint constraints in regards to RPC functionality, there + // may only be one test network running at a time. Thus, any caller must be + // sure to Cleanup after testing is finished in order to allow other tests + // to create networks. In addition, only the first validator will have a valid + // RPC and API server/client. + Network struct { + T *testing.T + BaseDir string + Validators []*Validator + + Config Config + } + + // Validator defines an in-process Tendermint validator node. Through this object, + // a client can make RPC and API calls and interact with any client command + // or handler. + Validator struct { + AppConfig *srvconfig.Config + ClientCtx client.Context + Ctx *server.Context + Dir string + NodeID string + PubKey cryptotypes.PubKey + Moniker string + APIAddress string + RPCAddress string + P2PAddress string + Address sdk.AccAddress + ValAddress sdk.ValAddress + RPCClient tmclient.Client + + tmNode *node.Node + api *api.Server + grpc *grpc.Server + } +) + +// New creates Network +func New(t *testing.T, cfg Config) *Network { + // only one caller/test can create and use a network at a time + t.Log("acquiring test network lock") + lock.Lock() + + baseDir, err := ioutil.TempDir(t.TempDir(), cfg.ChainID) + require.NoError(t, err) + t.Logf("created temporary directory: %s", baseDir) + + network := &Network{ + T: t, + BaseDir: baseDir, + Validators: make([]*Validator, cfg.NumValidators), + Config: cfg, + } + + t.Log("preparing test network...") + + monikers := make([]string, cfg.NumValidators) + nodeIDs := make([]string, cfg.NumValidators) + valPubKeys := make([]cryptotypes.PubKey, cfg.NumValidators) + + var ( + genAccounts []authtypes.GenesisAccount + genBalances []banktypes.Balance + genFiles []string + ) + + buf := bufio.NewReader(os.Stdin) + + // generate private keys, node IDs, and initial transactions + for i := 0; i < cfg.NumValidators; i++ { + appCfg := srvconfig.DefaultConfig() + appCfg.Pruning = cfg.PruningStrategy + appCfg.MinGasPrices = cfg.MinGasPrices + appCfg.API.Enable = true + appCfg.API.Swagger = false + appCfg.Telemetry.Enabled = false + + ctx := server.NewDefaultContext() + tmCfg := ctx.Config + tmCfg.Consensus.TimeoutCommit = cfg.TimeoutCommit + + // Only allow the first validator to expose an RPC, API and gRPC + // server/client due to Tendermint in-process constraints. + apiAddr := "" + tmCfg.RPC.ListenAddress = "" + appCfg.GRPC.Enable = false + if i == 0 { + apiListenAddr, _, err := server.FreeTCPAddr() + require.NoError(t, err) + appCfg.API.Address = apiListenAddr + + apiURL, err := url.Parse(apiListenAddr) + require.NoError(t, err) + apiAddr = fmt.Sprintf("http://%s:%s", apiURL.Hostname(), apiURL.Port()) + + rpcAddr, _, err := server.FreeTCPAddr() + require.NoError(t, err) + tmCfg.RPC.ListenAddress = rpcAddr + + _, grpcPort, err := server.FreeTCPAddr() + require.NoError(t, err) + appCfg.GRPC.Address = fmt.Sprintf("0.0.0.0:%s", grpcPort) + appCfg.GRPC.Enable = true + } + + logger := log.NewNopLogger() + if cfg.EnableLogging { + logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout)) + logger, _ = tmflags.ParseLogLevel("info", logger, tmcfg.DefaultLogLevel) + } + + ctx.Logger = logger + + nodeDirName := fmt.Sprintf("node%d", i) + nodeDir := filepath.Join(network.BaseDir, nodeDirName, "simd") + clientDir := filepath.Join(network.BaseDir, nodeDirName, "simcli") + gentxsDir := filepath.Join(network.BaseDir, "gentxs") + + require.NoError(t, os.MkdirAll(filepath.Join(nodeDir, "config"), 0755)) + require.NoError(t, os.MkdirAll(clientDir, 0755)) + + tmCfg.SetRoot(nodeDir) + tmCfg.Moniker = nodeDirName + monikers[i] = nodeDirName + + proxyAddr, _, err := server.FreeTCPAddr() + require.NoError(t, err) + tmCfg.ProxyApp = proxyAddr + + p2pAddr, _, err := server.FreeTCPAddr() + require.NoError(t, err) + tmCfg.P2P.ListenAddress = p2pAddr + tmCfg.P2P.AddrBookStrict = false + tmCfg.P2P.AllowDuplicateIP = true + + nodeID, pubKey, err := genutil.InitializeNodeValidatorFiles(tmCfg) + require.NoError(t, err) + nodeIDs[i] = nodeID + valPubKeys[i] = pubKey + + kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, clientDir, buf, cfg.KeyringOptions...) + require.NoError(t, err) + + keyringAlgos, _ := kb.SupportedAlgorithms() + algo, err := keyring.NewSigningAlgoFromString(cfg.SigningAlgo, keyringAlgos) + require.NoError(t, err) + + addr, secret, err := server.GenerateSaveCoinKey(kb, nodeDirName, true, algo) + require.NoError(t, err) + + info := map[string]string{"secret": secret} + infoBz, err := json.Marshal(info) + require.NoError(t, err) + + // save private key seed words + require.NoError(t, writeFile(fmt.Sprintf("%v.json", "key_seed"), clientDir, infoBz)) + + balances := sdk.NewCoins( + sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), cfg.AccountTokens), + sdk.NewCoin(cfg.BondDenom, cfg.StakingTokens), + ) + + genFiles = append(genFiles, tmCfg.GenesisFile()) + genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: balances.Sort()}) + genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0)) + + commission, err := sdk.NewDecFromStr("0.5") + require.NoError(t, err) + + createValMsg, err := stakingtypes.NewMsgCreateValidator( + sdk.ValAddress(addr), + valPubKeys[i], + sdk.NewCoin(sdk.DefaultBondDenom, cfg.BondedTokens), + stakingtypes.NewDescription(nodeDirName, "", "", "", ""), + stakingtypes.NewCommissionRates(commission, sdk.OneDec(), sdk.OneDec()), + sdk.OneInt(), + ) + if err != nil { + panic(err) + } + + p2pURL, err := url.Parse(p2pAddr) + require.NoError(t, err) + + memo := fmt.Sprintf("%s@%s:%s", nodeIDs[i], p2pURL.Hostname(), p2pURL.Port()) + fee := sdk.NewCoins(sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), sdk.NewInt(0))) + txBuilder := cfg.TxConfig.NewTxBuilder() + require.NoError(t, txBuilder.SetMsgs(createValMsg)) + txBuilder.SetFeeAmount(fee) // Arbitrary fee + txBuilder.SetGasLimit(1000000) // Need at least 100386 + txBuilder.SetMemo(memo) + + txFactory := tx.Factory{} + txFactory = txFactory. + WithChainID(cfg.ChainID). + WithMemo(memo). + WithKeybase(kb). + WithTxConfig(cfg.TxConfig) + + err = tx.Sign(txFactory, nodeDirName, txBuilder, true) + require.NoError(t, err) + + txBz, err := cfg.TxConfig.TxJSONEncoder()(txBuilder.GetTx()) + require.NoError(t, err) + require.NoError(t, writeFile(fmt.Sprintf("%v.json", nodeDirName), gentxsDir, txBz)) + + srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), appCfg) + + clientCtx := client.Context{}. + WithKeyring(kb). + WithHomeDir(tmCfg.RootDir). + WithChainID(cfg.ChainID). + WithInterfaceRegistry(cfg.InterfaceRegistry). + WithCodec(cfg.Codec). + WithLegacyAmino(cfg.LegacyAmino). + WithTxConfig(cfg.TxConfig). + WithAccountRetriever(cfg.AccountRetriever) + + network.Validators[i] = &Validator{ + AppConfig: appCfg, + ClientCtx: clientCtx, + Ctx: ctx, + Dir: filepath.Join(network.BaseDir, nodeDirName), + NodeID: nodeID, + PubKey: pubKey, + Moniker: nodeDirName, + RPCAddress: tmCfg.RPC.ListenAddress, + P2PAddress: tmCfg.P2P.ListenAddress, + APIAddress: apiAddr, + Address: addr, + ValAddress: sdk.ValAddress(addr), + } + } + + require.NoError(t, initGenFiles(cfg, genAccounts, genBalances, genFiles)) + require.NoError(t, collectGenFiles(cfg, network.Validators, network.BaseDir)) + + t.Log("starting test network...") + for _, v := range network.Validators { + require.NoError(t, startInProcess(cfg, v)) + } + + t.Log("started test network") + + // Ensure we cleanup incase any test was abruptly halted (e.g. SIGINT) as any + // defer in a test would not be called. + server.TrapSignal(network.Cleanup) + + return network +} + +// LatestHeight returns the latest height of the network or an error if the +// query fails or no validators exist. +func (n *Network) LatestHeight() (int64, error) { + if len(n.Validators) == 0 { + return 0, errors.New("no validators available") + } + + status, err := n.Validators[0].RPCClient.Status(context.Background()) + if err != nil { + return 0, err + } + + return status.SyncInfo.LatestBlockHeight, nil +} + +// WaitForHeight performs a blocking check where it waits for a block to be +// committed after a given block. If that height is not reached within a timeout, +// an error is returned. Regardless, the latest height queried is returned. +func (n *Network) WaitForHeight(h int64) (int64, error) { + return n.WaitForHeightWithTimeout(h, 10*time.Second) +} + +// WaitForHeightWithTimeout is the same as WaitForHeight except the caller can +// provide a custom timeout. +func (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, error) { + ticker := time.NewTicker(time.Second) + timeout := time.After(t) + + if len(n.Validators) == 0 { + return 0, errors.New("no validators available") + } + + var latestHeight int64 + val := n.Validators[0] + + for { + select { + case <-timeout: + ticker.Stop() + return latestHeight, errors.New("timeout exceeded waiting for block") + case <-ticker.C: + status, err := val.RPCClient.Status(context.Background()) + if err == nil && status != nil { + latestHeight = status.SyncInfo.LatestBlockHeight + if latestHeight >= h { + return latestHeight, nil + } + } + } + } +} + +// WaitForNextBlock waits for the next block to be committed, returning an error +// upon failure. +func (n *Network) WaitForNextBlock() error { + lastBlock, err := n.LatestHeight() + if err != nil { + return err + } + + _, err = n.WaitForHeight(lastBlock + 1) + if err != nil { + return err + } + + return err +} + +// Cleanup removes the root testing (temporary) directory and stops both the +// Tendermint and API services. It allows other callers to create and start +// test networks. This method must be called when a test is finished, typically +// in a defer. +func (n *Network) Cleanup() { + defer func() { + lock.Unlock() + n.T.Log("released test network lock") + }() + + n.T.Log("cleaning up test network...") + + for _, v := range n.Validators { + if v.tmNode != nil && v.tmNode.IsRunning() { + _ = v.tmNode.Stop() + } + + if v.api != nil { + _ = v.api.Close() + } + + if v.grpc != nil { + v.grpc.Stop() + } + } + + if n.Config.CleanupDir { + _ = os.RemoveAll(n.BaseDir) + } + + n.T.Log("finished cleaning up test network") +} diff --git a/regen/types/testutil/network/suite.go b/regen/types/testutil/network/suite.go new file mode 100644 index 0000000000..8f49791cfc --- /dev/null +++ b/regen/types/testutil/network/suite.go @@ -0,0 +1,38 @@ +package network + +import ( + "time" + + "github.com/stretchr/testify/suite" +) + +type IntegrationTestSuite struct { + suite.Suite + + cfg Config + network *Network +} + +func NewIntegrationTestSuite(cfg Config) *IntegrationTestSuite { + return &IntegrationTestSuite{cfg: cfg} +} + +func (s *IntegrationTestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + s.network = New(s.T(), s.cfg) + s.Require().NotNil(s.network) + + _, err := s.network.WaitForHeight(1) + s.Require().NoError(err) +} + +func (s *IntegrationTestSuite) TearDownSuite() { + s.T().Log("tearing down integration test suite") + s.network.Cleanup() +} + +func (s *IntegrationTestSuite) TestNetwork_Liveness() { + h, err := s.network.WaitForHeightWithTimeout(10, time.Minute) + s.Require().NoError(err, "expected to reach 10 blocks; got %d", h) +} diff --git a/regen/types/testutil/network/util.go b/regen/types/testutil/network/util.go new file mode 100644 index 0000000000..7393500802 --- /dev/null +++ b/regen/types/testutil/network/util.go @@ -0,0 +1,190 @@ +package network + +import ( + "encoding/json" + "path/filepath" + "time" + + tmos "github.com/tendermint/tendermint/libs/os" + "github.com/tendermint/tendermint/node" + "github.com/tendermint/tendermint/p2p" + pvm "github.com/tendermint/tendermint/privval" + "github.com/tendermint/tendermint/proxy" + "github.com/tendermint/tendermint/rpc/client/local" + "github.com/tendermint/tendermint/types" + tmtime "github.com/tendermint/tendermint/types/time" + + "github.com/cosmos/cosmos-sdk/server/api" + servergrpc "github.com/cosmos/cosmos-sdk/server/grpc" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" +) + +func startInProcess(cfg Config, val *Validator) error { + logger := val.Ctx.Logger + tmCfg := val.Ctx.Config + tmCfg.Instrumentation.Prometheus = false + + nodeKey, err := p2p.LoadOrGenNodeKey(tmCfg.NodeKeyFile()) + if err != nil { + return err + } + + app := cfg.AppConstructor(*val) + + genDocProvider := node.DefaultGenesisDocProviderFunc(tmCfg) + tmNode, err := node.NewNode( + tmCfg, + pvm.LoadOrGenFilePV(tmCfg.PrivValidatorKeyFile(), tmCfg.PrivValidatorStateFile()), + nodeKey, + proxy.NewLocalClientCreator(app), + genDocProvider, + node.DefaultDBProvider, + node.DefaultMetricsProvider(tmCfg.Instrumentation), + logger.With("module", val.Moniker), + ) + if err != nil { + return err + } + + if err := tmNode.Start(); err != nil { + return err + } + + val.tmNode = tmNode + + if val.RPCAddress != "" { + val.RPCClient = local.New(tmNode) + } + + if val.APIAddress != "" { + val.ClientCtx = val.ClientCtx. + WithClient(val.RPCClient) + + apiSrv := api.New(val.ClientCtx, logger.With("module", "api-server")) + app.RegisterAPIRoutes(apiSrv, val.AppConfig.API) + + errCh := make(chan error) + + go func() { + if err := apiSrv.Start(*val.AppConfig); err != nil { + errCh <- err + } + }() + + select { + case err := <-errCh: + return err + case <-time.After(5 * time.Second): // assume server started successfully + } + + val.api = apiSrv + } + + if val.AppConfig.GRPC.Enable { + grpcSrv, err := servergrpc.StartGRPCServer(val.ClientCtx, app, val.AppConfig.GRPC.Address) + if err != nil { + return err + } + + val.grpc = grpcSrv + } + + return nil +} + +func collectGenFiles(cfg Config, vals []*Validator, outputDir string) error { + genTime := tmtime.Now() + + for i := 0; i < cfg.NumValidators; i++ { + tmCfg := vals[i].Ctx.Config + + nodeDir := filepath.Join(outputDir, vals[i].Moniker, "simd") + gentxsDir := filepath.Join(outputDir, "gentxs") + + tmCfg.Moniker = vals[i].Moniker + tmCfg.SetRoot(nodeDir) + + initCfg := genutiltypes.NewInitConfig(cfg.ChainID, gentxsDir, vals[i].NodeID, vals[i].PubKey) + + genFile := tmCfg.GenesisFile() + genDoc, err := types.GenesisDocFromFile(genFile) + if err != nil { + return err + } + + appState, err := genutil.GenAppStateFromConfig(cfg.Codec, cfg.TxConfig, + tmCfg, initCfg, *genDoc, banktypes.GenesisBalancesIterator{}) + if err != nil { + return err + } + + // overwrite each validator's genesis file to have a canonical genesis time + if err := genutil.ExportGenesisFileWithTime(genFile, cfg.ChainID, nil, appState, genTime); err != nil { + return err + } + } + + return nil +} + +func initGenFiles(cfg Config, genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance, genFiles []string) error { + + // set the accounts in the genesis state + var authGenState authtypes.GenesisState + cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[authtypes.ModuleName], &authGenState) + + accounts, err := authtypes.PackAccounts(genAccounts) + if err != nil { + return err + } + + authGenState.Accounts = accounts + cfg.GenesisState[authtypes.ModuleName] = cfg.Codec.MustMarshalJSON(&authGenState) + + // set the balances in the genesis state + var bankGenState banktypes.GenesisState + cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[banktypes.ModuleName], &bankGenState) + + bankGenState.Balances = genBalances + cfg.GenesisState[banktypes.ModuleName] = cfg.Codec.MustMarshalJSON(&bankGenState) + + appGenStateJSON, err := json.MarshalIndent(cfg.GenesisState, "", " ") + if err != nil { + return err + } + + genDoc := types.GenesisDoc{ + ChainID: cfg.ChainID, + AppState: appGenStateJSON, + Validators: nil, + } + + // generate empty genesis files for each validator and save + for i := 0; i < cfg.NumValidators; i++ { + if err := genDoc.SaveAs(genFiles[i]); err != nil { + return err + } + } + + return nil +} + +func writeFile(name string, dir string, contents []byte) error { + writePath := filepath.Join(dir) + file := filepath.Join(writePath, name) + + err := tmos.EnsureDir(writePath, 0755) + if err != nil { + return err + } + + err = tmos.WriteFile(file, contents, 0644) + if err != nil { + return err + } + + return nil +} From 388bf1270cdad6c1f36e6a847dc819dec3a212d2 Mon Sep 17 00:00:00 2001 From: kitty Date: Thu, 26 Aug 2021 14:48:19 +0100 Subject: [PATCH 24/34] upgrade testsuite to regen-ledger v2.0.0-beta1 --- x/group/client/testsuite/query.go | 4 +- x/group/client/testsuite/tx.go | 166 +++++--- x/group/query_cosmos.pb.go | 610 --------------------------- x/group/server/testsuite/suite.go | 17 +- x/group/tx_cosmos.pb.go | 661 ------------------------------ 5 files changed, 122 insertions(+), 1336 deletions(-) delete mode 100644 x/group/query_cosmos.pb.go delete mode 100644 x/group/tx_cosmos.pb.go diff --git a/x/group/client/testsuite/query.go b/x/group/client/testsuite/query.go index cd08fbd5a1..c200857fd4 100644 --- a/x/group/client/testsuite/query.go +++ b/x/group/client/testsuite/query.go @@ -387,7 +387,7 @@ func (s *IntegrationTestSuite) TestQueryGroupAccountsByAdmin() { s.Require().NoError(err, out.String()) var res group.QueryGroupAccountsByAdminResponse - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) s.Require().Equal(len(res.GroupAccounts), len(tc.expectGroupAccounts)) for i := range res.GroupAccounts { s.Require().Equal(res.GroupAccounts[i].GroupId, tc.expectGroupAccounts[i].GroupId) @@ -497,7 +497,7 @@ func (s *IntegrationTestSuite) TestQueryProposalsByGroupAccount() { s.Require().NoError(err, out.String()) var res group.QueryProposalsByGroupAccountResponse - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) s.Require().Equal(len(res.Proposals), len(tc.expectProposals)) for i := range res.Proposals { s.Require().Equal(res.Proposals[i], tc.expectProposals[i]) diff --git a/x/group/client/testsuite/tx.go b/x/group/client/testsuite/tx.go index 93b15d3d61..84a4d51bb8 100644 --- a/x/group/client/testsuite/tx.go +++ b/x/group/client/testsuite/tx.go @@ -4,7 +4,6 @@ import ( "fmt" "strconv" "strings" - "testing" tmcli "github.com/tendermint/tendermint/libs/cli" @@ -38,14 +37,16 @@ type IntegrationTestSuite struct { const validMetadata = "AQ==" +func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite { + return &IntegrationTestSuite{cfg: cfg} +} + func (s *IntegrationTestSuite) SetupSuite() { s.T().Log("setting up integration test suite") - cfg := network.DefaultConfig() - cfg.NumValidators = 2 - - s.cfg = cfg - s.network = network.New(s.T(), cfg) + // We execute NewIntegrationTestSuite to set cfg field of IntegrationTestSuite + s.cfg.NumValidators = 2 + s.network = network.New(s.T(), s.cfg) _, err := s.network.WaitForHeight(1) s.Require().NoError(err) @@ -53,7 +54,7 @@ func (s *IntegrationTestSuite) SetupSuite() { val := s.network.Validators[0] // create a new account - info, _, err := val.ClientCtx.Keyring.NewMnemonic("NewValidator", keyring.English, sdk.FullFundraiserPath, hd.Secp256k1) + info, _, err := val.ClientCtx.Keyring.NewMnemonic("NewValidator", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) s.Require().NoError(err) account := sdk.AccAddress(info.GetPubKey().Address()) @@ -76,7 +77,7 @@ func (s *IntegrationTestSuite) SetupSuite() { // create a group validMembers := fmt.Sprintf(`{"members": [{ "address": "%s", - "weight": "1", + "weight": "3", "metadata": "%s" }]}`, val.Address.String(), validMetadata) validMembersFile := testutil.WriteToNewTempFile(s.T(), validMembers) @@ -93,26 +94,30 @@ func (s *IntegrationTestSuite) SetupSuite() { s.Require().NoError(err, out.String()) var txResp = sdk.TxResponse{} - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) s.Require().Equal(uint32(0), txResp.Code, out.String()) - s.group = &group.GroupInfo{GroupId: 1, Admin: val.Address.String(), Metadata: []byte{1}, TotalWeight: "1", Version: 1} + s.group = &group.GroupInfo{GroupId: 1, Admin: val.Address.String(), Metadata: []byte{1}, TotalWeight: "3", Version: 1} - // create 4 group accounts - for i := 0; i < 4; i++ { + // create 5 group accounts + for i := 0; i < 5; i++ { + threshold := i + 1 + if threshold > 3 { + threshold = 3 + } out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateGroupAccountCmd(), append( []string{ val.Address.String(), "1", validMetadata, - "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"timeout\":\"30000s\"}", + fmt.Sprintf("{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"%d\", \"timeout\":\"30000s\"}", threshold), }, commonFlags..., ), ) s.Require().NoError(err, out.String()) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) s.Require().Equal(uint32(0), txResp.Code, out.String()) out, err = cli.ExecTestCLICmd(val.ClientCtx, client.QueryGroupAccountsByGroupCmd(), []string{"1", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) @@ -120,8 +125,8 @@ func (s *IntegrationTestSuite) SetupSuite() { } var res group.QueryGroupAccountsByGroupResponse - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res)) - s.Require().Equal(len(res.GroupAccounts), 4) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) + s.Require().Equal(len(res.GroupAccounts), 5) s.groupAccounts = res.GroupAccounts // create a proposal @@ -139,7 +144,7 @@ func (s *IntegrationTestSuite) SetupSuite() { ), ) s.Require().NoError(err, out.String()) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) s.Require().Equal(uint32(0), txResp.Code, out.String()) // vote @@ -155,21 +160,21 @@ func (s *IntegrationTestSuite) SetupSuite() { ), ) s.Require().NoError(err, out.String()) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) s.Require().Equal(uint32(0), txResp.Code, out.String()) out, err = cli.ExecTestCLICmd(val.ClientCtx, client.QueryProposalCmd(), []string{"1", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) s.Require().NoError(err, out.String()) var proposalRes group.QueryProposalResponse - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &proposalRes)) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &proposalRes)) s.proposal = proposalRes.Proposal out, err = cli.ExecTestCLICmd(val.ClientCtx, client.QueryVoteByProposalVoterCmd(), []string{"1", val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) s.Require().NoError(err, out.String()) var voteRes group.QueryVoteByProposalVoterResponse - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &voteRes)) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &voteRes)) s.vote = voteRes.Vote } @@ -326,7 +331,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroup() { s.Require().Contains(out.String(), tc.expectErrMsg) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -446,7 +451,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAdmin() { s.Require().Contains(out.String(), tc.expectErrMsg) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -532,7 +537,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMetadata() { s.Require().Contains(out.String(), tc.expectErrMsg) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -654,7 +659,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMembers() { s.Require().Contains(out.String(), tc.expectErrMsg) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -729,7 +734,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupAccount() { commonFlags..., ), true, - "The specified item could not be found in the keyring", + "key not found", &sdk.TxResponse{}, 0, }, @@ -778,7 +783,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupAccount() { s.Require().Contains(out.String(), tc.expectErrMsg) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -791,7 +796,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAccountAdmin() { val := s.network.Validators[0] newAdmin := s.network.Validators[1].Address clientCtx := val.ClientCtx - groupAccount := s.groupAccounts[1] + groupAccount := s.groupAccounts[3] var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), @@ -827,7 +832,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAccountAdmin() { append( []string{ groupAccount.Admin, - s.groupAccounts[2].Address, + s.groupAccounts[4].Address, newAdmin.String(), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, @@ -849,7 +854,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAccountAdmin() { commonFlags..., ), true, - "The specified item could not be found in the keyring", + "key not found", &sdk.TxResponse{}, 0, }, @@ -881,7 +886,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAccountAdmin() { s.Require().Contains(out.String(), tc.expectErrMsg) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -894,7 +899,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAccountDecisionPolicy() { val := s.network.Validators[0] newAdmin := s.network.Validators[1].Address clientCtx := val.ClientCtx - groupAccount := s.groupAccounts[3] + groupAccount := s.groupAccounts[2] var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), @@ -916,7 +921,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAccountDecisionPolicy() { []string{ groupAccount.Admin, groupAccount.Address, - "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"2\", \"timeout\":\"2s\"}", + "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"timeout\":\"40000s\"}", }, commonFlags..., ), @@ -931,7 +936,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAccountDecisionPolicy() { []string{ groupAccount.Admin, groupAccount.Address, - "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"2\", \"timeout\":\"2s\"}", + "{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"timeout\":\"50000s\"}", fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, commonFlags..., @@ -952,7 +957,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAccountDecisionPolicy() { commonFlags..., ), true, - "The specified item could not be found in the keyring", + "key not found", &sdk.TxResponse{}, 0, }, @@ -984,7 +989,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAccountDecisionPolicy() { s.Require().Contains(out.String(), tc.expectErrMsg) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -997,7 +1002,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAccountMetadata() { val := s.network.Validators[0] newAdmin := s.network.Validators[1].Address clientCtx := val.ClientCtx - groupAccount := s.groupAccounts[3] + groupAccount := s.groupAccounts[2] var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), @@ -1070,7 +1075,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAccountMetadata() { commonFlags..., ), true, - "The specified item could not be found in the keyring", + "key not found", &sdk.TxResponse{}, 0, }, @@ -1102,7 +1107,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAccountMetadata() { s.Require().Contains(out.String(), tc.expectErrMsg) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -1123,6 +1128,7 @@ func (s *IntegrationTestSuite) TestTxCreateProposal() { validTxFileName := getTxSendFileName(s, s.groupAccounts[0].Address, val.Address.String()) unauthzTxFileName := getTxSendFileName(s, val.Address.String(), s.groupAccounts[0].Address) + validTxFileName2 := getTxSendFileName(s, s.groupAccounts[3].Address, val.Address.String()) testCases := []struct { name string @@ -1149,6 +1155,42 @@ func (s *IntegrationTestSuite) TestTxCreateProposal() { &sdk.TxResponse{}, 0, }, + { + "with try exec", + append( + []string{ + s.groupAccounts[0].Address, + val.Address.String(), + validTxFileName, + "", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=try", client.FlagExec), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "with try exec, not enough yes votes for proposal to pass", + append( + []string{ + s.groupAccounts[3].Address, + val.Address.String(), + validTxFileName2, + "", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=try", client.FlagExec), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, { "with amino-json", append( @@ -1265,7 +1307,7 @@ func (s *IntegrationTestSuite) TestTxCreateProposal() { s.Require().Contains(out.String(), tc.expectErrMsg) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -1284,12 +1326,12 @@ func (s *IntegrationTestSuite) TestTxVote() { fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } - validTxFileName := getTxSendFileName(s, s.groupAccounts[3].Address, val.Address.String()) + validTxFileName := getTxSendFileName(s, s.groupAccounts[1].Address, val.Address.String()) for i := 0; i < 2; i++ { out, err := cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateProposalCmd(), append( []string{ - s.groupAccounts[3].Address, + s.groupAccounts[1].Address, val.Address.String(), validTxFileName, "", @@ -1325,6 +1367,40 @@ func (s *IntegrationTestSuite) TestTxVote() { &sdk.TxResponse{}, 0, }, + { + "with try exec", + append( + []string{ + "7", + val.Address.String(), + "CHOICE_YES", + "", + fmt.Sprintf("--%s=try", client.FlagExec), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "with try exec, not enough yes votes for proposal to pass", + append( + []string{ + "8", + val.Address.String(), + "CHOICE_NO", + "", + fmt.Sprintf("--%s=try", client.FlagExec), + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, { "with amino-json", append( @@ -1419,7 +1495,7 @@ func (s *IntegrationTestSuite) TestTxVote() { s.Require().Contains(out.String(), tc.expectErrMsg) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -1547,7 +1623,7 @@ func (s *IntegrationTestSuite) TestTxExec() { s.Require().Contains(out.String(), tc.expectErrMsg) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -1563,7 +1639,3 @@ func getTxSendFileName(s *IntegrationTestSuite, from string, to string) string { ) return testutil.WriteToNewTempFile(s.T(), tx).Name() } - -func TestIntegrationTestSuite(t *testing.T) { - suite.Run(t, new(IntegrationTestSuite)) -} diff --git a/x/group/query_cosmos.pb.go b/x/group/query_cosmos.pb.go deleted file mode 100644 index 6c239210ed..0000000000 --- a/x/group/query_cosmos.pb.go +++ /dev/null @@ -1,610 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. - -package group - -import ( - context "context" - types "github.com/regen-network/regen-ledger/types" - grpc "google.golang.org/grpc" -) - -// 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.SupportPackageIsVersion7 - -// QueryClient is the client API for Query service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type QueryClient interface { - // GroupInfo queries group info based on group id. - GroupInfo(ctx context.Context, in *QueryGroupInfoRequest, opts ...grpc.CallOption) (*QueryGroupInfoResponse, error) - // GroupAccountInfo queries group account info based on group account address. - GroupAccountInfo(ctx context.Context, in *QueryGroupAccountInfoRequest, opts ...grpc.CallOption) (*QueryGroupAccountInfoResponse, error) - // GroupMembers queries members of a group - GroupMembers(ctx context.Context, in *QueryGroupMembersRequest, opts ...grpc.CallOption) (*QueryGroupMembersResponse, error) - // GroupsByAdmin queries groups by admin address. - GroupsByAdmin(ctx context.Context, in *QueryGroupsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupsByAdminResponse, error) - // GroupAccountsByGroup queries group accounts by group id. - GroupAccountsByGroup(ctx context.Context, in *QueryGroupAccountsByGroupRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByGroupResponse, error) - // GroupsByAdmin queries group accounts by admin address. - GroupAccountsByAdmin(ctx context.Context, in *QueryGroupAccountsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByAdminResponse, error) - // Proposal queries a proposal based on proposal id. - Proposal(ctx context.Context, in *QueryProposalRequest, opts ...grpc.CallOption) (*QueryProposalResponse, error) - // ProposalsByGroupAccount queries proposals based on group account address. - ProposalsByGroupAccount(ctx context.Context, in *QueryProposalsByGroupAccountRequest, opts ...grpc.CallOption) (*QueryProposalsByGroupAccountResponse, error) - // VoteByProposalVoter queries a vote by proposal id and voter. - VoteByProposalVoter(ctx context.Context, in *QueryVoteByProposalVoterRequest, opts ...grpc.CallOption) (*QueryVoteByProposalVoterResponse, error) - // VotesByProposal queries a vote by proposal. - VotesByProposal(ctx context.Context, in *QueryVotesByProposalRequest, opts ...grpc.CallOption) (*QueryVotesByProposalResponse, error) - // VotesByVoter queries a vote by voter. - VotesByVoter(ctx context.Context, in *QueryVotesByVoterRequest, opts ...grpc.CallOption) (*QueryVotesByVoterResponse, error) -} - -type queryClient struct { - cc grpc.ClientConnInterface - _GroupInfo types.Invoker - _GroupAccountInfo types.Invoker - _GroupMembers types.Invoker - _GroupsByAdmin types.Invoker - _GroupAccountsByGroup types.Invoker - _GroupAccountsByAdmin types.Invoker - _Proposal types.Invoker - _ProposalsByGroupAccount types.Invoker - _VoteByProposalVoter types.Invoker - _VotesByProposal types.Invoker - _VotesByVoter types.Invoker -} - -func NewQueryClient(cc grpc.ClientConnInterface) QueryClient { - return &queryClient{cc: cc} -} - -func (c *queryClient) GroupInfo(ctx context.Context, in *QueryGroupInfoRequest, opts ...grpc.CallOption) (*QueryGroupInfoResponse, error) { - if invoker := c._GroupInfo; invoker != nil { - var out QueryGroupInfoResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._GroupInfo, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/GroupInfo") - if err != nil { - var out QueryGroupInfoResponse - err = c._GroupInfo(ctx, in, &out) - return &out, err - } - } - out := new(QueryGroupInfoResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) GroupAccountInfo(ctx context.Context, in *QueryGroupAccountInfoRequest, opts ...grpc.CallOption) (*QueryGroupAccountInfoResponse, error) { - if invoker := c._GroupAccountInfo; invoker != nil { - var out QueryGroupAccountInfoResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._GroupAccountInfo, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/GroupAccountInfo") - if err != nil { - var out QueryGroupAccountInfoResponse - err = c._GroupAccountInfo(ctx, in, &out) - return &out, err - } - } - out := new(QueryGroupAccountInfoResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupAccountInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) GroupMembers(ctx context.Context, in *QueryGroupMembersRequest, opts ...grpc.CallOption) (*QueryGroupMembersResponse, error) { - if invoker := c._GroupMembers; invoker != nil { - var out QueryGroupMembersResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._GroupMembers, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/GroupMembers") - if err != nil { - var out QueryGroupMembersResponse - err = c._GroupMembers(ctx, in, &out) - return &out, err - } - } - out := new(QueryGroupMembersResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupMembers", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) GroupsByAdmin(ctx context.Context, in *QueryGroupsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupsByAdminResponse, error) { - if invoker := c._GroupsByAdmin; invoker != nil { - var out QueryGroupsByAdminResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._GroupsByAdmin, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/GroupsByAdmin") - if err != nil { - var out QueryGroupsByAdminResponse - err = c._GroupsByAdmin(ctx, in, &out) - return &out, err - } - } - out := new(QueryGroupsByAdminResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupsByAdmin", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) GroupAccountsByGroup(ctx context.Context, in *QueryGroupAccountsByGroupRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByGroupResponse, error) { - if invoker := c._GroupAccountsByGroup; invoker != nil { - var out QueryGroupAccountsByGroupResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._GroupAccountsByGroup, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/GroupAccountsByGroup") - if err != nil { - var out QueryGroupAccountsByGroupResponse - err = c._GroupAccountsByGroup(ctx, in, &out) - return &out, err - } - } - out := new(QueryGroupAccountsByGroupResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupAccountsByGroup", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) GroupAccountsByAdmin(ctx context.Context, in *QueryGroupAccountsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByAdminResponse, error) { - if invoker := c._GroupAccountsByAdmin; invoker != nil { - var out QueryGroupAccountsByAdminResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._GroupAccountsByAdmin, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/GroupAccountsByAdmin") - if err != nil { - var out QueryGroupAccountsByAdminResponse - err = c._GroupAccountsByAdmin(ctx, in, &out) - return &out, err - } - } - out := new(QueryGroupAccountsByAdminResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupAccountsByAdmin", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) Proposal(ctx context.Context, in *QueryProposalRequest, opts ...grpc.CallOption) (*QueryProposalResponse, error) { - if invoker := c._Proposal; invoker != nil { - var out QueryProposalResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._Proposal, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/Proposal") - if err != nil { - var out QueryProposalResponse - err = c._Proposal(ctx, in, &out) - return &out, err - } - } - out := new(QueryProposalResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/Proposal", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) ProposalsByGroupAccount(ctx context.Context, in *QueryProposalsByGroupAccountRequest, opts ...grpc.CallOption) (*QueryProposalsByGroupAccountResponse, error) { - if invoker := c._ProposalsByGroupAccount; invoker != nil { - var out QueryProposalsByGroupAccountResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._ProposalsByGroupAccount, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/ProposalsByGroupAccount") - if err != nil { - var out QueryProposalsByGroupAccountResponse - err = c._ProposalsByGroupAccount(ctx, in, &out) - return &out, err - } - } - out := new(QueryProposalsByGroupAccountResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/ProposalsByGroupAccount", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) VoteByProposalVoter(ctx context.Context, in *QueryVoteByProposalVoterRequest, opts ...grpc.CallOption) (*QueryVoteByProposalVoterResponse, error) { - if invoker := c._VoteByProposalVoter; invoker != nil { - var out QueryVoteByProposalVoterResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._VoteByProposalVoter, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/VoteByProposalVoter") - if err != nil { - var out QueryVoteByProposalVoterResponse - err = c._VoteByProposalVoter(ctx, in, &out) - return &out, err - } - } - out := new(QueryVoteByProposalVoterResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VoteByProposalVoter", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) VotesByProposal(ctx context.Context, in *QueryVotesByProposalRequest, opts ...grpc.CallOption) (*QueryVotesByProposalResponse, error) { - if invoker := c._VotesByProposal; invoker != nil { - var out QueryVotesByProposalResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._VotesByProposal, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/VotesByProposal") - if err != nil { - var out QueryVotesByProposalResponse - err = c._VotesByProposal(ctx, in, &out) - return &out, err - } - } - out := new(QueryVotesByProposalResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VotesByProposal", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) VotesByVoter(ctx context.Context, in *QueryVotesByVoterRequest, opts ...grpc.CallOption) (*QueryVotesByVoterResponse, error) { - if invoker := c._VotesByVoter; invoker != nil { - var out QueryVotesByVoterResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._VotesByVoter, err = invokerConn.Invoker("/regen.group.v1alpha1.Query/VotesByVoter") - if err != nil { - var out QueryVotesByVoterResponse - err = c._VotesByVoter(ctx, in, &out) - return &out, err - } - } - out := new(QueryVotesByVoterResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VotesByVoter", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // GroupInfo queries group info based on group id. - GroupInfo(types.Context, *QueryGroupInfoRequest) (*QueryGroupInfoResponse, error) - // GroupAccountInfo queries group account info based on group account address. - GroupAccountInfo(types.Context, *QueryGroupAccountInfoRequest) (*QueryGroupAccountInfoResponse, error) - // GroupMembers queries members of a group - GroupMembers(types.Context, *QueryGroupMembersRequest) (*QueryGroupMembersResponse, error) - // GroupsByAdmin queries groups by admin address. - GroupsByAdmin(types.Context, *QueryGroupsByAdminRequest) (*QueryGroupsByAdminResponse, error) - // GroupAccountsByGroup queries group accounts by group id. - GroupAccountsByGroup(types.Context, *QueryGroupAccountsByGroupRequest) (*QueryGroupAccountsByGroupResponse, error) - // GroupsByAdmin queries group accounts by admin address. - GroupAccountsByAdmin(types.Context, *QueryGroupAccountsByAdminRequest) (*QueryGroupAccountsByAdminResponse, error) - // Proposal queries a proposal based on proposal id. - Proposal(types.Context, *QueryProposalRequest) (*QueryProposalResponse, error) - // ProposalsByGroupAccount queries proposals based on group account address. - ProposalsByGroupAccount(types.Context, *QueryProposalsByGroupAccountRequest) (*QueryProposalsByGroupAccountResponse, error) - // VoteByProposalVoter queries a vote by proposal id and voter. - VoteByProposalVoter(types.Context, *QueryVoteByProposalVoterRequest) (*QueryVoteByProposalVoterResponse, error) - // VotesByProposal queries a vote by proposal. - VotesByProposal(types.Context, *QueryVotesByProposalRequest) (*QueryVotesByProposalResponse, error) - // VotesByVoter queries a vote by voter. - VotesByVoter(types.Context, *QueryVotesByVoterRequest) (*QueryVotesByVoterResponse, error) -} - -func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) { - s.RegisterService(&Query_ServiceDesc, srv) -} - -func _Query_GroupInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGroupInfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GroupInfo(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/GroupInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GroupInfo(types.UnwrapSDKContext(ctx), req.(*QueryGroupInfoRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_GroupAccountInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGroupAccountInfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GroupAccountInfo(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/GroupAccountInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GroupAccountInfo(types.UnwrapSDKContext(ctx), req.(*QueryGroupAccountInfoRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_GroupMembers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGroupMembersRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GroupMembers(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/GroupMembers", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GroupMembers(types.UnwrapSDKContext(ctx), req.(*QueryGroupMembersRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_GroupsByAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGroupsByAdminRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GroupsByAdmin(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/GroupsByAdmin", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GroupsByAdmin(types.UnwrapSDKContext(ctx), req.(*QueryGroupsByAdminRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_GroupAccountsByGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGroupAccountsByGroupRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GroupAccountsByGroup(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/GroupAccountsByGroup", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GroupAccountsByGroup(types.UnwrapSDKContext(ctx), req.(*QueryGroupAccountsByGroupRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_GroupAccountsByAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGroupAccountsByAdminRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GroupAccountsByAdmin(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/GroupAccountsByAdmin", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GroupAccountsByAdmin(types.UnwrapSDKContext(ctx), req.(*QueryGroupAccountsByAdminRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_Proposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryProposalRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Proposal(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/Proposal", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Proposal(types.UnwrapSDKContext(ctx), req.(*QueryProposalRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_ProposalsByGroupAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryProposalsByGroupAccountRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ProposalsByGroupAccount(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/ProposalsByGroupAccount", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ProposalsByGroupAccount(types.UnwrapSDKContext(ctx), req.(*QueryProposalsByGroupAccountRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_VoteByProposalVoter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryVoteByProposalVoterRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).VoteByProposalVoter(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/VoteByProposalVoter", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).VoteByProposalVoter(types.UnwrapSDKContext(ctx), req.(*QueryVoteByProposalVoterRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_VotesByProposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryVotesByProposalRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).VotesByProposal(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/VotesByProposal", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).VotesByProposal(types.UnwrapSDKContext(ctx), req.(*QueryVotesByProposalRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_VotesByVoter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryVotesByVoterRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).VotesByVoter(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/VotesByVoter", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).VotesByVoter(types.UnwrapSDKContext(ctx), req.(*QueryVotesByVoterRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Query_ServiceDesc is the grpc.ServiceDesc for Query service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Query_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "regen.group.v1alpha1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GroupInfo", - Handler: _Query_GroupInfo_Handler, - }, - { - MethodName: "GroupAccountInfo", - Handler: _Query_GroupAccountInfo_Handler, - }, - { - MethodName: "GroupMembers", - Handler: _Query_GroupMembers_Handler, - }, - { - MethodName: "GroupsByAdmin", - Handler: _Query_GroupsByAdmin_Handler, - }, - { - MethodName: "GroupAccountsByGroup", - Handler: _Query_GroupAccountsByGroup_Handler, - }, - { - MethodName: "GroupAccountsByAdmin", - Handler: _Query_GroupAccountsByAdmin_Handler, - }, - { - MethodName: "Proposal", - Handler: _Query_Proposal_Handler, - }, - { - MethodName: "ProposalsByGroupAccount", - Handler: _Query_ProposalsByGroupAccount_Handler, - }, - { - MethodName: "VoteByProposalVoter", - Handler: _Query_VoteByProposalVoter_Handler, - }, - { - MethodName: "VotesByProposal", - Handler: _Query_VotesByProposal_Handler, - }, - { - MethodName: "VotesByVoter", - Handler: _Query_VotesByVoter_Handler, - }, - }, - Metadata: "regen/group/v1alpha1/query.proto", -} - -const ( - QueryGroupInfoMethod = "/regen.group.v1alpha1.Query/GroupInfo" - QueryGroupAccountInfoMethod = "/regen.group.v1alpha1.Query/GroupAccountInfo" - QueryGroupMembersMethod = "/regen.group.v1alpha1.Query/GroupMembers" - QueryGroupsByAdminMethod = "/regen.group.v1alpha1.Query/GroupsByAdmin" - QueryGroupAccountsByGroupMethod = "/regen.group.v1alpha1.Query/GroupAccountsByGroup" - QueryGroupAccountsByAdminMethod = "/regen.group.v1alpha1.Query/GroupAccountsByAdmin" - QueryProposalMethod = "/regen.group.v1alpha1.Query/Proposal" - QueryProposalsByGroupAccountMethod = "/regen.group.v1alpha1.Query/ProposalsByGroupAccount" - QueryVoteByProposalVoterMethod = "/regen.group.v1alpha1.Query/VoteByProposalVoter" - QueryVotesByProposalMethod = "/regen.group.v1alpha1.Query/VotesByProposal" - QueryVotesByVoterMethod = "/regen.group.v1alpha1.Query/VotesByVoter" -) diff --git a/x/group/server/testsuite/suite.go b/x/group/server/testsuite/suite.go index ccf13607db..7ea45ce3f3 100644 --- a/x/group/server/testsuite/suite.go +++ b/x/group/server/testsuite/suite.go @@ -78,9 +78,8 @@ func (s *IntegrationTestSuite) SetupSuite() { s.sdkCtx, _ = sdkCtx.CacheContext() s.ctx = types.Context{Context: s.sdkCtx} s.genesisCtx = types.Context{Context: sdkCtx} + s.Require().NoError(s.bankKeeper.MintCoins(s.sdkCtx, minttypes.ModuleName, sdk.NewCoins(sdk.NewInt64Coin("test", 400000000)))) - totalSupply := banktypes.NewSupply(sdk.NewCoins(sdk.NewInt64Coin("test", 400000000))) - s.bankKeeper.SetSupply(sdkCtx, totalSupply) s.bankKeeper.SetParams(sdkCtx, banktypes.DefaultParams()) s.msgClient = group.NewMsgClient(s.fixture.TxConn()) @@ -1866,20 +1865,6 @@ func (s *IntegrationTestSuite) TestExecProposal() { expFromBalances: sdk.Coins{sdk.NewInt64Coin("test", 9800)}, expToBalances: sdk.Coins{sdk.NewInt64Coin("test", 200)}, }, - "proposal with ADR 033 executed when accepted": { - setupProposal: func(ctx context.Context) uint64 { - msgs := []sdk.Msg{&ecocredit.MsgCreateClass{ - Designer: s.groupAccountAddr.String(), - Issuers: []string{s.groupAccountAddr.String()}, - CreditType: "carbon", - }, - } - return createProposalAndVote(ctx, s, msgs, proposers, group.Choice_CHOICE_YES) - }, - expProposalStatus: group.ProposalStatusClosed, - expProposalResult: group.ProposalResultAccepted, - expExecutorResult: group.ProposalExecutorResultSuccess, - }, "proposal with multiple messages executed when accepted": { setupProposal: func(ctx context.Context) uint64 { msgs := []sdk.Msg{msgSend1, msgSend1} diff --git a/x/group/tx_cosmos.pb.go b/x/group/tx_cosmos.pb.go deleted file mode 100644 index da15a807c6..0000000000 --- a/x/group/tx_cosmos.pb.go +++ /dev/null @@ -1,661 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. - -package group - -import ( - context "context" - types "github.com/regen-network/regen-ledger/types" - grpc "google.golang.org/grpc" -) - -// 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.SupportPackageIsVersion7 - -// MsgClient is the client API for Msg service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type MsgClient interface { - // CreateGroup creates a new group with an admin account address, a list of members and some optional metadata. - CreateGroup(ctx context.Context, in *MsgCreateGroupRequest, opts ...grpc.CallOption) (*MsgCreateGroupResponse, error) - // UpdateGroupMembers updates the group members with given group id and admin address. - UpdateGroupMembers(ctx context.Context, in *MsgUpdateGroupMembersRequest, opts ...grpc.CallOption) (*MsgUpdateGroupMembersResponse, error) - // UpdateGroupAdmin updates the group admin with given group id and previous admin address. - UpdateGroupAdmin(ctx context.Context, in *MsgUpdateGroupAdminRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAdminResponse, error) - // UpdateGroupMetadata updates the group metadata with given group id and admin address. - UpdateGroupMetadata(ctx context.Context, in *MsgUpdateGroupMetadataRequest, opts ...grpc.CallOption) (*MsgUpdateGroupMetadataResponse, error) - // CreateGroupAccount creates a new group account using given DecisionPolicy. - CreateGroupAccount(ctx context.Context, in *MsgCreateGroupAccountRequest, opts ...grpc.CallOption) (*MsgCreateGroupAccountResponse, error) - // UpdateGroupAccountAdmin updates a group account admin. - UpdateGroupAccountAdmin(ctx context.Context, in *MsgUpdateGroupAccountAdminRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAccountAdminResponse, error) - // UpdateGroupAccountDecisionPolicy allows a group account decision policy to be updated. - UpdateGroupAccountDecisionPolicy(ctx context.Context, in *MsgUpdateGroupAccountDecisionPolicyRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAccountDecisionPolicyResponse, error) - // UpdateGroupAccountMetadata updates a group account metadata. - UpdateGroupAccountMetadata(ctx context.Context, in *MsgUpdateGroupAccountMetadataRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAccountMetadataResponse, error) - // CreateProposal submits a new proposal. - CreateProposal(ctx context.Context, in *MsgCreateProposalRequest, opts ...grpc.CallOption) (*MsgCreateProposalResponse, error) - // Vote allows a voter to vote on a proposal. - Vote(ctx context.Context, in *MsgVoteRequest, opts ...grpc.CallOption) (*MsgVoteResponse, error) - // VoteAgg allows a sender to submit a set of votes - VoteAgg(ctx context.Context, in *MsgVoteAggRequest, opts ...grpc.CallOption) (*MsgVoteAggResponse, error) - // Exec executes a proposal. - Exec(ctx context.Context, in *MsgExecRequest, opts ...grpc.CallOption) (*MsgExecResponse, error) -} - -type msgClient struct { - cc grpc.ClientConnInterface - _CreateGroup types.Invoker - _UpdateGroupMembers types.Invoker - _UpdateGroupAdmin types.Invoker - _UpdateGroupMetadata types.Invoker - _CreateGroupAccount types.Invoker - _UpdateGroupAccountAdmin types.Invoker - _UpdateGroupAccountDecisionPolicy types.Invoker - _UpdateGroupAccountMetadata types.Invoker - _CreateProposal types.Invoker - _Vote types.Invoker - _VoteAgg types.Invoker - _Exec types.Invoker -} - -func NewMsgClient(cc grpc.ClientConnInterface) MsgClient { - return &msgClient{cc: cc} -} - -func (c *msgClient) CreateGroup(ctx context.Context, in *MsgCreateGroupRequest, opts ...grpc.CallOption) (*MsgCreateGroupResponse, error) { - if invoker := c._CreateGroup; invoker != nil { - var out MsgCreateGroupResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._CreateGroup, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/CreateGroup") - if err != nil { - var out MsgCreateGroupResponse - err = c._CreateGroup(ctx, in, &out) - return &out, err - } - } - out := new(MsgCreateGroupResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/CreateGroup", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateGroupMembers(ctx context.Context, in *MsgUpdateGroupMembersRequest, opts ...grpc.CallOption) (*MsgUpdateGroupMembersResponse, error) { - if invoker := c._UpdateGroupMembers; invoker != nil { - var out MsgUpdateGroupMembersResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._UpdateGroupMembers, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/UpdateGroupMembers") - if err != nil { - var out MsgUpdateGroupMembersResponse - err = c._UpdateGroupMembers(ctx, in, &out) - return &out, err - } - } - out := new(MsgUpdateGroupMembersResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupMembers", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateGroupAdmin(ctx context.Context, in *MsgUpdateGroupAdminRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAdminResponse, error) { - if invoker := c._UpdateGroupAdmin; invoker != nil { - var out MsgUpdateGroupAdminResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._UpdateGroupAdmin, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/UpdateGroupAdmin") - if err != nil { - var out MsgUpdateGroupAdminResponse - err = c._UpdateGroupAdmin(ctx, in, &out) - return &out, err - } - } - out := new(MsgUpdateGroupAdminResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAdmin", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateGroupMetadata(ctx context.Context, in *MsgUpdateGroupMetadataRequest, opts ...grpc.CallOption) (*MsgUpdateGroupMetadataResponse, error) { - if invoker := c._UpdateGroupMetadata; invoker != nil { - var out MsgUpdateGroupMetadataResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._UpdateGroupMetadata, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/UpdateGroupMetadata") - if err != nil { - var out MsgUpdateGroupMetadataResponse - err = c._UpdateGroupMetadata(ctx, in, &out) - return &out, err - } - } - out := new(MsgUpdateGroupMetadataResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupMetadata", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) CreateGroupAccount(ctx context.Context, in *MsgCreateGroupAccountRequest, opts ...grpc.CallOption) (*MsgCreateGroupAccountResponse, error) { - if invoker := c._CreateGroupAccount; invoker != nil { - var out MsgCreateGroupAccountResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._CreateGroupAccount, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/CreateGroupAccount") - if err != nil { - var out MsgCreateGroupAccountResponse - err = c._CreateGroupAccount(ctx, in, &out) - return &out, err - } - } - out := new(MsgCreateGroupAccountResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/CreateGroupAccount", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateGroupAccountAdmin(ctx context.Context, in *MsgUpdateGroupAccountAdminRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAccountAdminResponse, error) { - if invoker := c._UpdateGroupAccountAdmin; invoker != nil { - var out MsgUpdateGroupAccountAdminResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._UpdateGroupAccountAdmin, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/UpdateGroupAccountAdmin") - if err != nil { - var out MsgUpdateGroupAccountAdminResponse - err = c._UpdateGroupAccountAdmin(ctx, in, &out) - return &out, err - } - } - out := new(MsgUpdateGroupAccountAdminResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAccountAdmin", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateGroupAccountDecisionPolicy(ctx context.Context, in *MsgUpdateGroupAccountDecisionPolicyRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAccountDecisionPolicyResponse, error) { - if invoker := c._UpdateGroupAccountDecisionPolicy; invoker != nil { - var out MsgUpdateGroupAccountDecisionPolicyResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._UpdateGroupAccountDecisionPolicy, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/UpdateGroupAccountDecisionPolicy") - if err != nil { - var out MsgUpdateGroupAccountDecisionPolicyResponse - err = c._UpdateGroupAccountDecisionPolicy(ctx, in, &out) - return &out, err - } - } - out := new(MsgUpdateGroupAccountDecisionPolicyResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAccountDecisionPolicy", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateGroupAccountMetadata(ctx context.Context, in *MsgUpdateGroupAccountMetadataRequest, opts ...grpc.CallOption) (*MsgUpdateGroupAccountMetadataResponse, error) { - if invoker := c._UpdateGroupAccountMetadata; invoker != nil { - var out MsgUpdateGroupAccountMetadataResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._UpdateGroupAccountMetadata, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/UpdateGroupAccountMetadata") - if err != nil { - var out MsgUpdateGroupAccountMetadataResponse - err = c._UpdateGroupAccountMetadata(ctx, in, &out) - return &out, err - } - } - out := new(MsgUpdateGroupAccountMetadataResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAccountMetadata", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) CreateProposal(ctx context.Context, in *MsgCreateProposalRequest, opts ...grpc.CallOption) (*MsgCreateProposalResponse, error) { - if invoker := c._CreateProposal; invoker != nil { - var out MsgCreateProposalResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._CreateProposal, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/CreateProposal") - if err != nil { - var out MsgCreateProposalResponse - err = c._CreateProposal(ctx, in, &out) - return &out, err - } - } - out := new(MsgCreateProposalResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/CreateProposal", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) Vote(ctx context.Context, in *MsgVoteRequest, opts ...grpc.CallOption) (*MsgVoteResponse, error) { - if invoker := c._Vote; invoker != nil { - var out MsgVoteResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._Vote, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/Vote") - if err != nil { - var out MsgVoteResponse - err = c._Vote(ctx, in, &out) - return &out, err - } - } - out := new(MsgVoteResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/Vote", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) VoteAgg(ctx context.Context, in *MsgVoteAggRequest, opts ...grpc.CallOption) (*MsgVoteAggResponse, error) { - if invoker := c._VoteAgg; invoker != nil { - var out MsgVoteAggResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._VoteAgg, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/VoteAgg") - if err != nil { - var out MsgVoteAggResponse - err = c._VoteAgg(ctx, in, &out) - return &out, err - } - } - out := new(MsgVoteAggResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/VoteAgg", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) Exec(ctx context.Context, in *MsgExecRequest, opts ...grpc.CallOption) (*MsgExecResponse, error) { - if invoker := c._Exec; invoker != nil { - var out MsgExecResponse - err := invoker(ctx, in, &out) - return &out, err - } - if invokerConn, ok := c.cc.(types.InvokerConn); ok { - var err error - c._Exec, err = invokerConn.Invoker("/regen.group.v1alpha1.Msg/Exec") - if err != nil { - var out MsgExecResponse - err = c._Exec(ctx, in, &out) - return &out, err - } - } - out := new(MsgExecResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/Exec", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { - // CreateGroup creates a new group with an admin account address, a list of members and some optional metadata. - CreateGroup(types.Context, *MsgCreateGroupRequest) (*MsgCreateGroupResponse, error) - // UpdateGroupMembers updates the group members with given group id and admin address. - UpdateGroupMembers(types.Context, *MsgUpdateGroupMembersRequest) (*MsgUpdateGroupMembersResponse, error) - // UpdateGroupAdmin updates the group admin with given group id and previous admin address. - UpdateGroupAdmin(types.Context, *MsgUpdateGroupAdminRequest) (*MsgUpdateGroupAdminResponse, error) - // UpdateGroupMetadata updates the group metadata with given group id and admin address. - UpdateGroupMetadata(types.Context, *MsgUpdateGroupMetadataRequest) (*MsgUpdateGroupMetadataResponse, error) - // CreateGroupAccount creates a new group account using given DecisionPolicy. - CreateGroupAccount(types.Context, *MsgCreateGroupAccountRequest) (*MsgCreateGroupAccountResponse, error) - // UpdateGroupAccountAdmin updates a group account admin. - UpdateGroupAccountAdmin(types.Context, *MsgUpdateGroupAccountAdminRequest) (*MsgUpdateGroupAccountAdminResponse, error) - // UpdateGroupAccountDecisionPolicy allows a group account decision policy to be updated. - UpdateGroupAccountDecisionPolicy(types.Context, *MsgUpdateGroupAccountDecisionPolicyRequest) (*MsgUpdateGroupAccountDecisionPolicyResponse, error) - // UpdateGroupAccountMetadata updates a group account metadata. - UpdateGroupAccountMetadata(types.Context, *MsgUpdateGroupAccountMetadataRequest) (*MsgUpdateGroupAccountMetadataResponse, error) - // CreateProposal submits a new proposal. - CreateProposal(types.Context, *MsgCreateProposalRequest) (*MsgCreateProposalResponse, error) - // Vote allows a voter to vote on a proposal. - Vote(types.Context, *MsgVoteRequest) (*MsgVoteResponse, error) - // VoteAgg allows a sender to submit a set of votes - VoteAgg(types.Context, *MsgVoteAggRequest) (*MsgVoteAggResponse, error) - // Exec executes a proposal. - Exec(types.Context, *MsgExecRequest) (*MsgExecResponse, error) -} - -func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) { - s.RegisterService(&Msg_ServiceDesc, srv) -} - -func _Msg_CreateGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreateGroupRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).CreateGroup(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/CreateGroup", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CreateGroup(types.UnwrapSDKContext(ctx), req.(*MsgCreateGroupRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateGroupMembers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateGroupMembersRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateGroupMembers(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupMembers", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateGroupMembers(types.UnwrapSDKContext(ctx), req.(*MsgUpdateGroupMembersRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateGroupAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateGroupAdminRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateGroupAdmin(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAdmin", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateGroupAdmin(types.UnwrapSDKContext(ctx), req.(*MsgUpdateGroupAdminRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateGroupMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateGroupMetadataRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateGroupMetadata(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupMetadata", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateGroupMetadata(types.UnwrapSDKContext(ctx), req.(*MsgUpdateGroupMetadataRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_CreateGroupAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreateGroupAccountRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).CreateGroupAccount(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/CreateGroupAccount", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CreateGroupAccount(types.UnwrapSDKContext(ctx), req.(*MsgCreateGroupAccountRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateGroupAccountAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateGroupAccountAdminRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateGroupAccountAdmin(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAccountAdmin", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateGroupAccountAdmin(types.UnwrapSDKContext(ctx), req.(*MsgUpdateGroupAccountAdminRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateGroupAccountDecisionPolicy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateGroupAccountDecisionPolicyRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateGroupAccountDecisionPolicy(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAccountDecisionPolicy", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateGroupAccountDecisionPolicy(types.UnwrapSDKContext(ctx), req.(*MsgUpdateGroupAccountDecisionPolicyRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateGroupAccountMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateGroupAccountMetadataRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateGroupAccountMetadata(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAccountMetadata", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateGroupAccountMetadata(types.UnwrapSDKContext(ctx), req.(*MsgUpdateGroupAccountMetadataRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_CreateProposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreateProposalRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).CreateProposal(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/CreateProposal", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CreateProposal(types.UnwrapSDKContext(ctx), req.(*MsgCreateProposalRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_Vote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgVoteRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).Vote(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/Vote", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Vote(types.UnwrapSDKContext(ctx), req.(*MsgVoteRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_VoteAgg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgVoteAggRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).VoteAgg(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/VoteAgg", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).VoteAgg(types.UnwrapSDKContext(ctx), req.(*MsgVoteAggRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_Exec_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgExecRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).Exec(types.UnwrapSDKContext(ctx), in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/Exec", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Exec(types.UnwrapSDKContext(ctx), req.(*MsgExecRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Msg_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "regen.group.v1alpha1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "CreateGroup", - Handler: _Msg_CreateGroup_Handler, - }, - { - MethodName: "UpdateGroupMembers", - Handler: _Msg_UpdateGroupMembers_Handler, - }, - { - MethodName: "UpdateGroupAdmin", - Handler: _Msg_UpdateGroupAdmin_Handler, - }, - { - MethodName: "UpdateGroupMetadata", - Handler: _Msg_UpdateGroupMetadata_Handler, - }, - { - MethodName: "CreateGroupAccount", - Handler: _Msg_CreateGroupAccount_Handler, - }, - { - MethodName: "UpdateGroupAccountAdmin", - Handler: _Msg_UpdateGroupAccountAdmin_Handler, - }, - { - MethodName: "UpdateGroupAccountDecisionPolicy", - Handler: _Msg_UpdateGroupAccountDecisionPolicy_Handler, - }, - { - MethodName: "UpdateGroupAccountMetadata", - Handler: _Msg_UpdateGroupAccountMetadata_Handler, - }, - { - MethodName: "CreateProposal", - Handler: _Msg_CreateProposal_Handler, - }, - { - MethodName: "Vote", - Handler: _Msg_Vote_Handler, - }, - { - MethodName: "VoteAgg", - Handler: _Msg_VoteAgg_Handler, - }, - { - MethodName: "Exec", - Handler: _Msg_Exec_Handler, - }, - }, - Metadata: "regen/group/v1alpha1/tx.proto", -} - -const ( - MsgCreateGroupMethod = "/regen.group.v1alpha1.Msg/CreateGroup" - MsgUpdateGroupMembersMethod = "/regen.group.v1alpha1.Msg/UpdateGroupMembers" - MsgUpdateGroupAdminMethod = "/regen.group.v1alpha1.Msg/UpdateGroupAdmin" - MsgUpdateGroupMetadataMethod = "/regen.group.v1alpha1.Msg/UpdateGroupMetadata" - MsgCreateGroupAccountMethod = "/regen.group.v1alpha1.Msg/CreateGroupAccount" - MsgUpdateGroupAccountAdminMethod = "/regen.group.v1alpha1.Msg/UpdateGroupAccountAdmin" - MsgUpdateGroupAccountDecisionPolicyMethod = "/regen.group.v1alpha1.Msg/UpdateGroupAccountDecisionPolicy" - MsgUpdateGroupAccountMetadataMethod = "/regen.group.v1alpha1.Msg/UpdateGroupAccountMetadata" - MsgCreateProposalMethod = "/regen.group.v1alpha1.Msg/CreateProposal" - MsgVoteMethod = "/regen.group.v1alpha1.Msg/Vote" - MsgVoteAggMethod = "/regen.group.v1alpha1.Msg/VoteAgg" - MsgExecMethod = "/regen.group.v1alpha1.Msg/Exec" -) From 8f16106a5bf933ffb9af0982d74ab860ca2a5842 Mon Sep 17 00:00:00 2001 From: kitty Date: Thu, 26 Aug 2021 16:48:14 +0100 Subject: [PATCH 25/34] make bls requirement for group members optional --- proto/regen/group/v1alpha1/tx.proto | 9 +- proto/regen/group/v1alpha1/types.proto | 3 + x/group/client/tx.go | 37 +-- x/group/codec.go | 4 +- x/group/msgs.go | 48 ++-- x/group/server/handler.go | 73 ------ x/group/server/msg_server.go | 38 +-- x/group/server/server_test.go | 9 + x/group/server/testsuite/suite.go | 16 +- x/group/tx.pb.go | 314 ++++++++++++++----------- x/group/types.pb.go | 201 +++++++++------- 11 files changed, 394 insertions(+), 358 deletions(-) delete mode 100644 x/group/server/handler.go diff --git a/proto/regen/group/v1alpha1/tx.proto b/proto/regen/group/v1alpha1/tx.proto index 35aa824236..32ff98f2f6 100644 --- a/proto/regen/group/v1alpha1/tx.proto +++ b/proto/regen/group/v1alpha1/tx.proto @@ -45,7 +45,7 @@ service Msg { rpc Vote(MsgVote) returns (MsgVoteResponse); // VoteAgg allows a sender to submit a set of votes - rpc VoteAgg(MsgVoteAggRequest) returns (MsgVoteAggResponse); + rpc VoteAgg(MsgVoteAgg) returns (MsgVoteAggResponse); // Exec executes a proposal. rpc Exec(MsgExec) returns (MsgExecResponse); @@ -66,6 +66,9 @@ message MsgCreateGroup { // metadata is any arbitrary metadata to attached to the group. bytes metadata = 3; + + // bls_only requires all the group members to use bls public keys so their votes can be aggregated together + bool bls_only = 4; } // MsgCreateGroupResponse is the Msg/CreateGroup response type. @@ -274,7 +277,7 @@ message MsgVoteResponse { } // MsgVoteBasicRequest is the Msg/Vote request type. -message MsgVoteBasicRequest { +message MsgVoteBasic { // proposal is the unique ID of the proposal. uint64 proposal_id = 1; @@ -309,7 +312,7 @@ message MsgVoteBasicResponse { } // MsgVoteRequest is the Msg/Vote request type. -message MsgVoteAggRequest { +message MsgVoteAgg { // sender is the person who submits the votes string sender = 1; diff --git a/proto/regen/group/v1alpha1/types.proto b/proto/regen/group/v1alpha1/types.proto index 914b54b076..67f9c6871a 100644 --- a/proto/regen/group/v1alpha1/types.proto +++ b/proto/regen/group/v1alpha1/types.proto @@ -87,6 +87,9 @@ message GroupInfo { // total_weight is the sum of the group members' weights. string total_weight = 5; + + // bls_only requires all the group members to use bls public keys so their votes can be aggregated together + bool bls_only = 6; } // GroupMember represents the relationship between a group and a member. diff --git a/x/group/client/tx.go b/x/group/client/tx.go index c5fbde3172..a36c42e706 100644 --- a/x/group/client/tx.go +++ b/x/group/client/tx.go @@ -4,15 +4,17 @@ import ( "bytes" "encoding/base64" "fmt" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/gogo/protobuf/types" - tmcli "github.com/tendermint/tendermint/libs/cli" "strconv" "strings" + "github.com/gogo/protobuf/types" + tmcli "github.com/tendermint/tendermint/libs/cli" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -27,8 +29,9 @@ import ( ) const ( - FlagExec = "exec" - ExecTry = "try" + FlagExec = "exec" + ExecTry = "try" + FlagBlsOnly = "bls" ) // TxCmd returns a root CLI command handler for all x/group transaction commands. @@ -119,10 +122,13 @@ Where members.json contains: return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "metadata is malformed, proper base64 string is required") } + bls, _ := cmd.Flags().GetBool(FlagBlsOnly) + msg := &group.MsgCreateGroup{ Admin: clientCtx.GetFromAddress().String(), Members: members, Metadata: b, + BlsOnly: bls, } if err = msg.ValidateBasic(); err != nil { return fmt.Errorf("message validation failed: %w", err) @@ -133,6 +139,7 @@ Where members.json contains: } flags.AddTxFlagsToCmd(cmd) + cmd.Flags().Bool(FlagBlsOnly, false, "Only accept members with bls public keys") return cmd } @@ -750,13 +757,13 @@ Parameters: return err } - msg := &group.MsgVoteAggRequest{ - Sender: args[0], + msg := &group.MsgVoteAgg{ + Sender: args[0], ProposalId: proposalID, - Votes: votes, - Timeout: timeout, - AggSig: sigma, - Metadata: nil, + Votes: votes, + Timeout: timeout, + AggSig: sigma, + Metadata: nil, } if err = msg.ValidateBasic(); err != nil { @@ -772,7 +779,6 @@ Parameters: return cmd } - // GetVoteBasicCmd creates a CLI command for Msg/VoteBasic. func GetVoteBasicCmd() *cobra.Command { cmd := &cobra.Command{ @@ -825,10 +831,10 @@ Parameters: return fmt.Errorf("deadline for submitting the vote has passed") } - msg := &group.MsgVoteBasicRequest{ + msg := &group.MsgVoteBasic{ ProposalId: proposalID, Choice: choice, - Timeout: timeout, + Timeout: timeout, } if err = msg.ValidateBasic(); err != nil { @@ -862,8 +868,6 @@ Parameters: return cmd } - - // GetVerifyVoteBasicCmd creates a CLI command for aggregating basic votes. func GetVerifyVoteBasicCmd() *cobra.Command { cmd := &cobra.Command{ @@ -917,6 +921,3 @@ Parameters: return cmd } - - - diff --git a/x/group/codec.go b/x/group/codec.go index 412609de12..8d6cc2fb3d 100644 --- a/x/group/codec.go +++ b/x/group/codec.go @@ -24,7 +24,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgCreateProposal{}, "cosmos-sdk/group/MsgCreateProposal", nil) cdc.RegisterConcrete(&MsgVote{}, "cosmos-sdk/group/MsgVote", nil) cdc.RegisterConcrete(&MsgExec{}, "cosmos-sdk/group/MsgExec", nil) - cdc.RegisterConcrete(&MsgVoteAggRequest{}, "cosmos-sdk/group/MsgVoteAgg", nil) + cdc.RegisterConcrete(&MsgVoteAgg{}, "cosmos-sdk/group/MsgVoteAgg", nil) cdc.RegisterConcrete(&MsgVoteBasicResponse{}, "cosmos-sdk/group/MsgVoteBasic", nil) } @@ -41,7 +41,7 @@ func RegisterTypes(registry cdctypes.InterfaceRegistry) { &MsgCreateProposal{}, &MsgVote{}, &MsgExec{}, - &MsgVoteAggRequest{}, + &MsgVoteAgg{}, &MsgVoteBasicResponse{}, ) diff --git a/x/group/msgs.go b/x/group/msgs.go index 682bd120f2..2bcbb43e5b 100644 --- a/x/group/msgs.go +++ b/x/group/msgs.go @@ -2,6 +2,7 @@ package group import ( "fmt" + "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -620,18 +621,18 @@ func (m MsgVote) ValidateBasic() error { return nil } - -var _ sdk.Msg = &MsgVoteBasicRequest{} +var _ sdk.Msg = &MsgVoteBasic{} +var _ legacytx.LegacyMsg = &MsgVoteBasic{} // Route Implements Msg. -func (m MsgVoteBasicRequest) Route() string { return RouterKey } +func (m MsgVoteBasic) Route() string { return sdk.MsgTypeURL(&m) } // Type Implements Msg. -func (m MsgVoteBasicRequest) Type() string { return TypeMsgVoteBasic } +func (m MsgVoteBasic) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg. -func (m MsgVoteBasicRequest) GetSignBytes() []byte { - req := MsgVoteBasicRequest{ +func (m MsgVoteBasic) GetSignBytes() []byte { + req := MsgVoteBasic{ ProposalId: m.ProposalId, Choice: m.Choice, Timeout: m.Timeout, @@ -640,12 +641,12 @@ func (m MsgVoteBasicRequest) GetSignBytes() []byte { } // GetSigners returns the expected signers for a MsgVoteRequest. -func (m MsgVoteBasicRequest) GetSigners() []sdk.AccAddress { +func (m MsgVoteBasic) GetSigners() []sdk.AccAddress { panic("this message does not include signers") } // ValidateBasic does a sanity check on the provided data -func (m MsgVoteBasicRequest) ValidateBasic() error { +func (m MsgVoteBasic) ValidateBasic() error { if m.ProposalId == 0 { return sdkerrors.Wrap(ErrEmpty, "proposal") } @@ -658,19 +659,19 @@ func (m MsgVoteBasicRequest) ValidateBasic() error { return nil } - var _ sdk.Msg = &MsgVoteBasicResponse{} +var _ legacytx.LegacyMsg = &MsgVoteBasicResponse{} var _ types.UnpackInterfacesMessage = MsgVoteBasicResponse{} // Route Implements Msg. -func (m MsgVoteBasicResponse) Route() string { return RouterKey } +func (m MsgVoteBasicResponse) Route() string { return sdk.MsgTypeURL(&m) } // Type Implements Msg. -func (m MsgVoteBasicResponse) Type() string { return TypeMsgVoteBasicOutput } +func (m MsgVoteBasicResponse) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg. func (m MsgVoteBasicResponse) GetSignBytes() []byte { - res := MsgVoteBasicRequest{ + res := MsgVoteBasic{ ProposalId: m.ProposalId, Choice: m.Choice, Timeout: m.Timeout, @@ -707,22 +708,22 @@ func (m MsgVoteBasicResponse) UnpackInterfaces(unpacker types.AnyUnpacker) error return unpacker.UnpackAny(m.PubKey, &pk) } - -var _ sdk.Msg = &MsgVoteAggRequest{} +var _ sdk.Msg = &MsgVoteAgg{} +var _ legacytx.LegacyMsg = &MsgVoteAgg{} // Route Implements Msg. -func (m MsgVoteAggRequest) Route() string { return RouterKey } +func (m MsgVoteAgg) Route() string { return sdk.MsgTypeURL(&m) } // Type Implements Msg. -func (m MsgVoteAggRequest) Type() string { return TypeMsgVoteAgg } +func (m MsgVoteAgg) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg. -func (m MsgVoteAggRequest) GetSignBytes() []byte { +func (m MsgVoteAgg) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgVoteRequest. -func (m MsgVoteAggRequest) GetSigners() []sdk.AccAddress { +func (m MsgVoteAgg) GetSigners() []sdk.AccAddress { addr, err := sdk.AccAddressFromBech32(m.Sender) if err != nil { panic(err) @@ -731,7 +732,7 @@ func (m MsgVoteAggRequest) GetSigners() []sdk.AccAddress { } // ValidateBasic does a sanity check on the provided data -func (m MsgVoteAggRequest) ValidateBasic() error { +func (m MsgVoteAgg) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(m.Sender) if err != nil { return sdkerrors.Wrap(err, "sender") @@ -747,9 +748,7 @@ func (m MsgVoteAggRequest) ValidateBasic() error { return nil } - - -func (m MsgVoteAggRequest) VerifyAggSig(pks []cryptotypes.PubKey) error { +func (m MsgVoteAgg) VerifyAggSig(pks []cryptotypes.PubKey) error { n := len(m.Votes) if n <= 0 { return fmt.Errorf("empty votes") @@ -772,9 +771,9 @@ func (m MsgVoteAggRequest) VerifyAggSig(pks []cryptotypes.PubKey) error { var pubkeys [][]*bls12381.PubKey // skip the unspecified choice - for i := 1; i 0 { i -= len(m.Metadata) copy(dAtA[i:], m.Metadata) @@ -2796,7 +2815,7 @@ func (m *MsgVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgVoteBasicRequest) Marshal() (dAtA []byte, err error) { +func (m *MsgVoteBasic) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2806,12 +2825,12 @@ func (m *MsgVoteBasicRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgVoteBasicRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgVoteBasic) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgVoteBasicRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgVoteBasic) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2908,7 +2927,7 @@ func (m *MsgVoteBasicResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgVoteAggRequest) Marshal() (dAtA []byte, err error) { +func (m *MsgVoteAgg) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2918,12 +2937,12 @@ func (m *MsgVoteAggRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgVoteAggRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgVoteAgg) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgVoteAggRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgVoteAgg) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -3097,6 +3116,9 @@ func (m *MsgCreateGroup) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if m.BlsOnly { + n += 2 + } return n } @@ -3407,7 +3429,7 @@ func (m *MsgVoteResponse) Size() (n int) { return n } -func (m *MsgVoteBasicRequest) Size() (n int) { +func (m *MsgVoteBasic) Size() (n int) { if m == nil { return 0 } @@ -3453,7 +3475,7 @@ func (m *MsgVoteBasicResponse) Size() (n int) { return n } -func (m *MsgVoteAggRequest) Size() (n int) { +func (m *MsgVoteAgg) Size() (n int) { if m == nil { return 0 } @@ -3655,6 +3677,26 @@ func (m *MsgCreateGroup) Unmarshal(dAtA []byte) error { m.Metadata = []byte{} } iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlsOnly", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.BlsOnly = bool(v != 0) default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -5638,7 +5680,7 @@ func (m *MsgVoteResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgVoteBasicRequest) Unmarshal(dAtA []byte) error { +func (m *MsgVoteBasic) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5661,10 +5703,10 @@ func (m *MsgVoteBasicRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgVoteBasicRequest: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVoteBasic: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgVoteBasicRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVoteBasic: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -5982,7 +6024,7 @@ func (m *MsgVoteBasicResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgVoteAggRequest) Unmarshal(dAtA []byte) error { +func (m *MsgVoteAgg) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -6005,10 +6047,10 @@ func (m *MsgVoteAggRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgVoteAggRequest: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVoteAgg: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgVoteAggRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVoteAgg: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/group/types.pb.go b/x/group/types.pb.go index d784454961..2131bb0aa9 100644 --- a/x/group/types.pb.go +++ b/x/group/types.pb.go @@ -357,6 +357,8 @@ type GroupInfo struct { Version uint64 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"` // total_weight is the sum of the group members' weights. TotalWeight string `protobuf:"bytes,5,opt,name=total_weight,json=totalWeight,proto3" json:"total_weight,omitempty"` + // bls_only requires all the group members to use bls public keys so their votes can be aggregated together + BlsOnly bool `protobuf:"varint,6,opt,name=bls_only,json=blsOnly,proto3" json:"bls_only,omitempty"` } func (m *GroupInfo) Reset() { *m = GroupInfo{} } @@ -427,6 +429,13 @@ func (m *GroupInfo) GetTotalWeight() string { return "" } +func (m *GroupInfo) GetBlsOnly() bool { + if m != nil { + return m.BlsOnly + } + return false +} + // GroupMember represents the relationship between a group and a member. type GroupMember struct { // group_id is the unique ID of the group. @@ -752,87 +761,88 @@ func init() { func init() { proto.RegisterFile("regen/group/v1alpha1/types.proto", fileDescriptor_9b7906b115009838) } var fileDescriptor_9b7906b115009838 = []byte{ - // 1271 bytes of a gzipped FileDescriptorProto + // 1293 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0xda, 0x8e, 0x1d, 0x3f, 0x3b, 0x8e, 0x35, 0xa4, 0xad, 0xe3, 0xa4, 0xce, 0xd6, 0xa5, + 0x14, 0xcf, 0xda, 0x8e, 0xff, 0x3c, 0x3b, 0x8e, 0x35, 0xa4, 0xad, 0xe3, 0xa4, 0xce, 0xd6, 0xa5, 0x52, 0x04, 0x8a, 0xad, 0x04, 0x38, 0x10, 0xd1, 0x0a, 0x7b, 0xb3, 0x29, 0x86, 0xd4, 0x0e, 0xbb, - 0x76, 0x80, 0x1e, 0xb0, 0xd6, 0xbb, 0x53, 0x67, 0xa9, 0xbd, 0x63, 0xed, 0x8e, 0x43, 0xcd, 0x07, - 0x40, 0xc5, 0x27, 0x2e, 0x08, 0x71, 0xb0, 0x54, 0x89, 0xaf, 0xc0, 0x87, 0xa8, 0x38, 0x55, 0x88, - 0x03, 0xe2, 0x80, 0x50, 0x7b, 0xe1, 0xc2, 0x77, 0x40, 0x3b, 0x33, 0x9b, 0x64, 0x1b, 0xc7, 0xed, - 0x81, 0x93, 0xf7, 0xbd, 0xf9, 0xfd, 0xde, 0x9f, 0xdf, 0x3c, 0xcf, 0x0c, 0xc8, 0x2e, 0xee, 0x61, - 0xa7, 0xd2, 0x73, 0xc9, 0x68, 0x58, 0x39, 0xd9, 0x36, 0xfa, 0xc3, 0x63, 0x63, 0xbb, 0x42, 0xc7, - 0x43, 0xec, 0x95, 0x87, 0x2e, 0xa1, 0x04, 0xad, 0x30, 0x44, 0x99, 0x21, 0xca, 0x01, 0xa2, 0xb0, - 0xd2, 0x23, 0x3d, 0xc2, 0x00, 0x15, 0xff, 0x8b, 0x63, 0x0b, 0xc5, 0x1e, 0x21, 0xbd, 0x3e, 0xae, - 0x30, 0xab, 0x3b, 0x7a, 0x50, 0xb1, 0x46, 0xae, 0x41, 0x6d, 0xe2, 0x88, 0xf5, 0x8d, 0x97, 0xd7, - 0xa9, 0x3d, 0xc0, 0x1e, 0x35, 0x06, 0x43, 0x01, 0xc8, 0x98, 0xc4, 0x1b, 0x10, 0x91, 0xba, 0xb0, - 0xfa, 0x32, 0xdc, 0x70, 0xc6, 0x7c, 0xa9, 0x74, 0x04, 0x89, 0x7b, 0x78, 0xd0, 0xc5, 0x2e, 0xca, - 0x43, 0xd2, 0xb0, 0x2c, 0x17, 0x7b, 0x5e, 0x5e, 0x92, 0xa5, 0xcd, 0x94, 0x16, 0x98, 0xe8, 0x2a, - 0x24, 0xbe, 0xc6, 0x76, 0xef, 0x98, 0xe6, 0xa3, 0x6c, 0x41, 0x58, 0xa8, 0x00, 0x8b, 0x03, 0x4c, - 0x0d, 0xcb, 0xa0, 0x46, 0x3e, 0x26, 0x4b, 0x9b, 0x19, 0xed, 0xd4, 0x2e, 0xdd, 0x85, 0x24, 0x8f, - 0xeb, 0xa1, 0x0f, 0x20, 0x39, 0xe0, 0x9f, 0x79, 0x49, 0x8e, 0x6d, 0xa6, 0x77, 0xd6, 0xcb, 0xb3, - 0xa4, 0x28, 0x73, 0x7c, 0x2d, 0xfe, 0xf4, 0xaf, 0x8d, 0x88, 0x16, 0x50, 0x4a, 0xdf, 0x4a, 0x70, - 0xad, 0x75, 0xec, 0x62, 0xef, 0x98, 0xf4, 0xad, 0x3d, 0x6c, 0xda, 0x9e, 0x4d, 0x9c, 0x43, 0xd2, - 0xb7, 0xcd, 0x31, 0x5a, 0x87, 0x14, 0x0d, 0x96, 0x44, 0xd1, 0x67, 0x0e, 0xf4, 0x3e, 0x24, 0x7d, - 0x59, 0xc8, 0x88, 0xd7, 0x9d, 0xde, 0x59, 0x2d, 0x73, 0x1d, 0xca, 0x81, 0x0e, 0xe5, 0x3d, 0x21, - 0x6b, 0x90, 0x54, 0xe0, 0x77, 0xd1, 0x6f, 0xbf, 0x6c, 0x65, 0xc3, 0xc9, 0x4a, 0x3f, 0x48, 0x90, - 0xba, 0xeb, 0x57, 0x5c, 0x77, 0x1e, 0x10, 0xb4, 0x0a, 0x8b, 0xac, 0xfc, 0x8e, 0xcd, 0x33, 0xc7, - 0xb5, 0x24, 0xb3, 0xeb, 0x16, 0x5a, 0x81, 0x05, 0xc3, 0x1a, 0xd8, 0x8e, 0x50, 0x8b, 0x1b, 0xf3, - 0xc4, 0xf2, 0xa5, 0x3f, 0xc1, 0xae, 0x9f, 0x2b, 0x1f, 0xe7, 0xb1, 0x84, 0x89, 0x6e, 0x40, 0x86, - 0x12, 0x6a, 0xf4, 0x3b, 0x62, 0x03, 0x16, 0x58, 0xc8, 0x34, 0xf3, 0x7d, 0xc6, 0x5c, 0xa5, 0x2f, - 0x21, 0xcd, 0xca, 0x12, 0xdb, 0x38, 0xa7, 0xb0, 0x77, 0x21, 0xc1, 0x55, 0x15, 0x7a, 0xcc, 0xdd, - 0x07, 0x4d, 0x60, 0x4b, 0x3f, 0x46, 0x21, 0xc7, 0x12, 0x54, 0x4d, 0x93, 0x8c, 0x1c, 0xca, 0xda, - 0xbf, 0x7c, 0x58, 0xce, 0xe7, 0x8f, 0x5e, 0x22, 0x4c, 0xec, 0x32, 0x61, 0xe2, 0x97, 0x0b, 0xb3, - 0x10, 0x16, 0xe6, 0x53, 0x58, 0xb6, 0xc4, 0xfe, 0x74, 0x86, 0x6c, 0x83, 0xf2, 0x09, 0xd6, 0xd4, - 0xca, 0x85, 0x4d, 0xae, 0x3a, 0xe3, 0x1a, 0xfa, 0xf5, 0xc2, 0x86, 0x6a, 0x59, 0x2b, 0x3c, 0x4d, - 0xb7, 0x20, 0x6b, 0x61, 0xd7, 0x3e, 0x61, 0x13, 0xd1, 0x79, 0x88, 0xc7, 0xf9, 0x24, 0x2b, 0x67, - 0xe9, 0xcc, 0xfb, 0x09, 0x1e, 0xef, 0x2e, 0x3e, 0x7e, 0xb2, 0x11, 0xf9, 0xe7, 0xc9, 0x86, 0x54, - 0xfa, 0x17, 0x60, 0xf1, 0xd0, 0x25, 0x43, 0xe2, 0x19, 0x7d, 0xb4, 0x01, 0xe9, 0xa1, 0xf8, 0x3e, - 0x93, 0x1e, 0x02, 0x57, 0xdd, 0x3a, 0x2f, 0x59, 0x34, 0x2c, 0xd9, 0xbc, 0xd1, 0x58, 0x87, 0x14, - 0x8f, 0xe1, 0xff, 0x7d, 0xe2, 0x72, 0xcc, 0x1f, 0xf1, 0x53, 0x07, 0x52, 0x20, 0xe3, 0x8d, 0xba, - 0x03, 0x9b, 0x52, 0x6c, 0x75, 0x0c, 0x3e, 0x1e, 0xe9, 0x9d, 0xc2, 0x05, 0x09, 0x5a, 0xc1, 0xf1, - 0x20, 0x06, 0x3d, 0x7d, 0xca, 0xaa, 0x52, 0x74, 0x13, 0x96, 0xf8, 0x8e, 0x05, 0x52, 0x27, 0x58, - 0xed, 0x19, 0xe6, 0x3c, 0x12, 0x7a, 0xef, 0xc0, 0x15, 0x0e, 0x32, 0xf8, 0x14, 0x9c, 0x82, 0x93, - 0x0c, 0xfc, 0x46, 0xef, 0xdc, 0x84, 0x04, 0x9c, 0xdb, 0x90, 0xf0, 0xa8, 0x41, 0x47, 0x5e, 0x7e, - 0x51, 0x96, 0x36, 0xb3, 0x3b, 0xb7, 0x66, 0xcf, 0x5b, 0x20, 0x61, 0x59, 0x67, 0x60, 0x4d, 0x90, - 0x7c, 0xba, 0x8b, 0xbd, 0x51, 0x9f, 0xe6, 0x53, 0xaf, 0x45, 0xd7, 0x18, 0x58, 0x13, 0x24, 0xf4, - 0x21, 0xc0, 0x09, 0xa1, 0xb8, 0xe3, 0x47, 0xc3, 0x79, 0x60, 0xca, 0xac, 0xcd, 0x0e, 0xd1, 0x32, - 0xfa, 0xfd, 0xb1, 0x90, 0x26, 0xe5, 0x93, 0xfc, 0x4a, 0x30, 0xda, 0x3d, 0x3b, 0x40, 0xd2, 0xaf, - 0x29, 0x6c, 0x40, 0x40, 0x47, 0xb0, 0x8c, 0x1f, 0x61, 0x73, 0x44, 0x89, 0xdb, 0x11, 0x5d, 0x64, - 0x58, 0x17, 0x5b, 0xaf, 0xe8, 0x42, 0x15, 0x2c, 0xd1, 0x4d, 0x16, 0x87, 0x6c, 0xb4, 0x09, 0xf1, - 0x81, 0xd7, 0xf3, 0xf2, 0x4b, 0xec, 0x24, 0x9d, 0x39, 0xec, 0x1a, 0x43, 0x94, 0x9e, 0x49, 0x90, - 0xe0, 0x8a, 0xa2, 0x6d, 0x40, 0x7a, 0xab, 0xda, 0x6a, 0xeb, 0x9d, 0x76, 0x43, 0x3f, 0x54, 0x95, - 0xfa, 0x7e, 0x5d, 0xdd, 0xcb, 0x45, 0x0a, 0xab, 0x93, 0xa9, 0x7c, 0x25, 0xc8, 0xcc, 0xb1, 0x75, - 0xe7, 0xc4, 0xe8, 0xdb, 0x16, 0xda, 0x86, 0x9c, 0xa0, 0xe8, 0xed, 0xda, 0xbd, 0x7a, 0xab, 0xa5, - 0xee, 0xe5, 0xa4, 0xc2, 0xda, 0x64, 0x2a, 0x5f, 0x0b, 0x13, 0xf4, 0x60, 0x92, 0xd0, 0xdb, 0xb0, - 0x24, 0x28, 0xca, 0x41, 0x53, 0x57, 0xf7, 0x72, 0xd1, 0x42, 0x7e, 0x32, 0x95, 0x57, 0xc2, 0x78, - 0xa5, 0x4f, 0x3c, 0x6c, 0xa1, 0x2d, 0xc8, 0x0a, 0x70, 0xb5, 0xd6, 0xd4, 0xfc, 0xe8, 0xb1, 0x59, - 0xe5, 0x54, 0xbb, 0xc4, 0xa5, 0xd8, 0x2a, 0xc4, 0x1f, 0xff, 0x5c, 0x8c, 0x94, 0xfe, 0x94, 0x20, - 0x21, 0x74, 0xd8, 0x06, 0xa4, 0xa9, 0x7a, 0xfb, 0xa0, 0x35, 0xaf, 0x25, 0x8e, 0x0d, 0x5a, 0x7a, - 0xef, 0x1c, 0x65, 0xbf, 0xde, 0xa8, 0x1e, 0xd4, 0xef, 0xb3, 0xa6, 0xae, 0x4f, 0xa6, 0xf2, 0x6a, - 0x98, 0xd2, 0x76, 0x1e, 0xd8, 0x8e, 0xd1, 0xb7, 0xbf, 0xc1, 0x16, 0xaa, 0xc0, 0xb2, 0xa0, 0x55, - 0x15, 0x45, 0x3d, 0x6c, 0xb1, 0xc6, 0x0a, 0x93, 0xa9, 0x7c, 0x35, 0xcc, 0xa9, 0x9a, 0x26, 0x1e, - 0xd2, 0x10, 0x41, 0x53, 0x3f, 0x56, 0x15, 0xde, 0xdb, 0x0c, 0x82, 0x86, 0xbf, 0xc2, 0xe6, 0x59, - 0x73, 0x3f, 0x45, 0x21, 0x1b, 0xde, 0x7c, 0x54, 0x83, 0x35, 0xf5, 0x73, 0x55, 0x69, 0xb7, 0x9a, - 0x5a, 0x67, 0x66, 0xb7, 0x37, 0x26, 0x53, 0xf9, 0x7a, 0x10, 0x35, 0x4c, 0x0e, 0xba, 0xbe, 0x0d, - 0xd7, 0x5e, 0x8e, 0xd1, 0x68, 0xb6, 0x3a, 0x5a, 0xbb, 0x91, 0x93, 0x0a, 0xf2, 0x64, 0x2a, 0xaf, - 0xcf, 0xe6, 0x37, 0x08, 0xd5, 0x46, 0x0e, 0xba, 0x73, 0x91, 0xae, 0xb7, 0x15, 0x45, 0xd5, 0xf5, - 0x5c, 0x74, 0x5e, 0x7a, 0x7d, 0x64, 0x9a, 0xfe, 0xd9, 0x36, 0x83, 0xbf, 0x5f, 0xad, 0x1f, 0xb4, - 0x35, 0x35, 0x17, 0x9b, 0xc7, 0xdf, 0x37, 0xec, 0xfe, 0xc8, 0xc5, 0x5c, 0x9b, 0xdd, 0xb8, 0x7f, - 0xe6, 0x96, 0xbe, 0x93, 0x60, 0x81, 0xfd, 0x55, 0xd1, 0x1a, 0xa4, 0xc6, 0xd8, 0xeb, 0xb0, 0xd3, - 0x46, 0x5c, 0x40, 0x8b, 0x63, 0xec, 0x29, 0xbe, 0xed, 0xdf, 0x40, 0x0e, 0x11, 0x6b, 0xe2, 0xa4, - 0x75, 0x08, 0x5f, 0xba, 0x09, 0x4b, 0x46, 0xd7, 0xa3, 0x86, 0xed, 0x88, 0x75, 0x7e, 0x13, 0x65, - 0x84, 0x93, 0x83, 0xae, 0x03, 0x9c, 0x60, 0x1a, 0x44, 0x88, 0xf3, 0x67, 0x85, 0xef, 0x61, 0xcb, - 0xa2, 0x96, 0xdf, 0x25, 0x88, 0x1f, 0x11, 0x8a, 0x5f, 0x7d, 0xee, 0xaf, 0xc0, 0x82, 0x7f, 0xa4, - 0xb8, 0xc1, 0x73, 0x80, 0x19, 0xfe, 0x5d, 0x6c, 0x1e, 0x13, 0xdb, 0xc4, 0xac, 0x84, 0xec, 0x65, - 0x77, 0xb1, 0xc2, 0x30, 0x9a, 0xc0, 0xce, 0xbd, 0x2b, 0xff, 0x8f, 0xbb, 0xe0, 0x2d, 0x0b, 0x12, - 0x3c, 0x25, 0xba, 0x0a, 0x48, 0xf9, 0xa8, 0x59, 0x57, 0xd4, 0xf0, 0xc8, 0xa1, 0x25, 0x48, 0x09, - 0x7f, 0xa3, 0x99, 0x93, 0x50, 0x16, 0x40, 0x98, 0x5f, 0xa8, 0x7a, 0x2e, 0x8a, 0x10, 0x64, 0x85, - 0x5d, 0xad, 0xe9, 0xad, 0x6a, 0xbd, 0x91, 0x8b, 0xa1, 0x65, 0x48, 0x0b, 0xdf, 0x91, 0xda, 0x6a, - 0xe6, 0xe2, 0xb5, 0x3b, 0x4f, 0x9f, 0x17, 0xa5, 0x67, 0xcf, 0x8b, 0xd2, 0xdf, 0xcf, 0x8b, 0xd2, - 0xf7, 0x2f, 0x8a, 0x91, 0x67, 0x2f, 0x8a, 0x91, 0x3f, 0x5e, 0x14, 0x23, 0xf7, 0xdf, 0xec, 0xd9, - 0xf4, 0x78, 0xd4, 0x2d, 0x9b, 0x64, 0x50, 0xe1, 0x4f, 0x58, 0xf1, 0xb3, 0xe5, 0x59, 0x0f, 0x2b, - 0x8f, 0xf8, 0xfb, 0xba, 0x9b, 0x60, 0xcd, 0xbc, 0xf3, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa8, - 0xbc, 0x7c, 0xa3, 0x75, 0x0b, 0x00, 0x00, + 0x76, 0x80, 0x1e, 0xb0, 0xd6, 0xbb, 0x53, 0x67, 0xe9, 0x7a, 0xc7, 0xda, 0x1d, 0x87, 0x9a, 0x0f, + 0x80, 0x8a, 0x4f, 0xdc, 0x10, 0x07, 0x4b, 0x95, 0xf8, 0x02, 0x1c, 0xf8, 0x10, 0x15, 0xa7, 0x0a, + 0x71, 0x40, 0x1c, 0x10, 0x6a, 0x2f, 0x5c, 0xf8, 0x0e, 0x68, 0x67, 0x66, 0x93, 0xb8, 0x71, 0xdc, + 0x1e, 0x38, 0xd9, 0x6f, 0xe6, 0xf7, 0x7b, 0x7f, 0x7e, 0xef, 0xed, 0xcc, 0x80, 0xec, 0xe1, 0x1e, + 0x76, 0x2b, 0x3d, 0x8f, 0x0c, 0x07, 0x95, 0x93, 0x6d, 0xc3, 0x19, 0x1c, 0x1b, 0xdb, 0x15, 0x3a, + 0x1a, 0x60, 0xbf, 0x3c, 0xf0, 0x08, 0x25, 0x68, 0x85, 0x21, 0xca, 0x0c, 0x51, 0x0e, 0x11, 0x85, + 0x95, 0x1e, 0xe9, 0x11, 0x06, 0xa8, 0x04, 0xff, 0x38, 0xb6, 0x50, 0xec, 0x11, 0xd2, 0x73, 0x70, + 0x85, 0x59, 0xdd, 0xe1, 0x83, 0x8a, 0x35, 0xf4, 0x0c, 0x6a, 0x13, 0x57, 0xec, 0x6f, 0xbc, 0xbc, + 0x4f, 0xed, 0x3e, 0xf6, 0xa9, 0xd1, 0x1f, 0x08, 0x40, 0xc6, 0x24, 0x7e, 0x9f, 0x88, 0xd0, 0x85, + 0xd5, 0x97, 0xe1, 0x86, 0x3b, 0xe2, 0x5b, 0xa5, 0x23, 0x88, 0xdf, 0xc3, 0xfd, 0x2e, 0xf6, 0x50, + 0x1e, 0x12, 0x86, 0x65, 0x79, 0xd8, 0xf7, 0xf3, 0x92, 0x2c, 0x6d, 0xa6, 0xb4, 0xd0, 0x44, 0x57, + 0x21, 0xfe, 0x35, 0xb6, 0x7b, 0xc7, 0x34, 0x1f, 0x61, 0x1b, 0xc2, 0x42, 0x05, 0x48, 0xf6, 0x31, + 0x35, 0x2c, 0x83, 0x1a, 0xf9, 0xa8, 0x2c, 0x6d, 0x66, 0xb4, 0x53, 0xbb, 0x74, 0x17, 0x12, 0xdc, + 0xaf, 0x8f, 0x3e, 0x80, 0x44, 0x9f, 0xff, 0xcd, 0x4b, 0x72, 0x74, 0x33, 0xbd, 0xb3, 0x5e, 0x9e, + 0x25, 0x45, 0x99, 0xe3, 0x6b, 0xb1, 0xa7, 0x7f, 0x6d, 0x2c, 0x68, 0x21, 0xa5, 0xf4, 0xad, 0x04, + 0xd7, 0x5a, 0xc7, 0x1e, 0xf6, 0x8f, 0x89, 0x63, 0xed, 0x61, 0xd3, 0xf6, 0x6d, 0xe2, 0x1e, 0x12, + 0xc7, 0x36, 0x47, 0x68, 0x1d, 0x52, 0x34, 0xdc, 0x12, 0x49, 0x9f, 0x2d, 0xa0, 0xf7, 0x21, 0x11, + 0xc8, 0x42, 0x86, 0x3c, 0xef, 0xf4, 0xce, 0x6a, 0x99, 0xeb, 0x50, 0x0e, 0x75, 0x28, 0xef, 0x09, + 0x59, 0xc3, 0xa0, 0x02, 0xbf, 0x8b, 0x7e, 0xfb, 0x65, 0x2b, 0x3b, 0x1d, 0xac, 0xf4, 0xb3, 0x04, + 0xa9, 0xbb, 0x41, 0xc6, 0x75, 0xf7, 0x01, 0x41, 0xab, 0x90, 0x64, 0xe9, 0x77, 0x6c, 0x1e, 0x39, + 0xa6, 0x25, 0x98, 0x5d, 0xb7, 0xd0, 0x0a, 0x2c, 0x1a, 0x56, 0xdf, 0x76, 0x85, 0x5a, 0xdc, 0x98, + 0x27, 0x56, 0x20, 0xfd, 0x09, 0xf6, 0x82, 0x58, 0xf9, 0x18, 0xf7, 0x25, 0x4c, 0x74, 0x03, 0x32, + 0x94, 0x50, 0xc3, 0xe9, 0x88, 0x06, 0x2c, 0x32, 0x97, 0x69, 0xb6, 0xf6, 0x19, 0xef, 0xc2, 0x2a, + 0x24, 0xbb, 0x8e, 0xdf, 0x21, 0xae, 0x33, 0xca, 0xc7, 0x65, 0x69, 0x33, 0xa9, 0x25, 0xba, 0x8e, + 0xdf, 0x74, 0x9d, 0x51, 0xe9, 0x4b, 0x48, 0xb3, 0x8c, 0x45, 0x87, 0xe7, 0xe4, 0xfc, 0x2e, 0xc4, + 0xb9, 0xe0, 0x42, 0xaa, 0xb9, 0x2d, 0xd2, 0x04, 0xb6, 0xf4, 0x43, 0x04, 0x72, 0x2c, 0x40, 0xd5, + 0x34, 0xc9, 0xd0, 0xa5, 0x4c, 0x99, 0xcb, 0xe7, 0xe8, 0x7c, 0xfc, 0xc8, 0x25, 0x9a, 0x45, 0x2f, + 0xd3, 0x2c, 0x76, 0xb9, 0x66, 0x8b, 0xd3, 0x9a, 0x7d, 0x0a, 0xcb, 0x96, 0x68, 0x5d, 0x67, 0xc0, + 0x7a, 0xc7, 0x74, 0x49, 0xef, 0xac, 0x5c, 0xe8, 0x7f, 0xd5, 0x1d, 0xd5, 0xd0, 0xaf, 0x17, 0x7a, + 0xad, 0x65, 0xad, 0xe9, 0x41, 0xbb, 0x05, 0x59, 0x0b, 0x7b, 0xf6, 0x09, 0x1b, 0x96, 0xce, 0x43, + 0x3c, 0xca, 0x27, 0x58, 0x3a, 0x4b, 0x67, 0xab, 0x9f, 0xe0, 0xd1, 0x6e, 0xf2, 0xf1, 0x93, 0x8d, + 0x85, 0x7f, 0x9e, 0x6c, 0x48, 0xa5, 0x7f, 0x01, 0x92, 0x87, 0x1e, 0x19, 0x10, 0xdf, 0x70, 0xd0, + 0x06, 0xa4, 0x07, 0xe2, 0xff, 0x99, 0xf4, 0x10, 0x2e, 0xd5, 0xad, 0xf3, 0x92, 0x45, 0xa6, 0x25, + 0x9b, 0x37, 0x35, 0xeb, 0x90, 0xe2, 0x3e, 0x82, 0x2f, 0x2b, 0x26, 0x47, 0x83, 0xe9, 0x3f, 0x5d, + 0x40, 0x0a, 0x64, 0xfc, 0x61, 0xb7, 0x6f, 0x53, 0x8a, 0xad, 0x8e, 0xc1, 0x27, 0x27, 0xbd, 0x53, + 0xb8, 0x20, 0x41, 0x2b, 0x3c, 0x39, 0xc4, 0x37, 0x90, 0x3e, 0x65, 0x55, 0x29, 0xba, 0x09, 0x4b, + 0xbc, 0x63, 0xa1, 0xd4, 0x71, 0x96, 0x7b, 0x86, 0x2d, 0x1e, 0x09, 0xbd, 0x77, 0xe0, 0x0a, 0x07, + 0x19, 0x7c, 0x0a, 0x4e, 0xc1, 0x09, 0x06, 0x7e, 0xa3, 0x77, 0x6e, 0x42, 0x42, 0xce, 0x6d, 0x88, + 0xfb, 0xd4, 0xa0, 0x43, 0x3f, 0x9f, 0x94, 0xa5, 0xcd, 0xec, 0xce, 0xad, 0xd9, 0xf3, 0x16, 0x4a, + 0x58, 0xd6, 0x19, 0x58, 0x13, 0xa4, 0x80, 0xee, 0x61, 0x7f, 0xe8, 0xd0, 0x7c, 0xea, 0xb5, 0xe8, + 0x1a, 0x03, 0x6b, 0x82, 0x84, 0x3e, 0x04, 0x38, 0x21, 0x14, 0x77, 0x02, 0x6f, 0x38, 0x0f, 0x4c, + 0x99, 0xb5, 0xd9, 0x2e, 0x5a, 0x86, 0xe3, 0x8c, 0x84, 0x34, 0xa9, 0x80, 0x14, 0x64, 0x82, 0xd1, + 0xee, 0xd9, 0xd9, 0x92, 0x7e, 0x4d, 0x61, 0x43, 0x02, 0x3a, 0x82, 0x65, 0xfc, 0x08, 0x9b, 0x43, + 0x4a, 0xbc, 0x8e, 0xa8, 0x22, 0xc3, 0xaa, 0xd8, 0x7a, 0x45, 0x15, 0xaa, 0x60, 0x89, 0x6a, 0xb2, + 0x78, 0xca, 0x46, 0x9b, 0x10, 0xeb, 0xfb, 0x3d, 0x3f, 0xbf, 0xc4, 0x0e, 0xd9, 0x99, 0xc3, 0xae, + 0x31, 0x44, 0xe9, 0x99, 0x04, 0x71, 0xae, 0x28, 0xda, 0x06, 0xa4, 0xb7, 0xaa, 0xad, 0xb6, 0xde, + 0x69, 0x37, 0xf4, 0x43, 0x55, 0xa9, 0xef, 0xd7, 0xd5, 0xbd, 0xdc, 0x42, 0x61, 0x75, 0x3c, 0x91, + 0xaf, 0x84, 0x91, 0x39, 0xb6, 0xee, 0x9e, 0x18, 0x8e, 0x6d, 0xa1, 0x6d, 0xc8, 0x09, 0x8a, 0xde, + 0xae, 0xdd, 0xab, 0xb7, 0x5a, 0xea, 0x5e, 0x4e, 0x2a, 0xac, 0x8d, 0x27, 0xf2, 0xb5, 0x69, 0x82, + 0x1e, 0x4e, 0x12, 0x7a, 0x1b, 0x96, 0x04, 0x45, 0x39, 0x68, 0xea, 0xea, 0x5e, 0x2e, 0x52, 0xc8, + 0x8f, 0x27, 0xf2, 0xca, 0x34, 0x5e, 0x71, 0x88, 0x8f, 0x2d, 0xb4, 0x05, 0x59, 0x01, 0xae, 0xd6, + 0x9a, 0x5a, 0xe0, 0x3d, 0x3a, 0x2b, 0x9d, 0x6a, 0x97, 0x78, 0x14, 0x5b, 0x85, 0xd8, 0xe3, 0x9f, + 0x8a, 0x0b, 0xa5, 0x3f, 0x25, 0x88, 0x0b, 0x1d, 0xb6, 0x01, 0x69, 0xaa, 0xde, 0x3e, 0x68, 0xcd, + 0x2b, 0x89, 0x63, 0xc3, 0x92, 0xde, 0x3b, 0x47, 0xd9, 0xaf, 0x37, 0xaa, 0x07, 0xf5, 0xfb, 0xac, + 0xa8, 0xeb, 0xe3, 0x89, 0xbc, 0x3a, 0x4d, 0x69, 0xbb, 0x0f, 0x6c, 0xd7, 0x70, 0xec, 0x6f, 0xb0, + 0x85, 0x2a, 0xb0, 0x2c, 0x68, 0x55, 0x45, 0x51, 0x0f, 0x5b, 0xac, 0xb0, 0xc2, 0x78, 0x22, 0x5f, + 0x9d, 0xe6, 0x54, 0x4d, 0x13, 0x0f, 0xe8, 0x14, 0x41, 0x53, 0x3f, 0x56, 0x15, 0x5e, 0xdb, 0x0c, + 0x82, 0x86, 0xbf, 0xc2, 0xe6, 0x59, 0x71, 0x3f, 0x46, 0x20, 0x3b, 0xdd, 0x7c, 0x54, 0x83, 0x35, + 0xf5, 0x73, 0x55, 0x69, 0xb7, 0x9a, 0x5a, 0x67, 0x66, 0xb5, 0x37, 0xc6, 0x13, 0xf9, 0x7a, 0xe8, + 0x75, 0x9a, 0x1c, 0x56, 0x7d, 0x1b, 0xae, 0xbd, 0xec, 0xa3, 0xd1, 0x6c, 0x75, 0xb4, 0x76, 0x23, + 0x27, 0x15, 0xe4, 0xf1, 0x44, 0x5e, 0x9f, 0xcd, 0x6f, 0x10, 0xaa, 0x0d, 0x5d, 0x74, 0xe7, 0x22, + 0x5d, 0x6f, 0x2b, 0x8a, 0xaa, 0xeb, 0xb9, 0xc8, 0xbc, 0xf0, 0xfa, 0xd0, 0x34, 0x83, 0xb3, 0x6d, + 0x06, 0x7f, 0xbf, 0x5a, 0x3f, 0x68, 0x6b, 0x6a, 0x2e, 0x3a, 0x8f, 0xbf, 0x6f, 0xd8, 0xce, 0xd0, + 0xc3, 0x5c, 0x9b, 0xdd, 0x58, 0x70, 0xe6, 0x96, 0xbe, 0x93, 0x60, 0x91, 0x7d, 0xaa, 0x68, 0x0d, + 0x52, 0x23, 0xec, 0x77, 0xd8, 0x69, 0x23, 0x2e, 0xa0, 0xe4, 0x08, 0xfb, 0x4a, 0x60, 0x07, 0x37, + 0x90, 0x4b, 0xc4, 0x9e, 0x38, 0x69, 0x5d, 0xc2, 0xb7, 0x6e, 0xc2, 0x92, 0xd1, 0xf5, 0xa9, 0x61, + 0xbb, 0x62, 0x9f, 0xdf, 0x44, 0x19, 0xb1, 0xc8, 0x41, 0xd7, 0x01, 0x4e, 0x30, 0x0d, 0x3d, 0xc4, + 0xf8, 0x8b, 0x23, 0x58, 0x61, 0xdb, 0x22, 0x97, 0xdf, 0x25, 0x88, 0x1d, 0x11, 0x8a, 0x5f, 0x7d, + 0xee, 0xaf, 0xc0, 0x62, 0x70, 0xa4, 0x78, 0xe1, 0x4b, 0x81, 0x19, 0xc1, 0x5d, 0x6c, 0x1e, 0x13, + 0xdb, 0xc4, 0x2c, 0x85, 0xec, 0x65, 0x77, 0xb1, 0xc2, 0x30, 0x9a, 0xc0, 0xce, 0xbd, 0x2b, 0xff, + 0x8f, 0xbb, 0xe0, 0x2d, 0x0b, 0xe2, 0x3c, 0x24, 0xba, 0x0a, 0x48, 0xf9, 0xa8, 0x59, 0x57, 0xd4, + 0xe9, 0x91, 0x43, 0x4b, 0x90, 0x12, 0xeb, 0x8d, 0x66, 0x4e, 0x42, 0x59, 0x00, 0x61, 0x7e, 0xa1, + 0xea, 0xb9, 0x08, 0x42, 0x90, 0x15, 0x76, 0xb5, 0xa6, 0xb7, 0xaa, 0xf5, 0x46, 0x2e, 0x8a, 0x96, + 0x21, 0x2d, 0xd6, 0x8e, 0xd4, 0x56, 0x33, 0x17, 0xab, 0xdd, 0x79, 0xfa, 0xbc, 0x28, 0x3d, 0x7b, + 0x5e, 0x94, 0xfe, 0x7e, 0x5e, 0x94, 0xbe, 0x7f, 0x51, 0x5c, 0x78, 0xf6, 0xa2, 0xb8, 0xf0, 0xc7, + 0x8b, 0xe2, 0xc2, 0xfd, 0x37, 0x7b, 0x36, 0x3d, 0x1e, 0x76, 0xcb, 0x26, 0xe9, 0x57, 0xf8, 0xeb, + 0x56, 0xfc, 0x6c, 0xf9, 0xd6, 0xc3, 0xca, 0x23, 0xfe, 0xf4, 0xee, 0xc6, 0x59, 0x31, 0xef, 0xfc, + 0x17, 0x00, 0x00, 0xff, 0xff, 0xf5, 0x84, 0x4c, 0x18, 0x90, 0x0b, 0x00, 0x00, } func (this *GroupAccountInfo) Equal(that interface{}) bool { @@ -1018,6 +1028,16 @@ func (m *GroupInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.BlsOnly { + i-- + if m.BlsOnly { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } if len(m.TotalWeight) > 0 { i -= len(m.TotalWeight) copy(dAtA[i:], m.TotalWeight) @@ -1479,6 +1499,9 @@ func (m *GroupInfo) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } + if m.BlsOnly { + n += 2 + } return n } @@ -2154,6 +2177,26 @@ func (m *GroupInfo) Unmarshal(dAtA []byte) error { } m.TotalWeight = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlsOnly", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.BlsOnly = bool(v != 0) default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) From 1f1a2aa1d55dcc8f3389ad0e3dda4240512287cc Mon Sep 17 00:00:00 2001 From: kitty Date: Thu, 2 Sep 2021 12:40:32 +0100 Subject: [PATCH 26/34] add tests for bls related group operations --- go.mod | 3 +- go.sum | 5 - proto/regen/group/v1alpha1/tx.proto | 4 + regen/orm/testdata/codec.proto | 2 +- regen/types/module/server/testutil.go | 49 +- regen/types/testutil/fixture.go | 6 + testutil/testdata/tx.go | 12 +- x/group/server/msg_server.go | 19 +- x/group/server/testsuite/suite.go | 626 +++++++++++++++++++++++++- x/group/tx.pb.go | 183 +++++--- x/group/types_test.go | 4 +- 11 files changed, 801 insertions(+), 112 deletions(-) diff --git a/go.mod b/go.mod index 0a8f332ee6..9033a2fc01 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/iavl v0.16.0 github.com/cosmos/ledger-cosmos-go v0.11.1 + github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25 github.com/gogo/gateway v1.1.0 github.com/gogo/protobuf v1.3.3 @@ -36,7 +37,6 @@ require ( github.com/prometheus/common v0.29.0 github.com/rakyll/statik v0.1.7 github.com/regen-network/cosmos-proto v0.3.1 - github.com/regen-network/regen-ledger/types v0.0.0-20210823092432-9005905bc310 github.com/rs/zerolog v1.23.0 github.com/spf13/cast v1.3.1 github.com/spf13/cobra v1.1.3 @@ -54,6 +54,7 @@ require ( google.golang.org/grpc v1.38.0 google.golang.org/protobuf v1.26.0 gopkg.in/yaml.v2 v2.4.0 + nhooyr.io/websocket v1.8.6 // indirect pgregory.net/rapid v0.4.7 ) diff --git a/go.sum b/go.sum index 22564911a9..9310a4a9f0 100644 --- a/go.sum +++ b/go.sum @@ -159,7 +159,6 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cosmos/cosmos-sdk v0.43.0-rc0/go.mod h1:ctcrTEAhei9s8O3KSNvL0dxe+fVQGp07QyRb/7H9JYE= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= @@ -483,7 +482,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= @@ -655,8 +653,6 @@ github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzy github.com/regen-network/cosmos-proto v0.3.1/go.mod h1:jO0sVX6a1B36nmE8C9xBFXpNwWejXC7QqCOnH3O0+YM= github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4= github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI= -github.com/regen-network/regen-ledger/types v0.0.0-20210823092432-9005905bc310 h1:g0xgkUTYchGKdzGw4b1E4sR999JkJGaxOY6OS+hEo1s= -github.com/regen-network/regen-ledger/types v0.0.0-20210823092432-9005905bc310/go.mod h1:MPRrtwCCs+DE1slO1DQEfIcH8qZPoW/Ypc0s7jHjdPA= github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= @@ -825,7 +821,6 @@ golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= diff --git a/proto/regen/group/v1alpha1/tx.proto b/proto/regen/group/v1alpha1/tx.proto index 32ff98f2f6..62254bbcd4 100644 --- a/proto/regen/group/v1alpha1/tx.proto +++ b/proto/regen/group/v1alpha1/tx.proto @@ -330,6 +330,10 @@ message MsgVoteAgg { // metadata is any arbitrary metadata to attached to the vote. bytes metadata = 6; + + // exec defines whether the proposal should be executed + // immediately after voting or not. + Exec exec = 7; } // MsgVoteResponse is the Msg/Vote response type. diff --git a/regen/orm/testdata/codec.proto b/regen/orm/testdata/codec.proto index 31e15fde63..84f8f2f038 100644 --- a/regen/orm/testdata/codec.proto +++ b/regen/orm/testdata/codec.proto @@ -4,7 +4,7 @@ package testdata; import "gogoproto/gogo.proto"; -option go_package = "github.com/regen-network/regen-ledger/orm/testdata"; +option go_package = "github.com/cosmos/cosmos-sdk/regen/orm/testdata"; message GroupInfo { uint64 group_id = 1; diff --git a/regen/types/module/server/testutil.go b/regen/types/module/server/testutil.go index dd4de30e86..2cee0f89d6 100644 --- a/regen/types/module/server/testutil.go +++ b/regen/types/module/server/testutil.go @@ -6,6 +6,9 @@ import ( "fmt" "testing" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/std" + "github.com/cosmos/cosmos-sdk/regen/types/testutil" "github.com/cosmos/cosmos-sdk/baseapp" @@ -25,18 +28,22 @@ import ( ) type FixtureFactory struct { - t *testing.T - modules []module.Module - signers []sdk.AccAddress - cdc *codec.ProtoCodec - baseApp *baseapp.BaseApp + t *testing.T + modules []module.Module + signers []sdk.AccAddress + signersBls []sdk.AccAddress + sksBls []cryptotypes.PrivKey + cdc *codec.ProtoCodec + baseApp *baseapp.BaseApp } func NewFixtureFactory(t *testing.T, numSigners int) *FixtureFactory { - signers := makeTestAddresses(numSigners) + signers, signersBls, sksBls := makeTestAddresses(numSigners) return &FixtureFactory{ - t: t, - signers: signers, + t: t, + signers: signers, + signersBls: signersBls, + sksBls: sksBls, // cdc and baseApp are initialized here just for compatibility with legacy modules which don't use ADR 033 // TODO: remove once all code using this uses ADR 033 module wiring cdc: codec.NewProtoCodec(types.NewInterfaceRegistry()), @@ -60,12 +67,18 @@ func (ff *FixtureFactory) BaseApp() *baseapp.BaseApp { return ff.baseApp } -func makeTestAddresses(count int) []sdk.AccAddress { +func makeTestAddresses(count int) ([]sdk.AccAddress, []sdk.AccAddress, []cryptotypes.PrivKey) { addrs := make([]sdk.AccAddress, count) for i := 0; i < count; i++ { _, _, addrs[i] = testdata.KeyTestPubAddr() } - return addrs + + addrsBls := make([]sdk.AccAddress, count) + sksBls := make([]cryptotypes.PrivKey, count) + for i := 0; i < count; i++ { + sksBls[i], _, addrsBls[i] = testdata.KeyTestPubAddrBls12381() + } + return addrs, addrsBls, sksBls } func (ff FixtureFactory) Setup() testutil.Fixture { @@ -82,6 +95,8 @@ func (ff FixtureFactory) Setup() testutil.Fixture { err = baseApp.LoadLatestVersion() require.NoError(ff.t, err) + std.RegisterInterfaces(registry) + return fixture{ baseApp: baseApp, router: mm.router, @@ -90,6 +105,8 @@ func (ff FixtureFactory) Setup() testutil.Fixture { exportGenesisHandlers: mm.exportGenesisHandlers, t: ff.t, signers: ff.signers, + signersBls: ff.signersBls, + sksBls: ff.sksBls, } } @@ -101,6 +118,8 @@ type fixture struct { exportGenesisHandlers map[string]module.ExportGenesisHandler t *testing.T signers []sdk.AccAddress + signersBls []sdk.AccAddress + sksBls []cryptotypes.PrivKey } func (f fixture) Context() context.Context { @@ -108,7 +127,7 @@ func (f fixture) Context() context.Context { } func (f fixture) TxConn() grpc.ClientConnInterface { - return testKey{invokerFactory: f.router.testTxFactory(f.signers)} + return testKey{invokerFactory: f.router.testTxFactory(append(f.signers, f.signersBls...))} } func (f fixture) QueryConn() grpc.ClientConnInterface { @@ -119,6 +138,14 @@ func (f fixture) Signers() []sdk.AccAddress { return f.signers } +func (f fixture) SignersBls() []sdk.AccAddress { + return f.signersBls +} + +func (f fixture) SksBls() []cryptotypes.PrivKey { + return f.sksBls +} + func (f fixture) InitGenesis(ctx sdk.Context, genesisData map[string]json.RawMessage) (abci.ResponseInitChain, error) { return initGenesis(ctx, f.cdc, genesisData, []abci.ValidatorUpdate{}, f.initGenesisHandlers) } diff --git a/regen/types/testutil/fixture.go b/regen/types/testutil/fixture.go index d426329653..832e6b9834 100644 --- a/regen/types/testutil/fixture.go +++ b/regen/types/testutil/fixture.go @@ -13,6 +13,8 @@ import ( "context" "encoding/json" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" abci "github.com/tendermint/tendermint/abci/types" @@ -43,6 +45,10 @@ type Fixture interface { // random or correspond to nodes in a test network which have keyrings. Signers() []sdk.AccAddress + SignersBls() []sdk.AccAddress + + SksBls() []cryptotypes.PrivKey + // InitGenesis initializes genesis for all modules with provided genesisData. InitGenesis(ctx sdk.Context, genesisData map[string]json.RawMessage) (abci.ResponseInitChain, error) diff --git a/testutil/testdata/tx.go b/testutil/testdata/tx.go index abf3e63c2d..5377482e3d 100644 --- a/testutil/testdata/tx.go +++ b/testutil/testdata/tx.go @@ -3,6 +3,8 @@ package testdata import ( "encoding/json" + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" + "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -19,7 +21,7 @@ func KeyTestPubAddr() (cryptotypes.PrivKey, cryptotypes.PubKey, sdk.AccAddress) return key, pub, addr } -// KeyTestPubAddr generates a new secp256r1 keypair. +// KeyTestPubAddrSecp256R1 generates a new secp256r1 keypair. func KeyTestPubAddrSecp256R1(require *require.Assertions) (cryptotypes.PrivKey, cryptotypes.PubKey, sdk.AccAddress) { key, err := secp256r1.GenPrivKey() require.NoError(err) @@ -28,6 +30,14 @@ func KeyTestPubAddrSecp256R1(require *require.Assertions) (cryptotypes.PrivKey, return key, pub, addr } +// KeyTestPubAddrBls12381 generates a new secp256k1 keypair. +func KeyTestPubAddrBls12381() (cryptotypes.PrivKey, cryptotypes.PubKey, sdk.AccAddress) { + key := bls12381.GenPrivKey() + pub := key.PubKey() + addr := sdk.AccAddress(pub.Address()) + return key, pub, addr +} + // NewTestFeeAmount is a test fee amount. func NewTestFeeAmount() sdk.Coins { return sdk.NewCoins(sdk.NewInt64Coin("atom", 150)) diff --git a/x/group/server/msg_server.go b/x/group/server/msg_server.go index 9f85ee141a..7b7b46a721 100644 --- a/x/group/server/msg_server.go +++ b/x/group/server/msg_server.go @@ -703,13 +703,13 @@ func (s serverImpl) VoteAgg(goCtx context.Context, req *group.MsgVoteAgg) (*grou return nil, sdkerrors.Wrap(group.ErrExpired, "voting period has ended already") } - var accountInfo group.GroupAccountInfo // Ensure that group account hasn't been modified since the proposal submission. address, err := sdk.AccAddressFromBech32(proposal.Address) if err != nil { return nil, sdkerrors.Wrap(err, "group account") } - if err := s.groupAccountTable.GetOne(ctx, address.Bytes(), &accountInfo); err != nil { + accountInfo, err := s.getGroupAccountInfo(ctx, address.Bytes()) + if err != nil { return nil, sdkerrors.Wrap(err, "load group account") } if proposal.GroupAccountVersion != accountInfo.Version { @@ -759,11 +759,11 @@ func (s serverImpl) VoteAgg(goCtx context.Context, req *group.MsgVoteAgg) (*grou acc := s.accKeeper.GetAccount(ctx.Context, memAddr) if acc == nil { - return nil, sdkerrors.Wrap(group.ErrInvalid, "account does not exist") + return nil, sdkerrors.Wrapf(group.ErrInvalid, "account %s does not exist", memAddr.String()) } pk := acc.GetPubKey() if pk == nil { - return nil, sdkerrors.Wrap(group.ErrInvalid, "public key not set yet") + return nil, sdkerrors.Wrapf(group.ErrInvalid, "public key for account %s not set yet", memAddr.String()) } meta := fmt.Sprintf("submitted through aggregated vote by %s", req.Sender) @@ -843,6 +843,17 @@ func (s serverImpl) VoteAgg(goCtx context.Context, req *group.MsgVoteAgg) (*grou return nil, err } + // Try to execute proposal immediately + if req.Exec == group.Exec_EXEC_TRY { + _, err = s.Exec(ctx, &group.MsgExec{ + ProposalId: id, + Signer: req.Sender, + }) + if err != nil { + return nil, err + } + } + return &group.MsgVoteAggResponse{}, nil } diff --git a/x/group/server/testsuite/suite.go b/x/group/server/testsuite/suite.go index fbfec759bf..5d8f6da06c 100644 --- a/x/group/server/testsuite/suite.go +++ b/x/group/server/testsuite/suite.go @@ -3,10 +3,19 @@ package testsuite import ( "bytes" "context" + + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" + + //"github.com/cosmos/cosmos-sdk/x/group/server" + + //"github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" "sort" "strings" "time" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/group/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -42,9 +51,22 @@ type IntegrationTestSuite struct { addr4 sdk.AccAddress addr5 sdk.AccAddress addr6 sdk.AccAddress + addrBls1 sdk.AccAddress + addrBls2 sdk.AccAddress + addrBls3 sdk.AccAddress + addrBls4 sdk.AccAddress + addrBls5 sdk.AccAddress + addrBls6 sdk.AccAddress groupAccountAddr sdk.AccAddress groupID uint64 + skBls1 cryptotypes.PrivKey + skBls2 cryptotypes.PrivKey + skBls3 cryptotypes.PrivKey + skBls4 cryptotypes.PrivKey + skBls5 cryptotypes.PrivKey + skBls6 cryptotypes.PrivKey + accountKeeper authkeeper.AccountKeeper // paramSpace paramstypes.Subspace bankKeeper bankkeeper.Keeper @@ -82,6 +104,7 @@ func (s *IntegrationTestSuite) SetupSuite() { s.genesisCtx = types.Context{Context: sdkCtx} s.Require().NoError(s.bankKeeper.MintCoins(s.sdkCtx, minttypes.ModuleName, sdk.NewCoins(sdk.NewInt64Coin("test", 400000000)))) + s.accountKeeper.SetParams(sdkCtx, authtypes.DefaultParams()) s.bankKeeper.SetParams(sdkCtx, banktypes.DefaultParams()) s.msgClient = group.NewMsgClient(s.fixture.TxConn()) @@ -95,6 +118,67 @@ func (s *IntegrationTestSuite) SetupSuite() { s.addr5 = s.fixture.Signers()[4] s.addr6 = s.fixture.Signers()[5] + s.addrBls1 = s.fixture.SignersBls()[0] + s.addrBls2 = s.fixture.SignersBls()[1] + s.addrBls3 = s.fixture.SignersBls()[2] + s.addrBls4 = s.fixture.SignersBls()[3] + s.addrBls5 = s.fixture.SignersBls()[4] + s.addrBls6 = s.fixture.SignersBls()[5] + + s.skBls1 = s.fixture.SksBls()[0] + s.skBls2 = s.fixture.SksBls()[1] + s.skBls3 = s.fixture.SksBls()[2] + s.skBls4 = s.fixture.SksBls()[3] + s.skBls5 = s.fixture.SksBls()[4] + s.skBls6 = s.fixture.SksBls()[5] + + accBls1 := s.accountKeeper.NewAccountWithAddress(s.sdkCtx, s.addrBls1) + accBls2 := s.accountKeeper.NewAccountWithAddress(s.sdkCtx, s.addrBls2) + accBls3 := s.accountKeeper.NewAccountWithAddress(s.sdkCtx, s.addrBls3) + accBls4 := s.accountKeeper.NewAccountWithAddress(s.sdkCtx, s.addrBls4) + accBls5 := s.accountKeeper.NewAccountWithAddress(s.sdkCtx, s.addrBls5) + accBls6 := s.accountKeeper.NewAccountWithAddress(s.sdkCtx, s.addrBls6) + + pkBls1 := s.skBls1.PubKey() + pkBls2 := s.skBls2.PubKey() + pkBls3 := s.skBls3.PubKey() + pkBls4 := s.skBls4.PubKey() + pkBls5 := s.skBls5.PubKey() + pkBls6 := s.skBls6.PubKey() + + err := accBls1.SetPubKey(pkBls1) + s.Require().NoError(err) + err = accBls2.SetPubKey(pkBls2) + s.Require().NoError(err) + err = accBls3.SetPubKey(pkBls3) + s.Require().NoError(err) + err = accBls4.SetPubKey(pkBls4) + s.Require().NoError(err) + err = accBls5.SetPubKey(pkBls5) + s.Require().NoError(err) + err = accBls6.SetPubKey(pkBls6) + s.Require().NoError(err) + + err = accBls1.SetPopValid(true) + s.Require().NoError(err) + err = accBls2.SetPopValid(true) + s.Require().NoError(err) + err = accBls3.SetPopValid(true) + s.Require().NoError(err) + err = accBls4.SetPopValid(true) + s.Require().NoError(err) + err = accBls5.SetPopValid(true) + s.Require().NoError(err) + err = accBls6.SetPopValid(true) + s.Require().NoError(err) + + s.accountKeeper.SetAccount(s.sdkCtx, accBls1) + s.accountKeeper.SetAccount(s.sdkCtx, accBls2) + s.accountKeeper.SetAccount(s.sdkCtx, accBls3) + s.accountKeeper.SetAccount(s.sdkCtx, accBls4) + s.accountKeeper.SetAccount(s.sdkCtx, accBls5) + s.accountKeeper.SetAccount(s.sdkCtx, accBls6) + // Initial group, group account and balance setup members := []group.Member{ {Address: s.addr5.String(), Weight: "1"}, {Address: s.addr2.String(), Weight: "2"}, @@ -149,6 +233,26 @@ func (s *IntegrationTestSuite) TestCreateGroup() { Metadata: nil, }} + blsMembers := []group.Member{{ + Address: s.addrBls1.String(), + Weight: "3", + Metadata: nil, + }, { + Address: s.addrBls2.String(), + Weight: "5", + Metadata: nil, + }} + + mixedMembers := []group.Member{{ + Address: s.addr5.String(), + Weight: "2", + Metadata: nil, + }, { + Address: s.addrBls1.String(), + Weight: "3", + Metadata: nil, + }} + expGroups := []*group.GroupInfo{ { GroupId: s.groupID, @@ -164,12 +268,28 @@ func (s *IntegrationTestSuite) TestCreateGroup() { TotalWeight: "3", Metadata: nil, }, + { + GroupId: 2, + Version: 1, + Admin: s.addr1.String(), + TotalWeight: "8", + Metadata: nil, + BlsOnly: true, + }, + { + GroupId: 2, + Version: 1, + Admin: s.addr1.String(), + TotalWeight: "5", + Metadata: nil, + }, } specs := map[string]struct { req *group.MsgCreateGroup expErr bool expGroups []*group.GroupInfo + mems []group.Member }{ "all good": { req: &group.MsgCreateGroup{ @@ -177,7 +297,44 @@ func (s *IntegrationTestSuite) TestCreateGroup() { Members: members, Metadata: nil, }, - expGroups: expGroups, + expGroups: expGroups[0:2], + mems: members, + }, + "all good with bls members": { + req: &group.MsgCreateGroup{ + Admin: s.addr1.String(), + Members: blsMembers, + Metadata: nil, + BlsOnly: true, + }, + expGroups: []*group.GroupInfo{ + expGroups[0], + expGroups[2], + }, + mems: blsMembers, + }, + "all good with mixed memebers": { + req: &group.MsgCreateGroup{ + Admin: s.addr1.String(), + Members: mixedMembers, + Metadata: nil, + BlsOnly: false, + }, + expGroups: []*group.GroupInfo{ + expGroups[0], + expGroups[3], + }, + mems: mixedMembers, + }, + "mixed memebers not allowed when bls only": { + req: &group.MsgCreateGroup{ + Admin: s.addr1.String(), + Members: mixedMembers, + Metadata: nil, + BlsOnly: true, + }, + expErr: true, + mems: mixedMembers, }, "group metadata too long": { req: &group.MsgCreateGroup{ @@ -212,25 +369,27 @@ func (s *IntegrationTestSuite) TestCreateGroup() { expErr: true, }, } + var seq uint32 = 1 for msg, spec := range specs { - spec := spec s.Run(msg, func() { - res, err := s.msgClient.CreateGroup(s.ctx, spec.req) + sdkCtx, _ := s.sdkCtx.CacheContext() + ctx := types.Context{Context: sdkCtx} + + res, err := s.msgClient.CreateGroup(ctx, spec.req) if spec.expErr { s.Require().Error(err) - _, err := s.queryClient.GroupInfo(s.ctx, &group.QueryGroupInfoRequest{GroupId: uint64(seq + 1)}) + _, err := s.queryClient.GroupInfo(ctx, &group.QueryGroupInfoRequest{GroupId: uint64(seq + 1)}) s.Require().Error(err) return } s.Require().NoError(err) id := res.GroupId - seq++ - s.Assert().Equal(uint64(seq), id) + s.Assert().Equal(uint64(2), id) // then all data persisted - loadedGroupRes, err := s.queryClient.GroupInfo(s.ctx, &group.QueryGroupInfoRequest{GroupId: id}) + loadedGroupRes, err := s.queryClient.GroupInfo(ctx, &group.QueryGroupInfoRequest{GroupId: id}) s.Require().NoError(err) s.Assert().Equal(spec.req.Admin, loadedGroupRes.Info.Admin) s.Assert().Equal(spec.req.Metadata, loadedGroupRes.Info.Metadata) @@ -238,21 +397,21 @@ func (s *IntegrationTestSuite) TestCreateGroup() { s.Assert().Equal(uint64(1), loadedGroupRes.Info.Version) // and members are stored as well - membersRes, err := s.queryClient.GroupMembers(s.ctx, &group.QueryGroupMembersRequest{GroupId: id}) + membersRes, err := s.queryClient.GroupMembers(ctx, &group.QueryGroupMembersRequest{GroupId: id}) s.Require().NoError(err) loadedMembers := membersRes.Members - s.Require().Equal(len(members), len(loadedMembers)) + s.Require().Equal(len(spec.mems), len(loadedMembers)) // we reorder members by address to be able to compare them - sort.Slice(members, func(i, j int) bool { return members[i].Address < members[j].Address }) + sort.Slice(spec.mems, func(i, j int) bool { return spec.mems[i].Address < spec.mems[j].Address }) for i := range loadedMembers { - s.Assert().Equal(members[i].Metadata, loadedMembers[i].Member.Metadata) - s.Assert().Equal(members[i].Address, loadedMembers[i].Member.Address) - s.Assert().Equal(members[i].Weight, loadedMembers[i].Member.Weight) + s.Assert().Equal(spec.mems[i].Metadata, loadedMembers[i].Member.Metadata) + s.Assert().Equal(spec.mems[i].Address, loadedMembers[i].Member.Address) + s.Assert().Equal(spec.mems[i].Weight, loadedMembers[i].Member.Weight) s.Assert().Equal(id, loadedMembers[i].GroupId) } // query groups by admin - groupsRes, err := s.queryClient.GroupsByAdmin(s.ctx, &group.QueryGroupsByAdminRequest{Admin: s.addr1.String()}) + groupsRes, err := s.queryClient.GroupsByAdmin(ctx, &group.QueryGroupsByAdminRequest{Admin: s.addr1.String()}) s.Require().NoError(err) loadedGroups := groupsRes.Groups s.Require().Equal(len(spec.expGroups), len(loadedGroups)) @@ -262,6 +421,7 @@ func (s *IntegrationTestSuite) TestCreateGroup() { s.Assert().Equal(spec.expGroups[i].TotalWeight, loadedGroups[i].TotalWeight) s.Assert().Equal(spec.expGroups[i].GroupId, loadedGroups[i].GroupId) s.Assert().Equal(spec.expGroups[i].Version, loadedGroups[i].Version) + s.Assert().Equal(spec.expGroups[i].BlsOnly, loadedGroups[i].BlsOnly) } }) } @@ -707,6 +867,135 @@ func (s *IntegrationTestSuite) TestUpdateGroupMembers() { } } +func (s *IntegrationTestSuite) TestUpdateGroupMembersBls() { + member := s.addr3.String() + memberBls1 := s.addrBls1.String() + memberBls2 := s.addrBls2.String() + memberBls3 := s.addrBls3.String() + membersBls := []group.Member{ + { + Address: memberBls1, + Weight: "5", + Metadata: nil, + }, + { + Address: memberBls2, + Weight: "7", + Metadata: nil, + }, + } + + myAdmin := s.addr4.String() + groupBlsRes, err := s.msgClient.CreateGroup(s.ctx, &group.MsgCreateGroup{ + Admin: myAdmin, + Members: membersBls, + Metadata: nil, + BlsOnly: true, + }) + s.Require().NoError(err) + groupBlsID := groupBlsRes.GroupId + + specs := map[string]struct { + req *group.MsgUpdateGroupMembers + expErr bool + expGroup *group.GroupInfo + expMembers []*group.GroupMember + }{ + "add new bls member": { + req: &group.MsgUpdateGroupMembers{ + GroupId: groupBlsID, + Admin: myAdmin, + MemberUpdates: []group.Member{{ + Address: memberBls3, + Weight: "3", + Metadata: nil, + }}, + }, + expGroup: &group.GroupInfo{ + GroupId: groupBlsID, + Admin: myAdmin, + Metadata: nil, + TotalWeight: "15", + Version: 2, + BlsOnly: true, + }, + expMembers: []*group.GroupMember{ + { + Member: &group.Member{ + Address: memberBls1, + Weight: "5", + Metadata: nil, + }, + GroupId: groupBlsID, + }, + { + Member: &group.Member{ + Address: memberBls2, + Weight: "7", + Metadata: nil, + }, + GroupId: groupBlsID, + }, + { + Member: &group.Member{ + Address: memberBls3, + Weight: "3", + Metadata: nil, + }, + GroupId: groupBlsID, + }, + }, + }, + "add new non-bls member not allowed": { + req: &group.MsgUpdateGroupMembers{ + GroupId: groupBlsID, + Admin: myAdmin, + MemberUpdates: []group.Member{{ + Address: member, + Weight: "1", + Metadata: nil, + }}, + }, + expErr: true, + }, + } + + for msg, spec := range specs { + spec := spec + s.Run(msg, func() { + sdkCtx, _ := s.sdkCtx.CacheContext() + ctx := types.Context{Context: sdkCtx} + _, err := s.msgClient.UpdateGroupMembers(ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + + // then + res, err := s.queryClient.GroupInfo(ctx, &group.QueryGroupInfoRequest{GroupId: groupBlsID}) + s.Require().NoError(err) + s.Assert().Equal(spec.expGroup, res.Info) + + // and members persisted + membersRes, err := s.queryClient.GroupMembers(ctx, &group.QueryGroupMembersRequest{GroupId: groupBlsID}) + s.Require().NoError(err) + loadedMembers := membersRes.Members + s.Require().Equal(len(spec.expMembers), len(loadedMembers)) + // we reorder group members by address to be able to compare them + sort.Slice(spec.expMembers, func(i, j int) bool { + return spec.expMembers[i].Member.Address < spec.expMembers[j].Member.Address + }) + for i := range loadedMembers { + s.Assert().Equal(spec.expMembers[i].Member.Metadata, loadedMembers[i].Member.Metadata) + s.Assert().Equal(spec.expMembers[i].Member.Address, loadedMembers[i].Member.Address) + s.Assert().Equal(spec.expMembers[i].Member.Weight, loadedMembers[i].Member.Weight) + s.Assert().Equal(spec.expMembers[i].GroupId, loadedMembers[i].GroupId) + } + }) + } +} + func (s *IntegrationTestSuite) TestCreateGroupAccount() { groupRes, err := s.msgClient.CreateGroup(s.ctx, &group.MsgCreateGroup{ Admin: s.addr1.String(), @@ -1833,6 +2122,315 @@ func (s *IntegrationTestSuite) TestVote() { } } +func (s *IntegrationTestSuite) TestVoteAgg() { + members := []group.Member{ + {Address: s.addrBls1.String(), Weight: "1"}, + {Address: s.addrBls2.String(), Weight: "2"}, + {Address: s.addrBls3.String(), Weight: "3"}, + {Address: s.addrBls4.String(), Weight: "4"}, + {Address: s.addrBls5.String(), Weight: "5"}, + } + + groupRes, err := s.msgClient.CreateGroup(s.ctx, &group.MsgCreateGroup{ + Admin: s.addrBls6.String(), + Members: members, + Metadata: nil, + BlsOnly: true, + }) + s.Require().NoError(err) + myGroupID := groupRes.GroupId + + policy := group.NewThresholdDecisionPolicy( + "8", + gogotypes.Duration{Seconds: 20}, + ) + accountReq := &group.MsgCreateGroupAccount{ + Admin: s.addrBls6.String(), + GroupId: myGroupID, + Metadata: nil, + } + err = accountReq.SetDecisionPolicy(policy) + s.Require().NoError(err) + accountRes, err := s.msgClient.CreateGroupAccount(s.ctx, accountReq) + s.Require().NoError(err) + accountAddr := accountRes.Address + groupAccount, err := sdk.AccAddressFromBech32(accountAddr) + s.Require().NoError(err) + s.Require().NotNil(groupAccount) + + s.Require().NoError(fundAccount(s.bankKeeper, s.sdkCtx, groupAccount, sdk.Coins{sdk.NewInt64Coin("test", 10000)})) + + req := &group.MsgCreateProposal{ + Address: accountAddr, + Metadata: nil, + Proposers: []string{s.addrBls1.String()}, + Msgs: nil, + } + err = req.SetMsgs([]sdk.Msg{&banktypes.MsgSend{ + FromAddress: accountAddr, + ToAddress: s.addrBls1.String(), + Amount: sdk.Coins{sdk.NewInt64Coin("test", 100)}, + }}) + s.Require().NoError(err) + + proposalRes, err := s.msgClient.CreateProposal(s.ctx, req) + s.Require().NoError(err) + myProposalID := proposalRes.ProposalId + + // proposals by group account + proposalsRes, err := s.queryClient.ProposalsByGroupAccount(s.ctx, &group.QueryProposalsByGroupAccountRequest{ + Address: accountAddr, + }) + s.Require().NoError(err) + proposals := proposalsRes.Proposals + s.Require().Equal(len(proposals), 1) + s.Assert().Equal(req.Address, proposals[0].Address) + s.Assert().Equal(req.Metadata, proposals[0].Metadata) + s.Assert().Equal(req.Proposers, proposals[0].Proposers) + + submittedAt, err := gogotypes.TimestampFromProto(&proposals[0].SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + + s.Assert().Equal(uint64(1), proposals[0].GroupVersion) + s.Assert().Equal(uint64(1), proposals[0].GroupAccountVersion) + s.Assert().Equal(group.ProposalStatusSubmitted, proposals[0].Status) + s.Assert().Equal(group.ProposalResultUnfinalized, proposals[0].Result) + s.Assert().Equal(group.Tally{ + YesCount: "0", + NoCount: "0", + AbstainCount: "0", + VetoCount: "0", + }, proposals[0].VoteState) + + voteAggTimeout, err := gogotypes.TimestampProto(submittedAt.Add(time.Second * 10)) + s.Require().NoError(err) + + type fullVote struct { + Address string + Choice group.Choice + } + + rawVotesAcc := []fullVote{ + {Address: s.addrBls1.String(), Choice: group.Choice_CHOICE_YES}, + {Address: s.addrBls2.String(), Choice: group.Choice_CHOICE_NO}, + {Address: s.addrBls3.String(), Choice: group.Choice_CHOICE_YES}, + {Address: s.addrBls4.String(), Choice: group.Choice_CHOICE_UNSPECIFIED}, + {Address: s.addrBls5.String(), Choice: group.Choice_CHOICE_YES}, + } + sort.Slice(rawVotesAcc, func(i, j int) bool { return rawVotesAcc[i].Address < rawVotesAcc[j].Address }) + sortedVotesAcc := make([]group.Choice, len(rawVotesAcc)) + validVotesAcc := make([]fullVote, 0, len(rawVotesAcc)) + for i, v := range rawVotesAcc { + sortedVotesAcc[i] = v.Choice + if v.Choice != group.Choice_CHOICE_UNSPECIFIED { + validVotesAcc = append(validVotesAcc, v) + } + } + + rawVotesRej := []fullVote{ + {Address: s.addrBls1.String(), Choice: group.Choice_CHOICE_YES}, + {Address: s.addrBls2.String(), Choice: group.Choice_CHOICE_ABSTAIN}, + {Address: s.addrBls3.String(), Choice: group.Choice_CHOICE_NO}, + {Address: s.addrBls4.String(), Choice: group.Choice_CHOICE_UNSPECIFIED}, + {Address: s.addrBls5.String(), Choice: group.Choice_CHOICE_VETO}, + } + sort.Slice(rawVotesRej, func(i, j int) bool { return rawVotesRej[i].Address < rawVotesRej[j].Address }) + sortedVotesRej := make([]group.Choice, len(rawVotesRej)) + validVotesRej := make([]fullVote, 0, len(rawVotesRej)) + for i, v := range rawVotesRej { + sortedVotesRej[i] = v.Choice + if v.Choice != group.Choice_CHOICE_UNSPECIFIED { + validVotesRej = append(validVotesRej, v) + } + } + + msgNo := &group.MsgVoteBasic{ + ProposalId: myProposalID, + Choice: group.Choice_CHOICE_NO, + Timeout: *voteAggTimeout, + } + signBytesNo := msgNo.GetSignBytes() + + msgYes := &group.MsgVoteBasic{ + ProposalId: myProposalID, + Choice: group.Choice_CHOICE_YES, + Timeout: *voteAggTimeout, + } + signBytesYes := msgYes.GetSignBytes() + + msgAbstain := &group.MsgVoteBasic{ + ProposalId: myProposalID, + Choice: group.Choice_CHOICE_ABSTAIN, + Timeout: *voteAggTimeout, + } + signBytesAbstain := msgAbstain.GetSignBytes() + + msgVeto := &group.MsgVoteBasic{ + ProposalId: myProposalID, + Choice: group.Choice_CHOICE_VETO, + Timeout: *voteAggTimeout, + } + signBytesVeto := msgVeto.GetSignBytes() + + sig1, err := s.skBls1.Sign(signBytesYes) + s.Require().NoError(err) + sig2, err := s.skBls2.Sign(signBytesNo) + s.Require().NoError(err) + sig3, err := s.skBls3.Sign(signBytesYes) + s.Require().NoError(err) + sig5, err := s.skBls5.Sign(signBytesYes) + s.Require().NoError(err) + sigmaAcc, err := bls12381.AggregateSignature([][]byte{sig1, sig2, sig3, sig5}) + s.Require().NoError(err) + + sig1, err = s.skBls1.Sign(signBytesYes) + s.Require().NoError(err) + sig2, err = s.skBls2.Sign(signBytesAbstain) + s.Require().NoError(err) + sig3, err = s.skBls3.Sign(signBytesNo) + s.Require().NoError(err) + sig5, err = s.skBls5.Sign(signBytesVeto) + s.Require().NoError(err) + sigmaRej, err := bls12381.AggregateSignature([][]byte{sig1, sig2, sig3, sig5}) + s.Require().NoError(err) + + specs := map[string]struct { + srcCtx sdk.Context + expVoteState group.Tally + req *group.MsgVoteAgg + votes []fullVote + doBefore func(ctx context.Context) + postRun func(sdkCtx sdk.Context) + expProposalStatus group.Proposal_Status + expResult group.Proposal_Result + expExecutorResult group.Proposal_ExecutorResult + expErr bool + }{ + "result accepted with exec": { + req: &group.MsgVoteAgg{ + Sender: s.addr1.String(), + ProposalId: myProposalID, + Votes: sortedVotesAcc, + Timeout: *voteAggTimeout, + AggSig: sigmaAcc, + Exec: group.Exec_EXEC_TRY, + }, + votes: validVotesAcc, + expVoteState: group.Tally{ + YesCount: "9", + NoCount: "2", + AbstainCount: "0", + VetoCount: "0", + }, + expProposalStatus: group.ProposalStatusClosed, + expResult: group.ProposalResultAccepted, + expExecutorResult: group.ProposalExecutorResultSuccess, + postRun: func(sdkCtx sdk.Context) { + fromBalances := s.bankKeeper.GetAllBalances(sdkCtx, groupAccount) + s.Require().Equal(sdk.Coins{sdk.NewInt64Coin("test", 9900)}, fromBalances) + toBalances := s.bankKeeper.GetAllBalances(sdkCtx, s.addrBls1) + s.Require().Equal(sdk.Coins{sdk.NewInt64Coin("test", 100)}, toBalances) + }, + }, + "result rejected": { + req: &group.MsgVoteAgg{ + Sender: s.addr1.String(), + ProposalId: myProposalID, + Votes: sortedVotesRej, + Timeout: *voteAggTimeout, + AggSig: sigmaRej, + Exec: group.Exec_EXEC_TRY, + }, + votes: validVotesRej, + expVoteState: group.Tally{ + YesCount: "1", + NoCount: "3", + AbstainCount: "2", + VetoCount: "5", + }, + expProposalStatus: group.ProposalStatusClosed, + expResult: group.ProposalResultRejected, + expExecutorResult: group.ProposalExecutorResultNotRun, + postRun: func(sdkCtx sdk.Context) { + fromBalances := s.bankKeeper.GetAllBalances(sdkCtx, groupAccount) + s.Require().Equal(sdk.Coins{sdk.NewInt64Coin("test", 10000)}, fromBalances) + toBalances := s.bankKeeper.GetAllBalances(sdkCtx, s.addrBls1) + s.Require().Equal(sdk.Coins{}, toBalances) + }, + }, + } + + for msg, spec := range specs { + spec := spec + s.Run(msg, func() { + sdkCtx := s.sdkCtx + if !spec.srcCtx.IsZero() { + sdkCtx = spec.srcCtx + } + sdkCtx, _ = sdkCtx.CacheContext() + ctx := types.Context{Context: sdkCtx} + + if spec.doBefore != nil { + spec.doBefore(ctx) + } + _, err := s.msgClient.VoteAgg(ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + + // query votes by proposal + votesByProposalRes, err := s.queryClient.VotesByProposal(ctx, &group.QueryVotesByProposalRequest{ + ProposalId: spec.req.ProposalId, + }) + s.Require().NoError(err) + votesByProposal := votesByProposalRes.Votes + s.Require().Equal(len(spec.votes), len(votesByProposal)) + + for i, vote := range votesByProposal { + s.Assert().Equal(spec.req.ProposalId, vote.ProposalId) + s.Assert().Equal(spec.votes[i].Address, vote.Voter) + s.Assert().Equal(spec.votes[i].Choice, vote.Choice) + submittedAt, err = gogotypes.TimestampFromProto(&vote.SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + } + + // query votes by voter + for _, vote := range spec.votes { + votesByVoterRes, err := s.queryClient.VotesByVoter(ctx, &group.QueryVotesByVoterRequest{ + Voter: vote.Address, + }) + s.Require().NoError(err) + votesByVoter := votesByVoterRes.Votes + s.Require().Equal(1, len(votesByVoter)) + s.Assert().Equal(spec.req.ProposalId, votesByVoter[0].ProposalId) + s.Assert().Equal(vote.Address, votesByVoter[0].Voter) + s.Assert().Equal(vote.Choice, votesByVoter[0].Choice) + submittedAt, err = gogotypes.TimestampFromProto(&votesByVoter[0].SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + } + + // and proposal is updated + proposalRes, err := s.queryClient.Proposal(ctx, &group.QueryProposalRequest{ + ProposalId: spec.req.ProposalId, + }) + s.Require().NoError(err) + proposal := proposalRes.Proposal + s.Assert().Equal(spec.expVoteState, proposal.VoteState) + s.Assert().Equal(spec.expResult, proposal.Result) + s.Assert().Equal(spec.expProposalStatus, proposal.Status) + s.Assert().Equal(spec.expExecutorResult, proposal.ExecutorResult) + + spec.postRun(sdkCtx) + }) + } + +} + func (s *IntegrationTestSuite) TestExecProposal() { msgSend1 := &banktypes.MsgSend{ FromAddress: s.groupAccountAddr.String(), diff --git a/x/group/tx.pb.go b/x/group/tx.pb.go index a908c6f71d..8cccaa59af 100644 --- a/x/group/tx.pb.go +++ b/x/group/tx.pb.go @@ -1248,6 +1248,9 @@ type MsgVoteAgg struct { AggSig []byte `protobuf:"bytes,5,opt,name=agg_sig,json=aggSig,proto3" json:"agg_sig,omitempty"` // metadata is any arbitrary metadata to attached to the vote. Metadata []byte `protobuf:"bytes,6,opt,name=metadata,proto3" json:"metadata,omitempty"` + // exec defines whether the proposal should be executed + // immediately after voting or not. + Exec Exec `protobuf:"varint,7,opt,name=exec,proto3,enum=regen.group.v1alpha1.Exec" json:"exec,omitempty"` } func (m *MsgVoteAgg) Reset() { *m = MsgVoteAgg{} } @@ -1325,6 +1328,13 @@ func (m *MsgVoteAgg) GetMetadata() []byte { return nil } +func (m *MsgVoteAgg) GetExec() Exec { + if m != nil { + return m.Exec + } + return Exec_EXEC_UNSPECIFIED +} + // MsgVoteResponse is the Msg/Vote response type. type MsgVoteAggResponse struct { } @@ -1487,83 +1497,83 @@ func init() { func init() { proto.RegisterFile("regen/group/v1alpha1/tx.proto", fileDescriptor_b4673626e7797578) } var fileDescriptor_b4673626e7797578 = []byte{ - // 1208 bytes of a gzipped FileDescriptorProto + // 1212 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0x4f, 0x6f, 0x1b, 0x45, 0x14, 0xf7, 0xda, 0x5b, 0x3b, 0x79, 0x09, 0x6e, 0xba, 0x35, 0xad, 0xbb, 0x6d, 0x6c, 0x6b, 0x49, 0x55, 0xd3, 0x24, 0x36, 0x49, 0x7a, 0xa0, 0xa1, 0x42, 0x72, 0xd2, 0x80, 0x22, 0x30, 0x84, 0x6d, 0x83, 0x00, 0x21, 0x59, 0xeb, 0xdd, 0x61, 0xb2, 0xc4, 0xbb, 0xb3, 0xf2, 0xac, 0xd3, 0xf8, 0x03, - 0x20, 0x71, 0x42, 0x48, 0x1c, 0xb9, 0x94, 0x2f, 0x00, 0x17, 0xae, 0x5c, 0xb8, 0x50, 0x71, 0xea, - 0x91, 0x53, 0x54, 0x25, 0xb7, 0x1e, 0xf9, 0x04, 0x68, 0x67, 0x67, 0xd7, 0xff, 0xd6, 0x6b, 0xbb, - 0xaa, 0x38, 0x25, 0x6f, 0xe6, 0xf7, 0xde, 0xfc, 0xde, 0xdf, 0x7d, 0x32, 0x2c, 0xb7, 0x11, 0x46, - 0x76, 0x15, 0xb7, 0x49, 0xc7, 0xa9, 0x9e, 0x6c, 0x68, 0x2d, 0xe7, 0x48, 0xdb, 0xa8, 0xba, 0xa7, - 0x15, 0xa7, 0x4d, 0x5c, 0x22, 0xe5, 0xd8, 0x75, 0x85, 0x5d, 0x57, 0x82, 0x6b, 0x39, 0x87, 0x09, - 0x26, 0x0c, 0x50, 0xf5, 0xfe, 0xf3, 0xb1, 0xf2, 0xa2, 0x4e, 0xa8, 0x45, 0x28, 0x97, 0x6e, 0x60, - 0x42, 0x70, 0x0b, 0x55, 0x99, 0xd4, 0xec, 0x7c, 0x53, 0xd5, 0xec, 0x2e, 0xbf, 0x2a, 0x0e, 0x5f, - 0xb9, 0xa6, 0x85, 0xa8, 0xab, 0x59, 0x0e, 0x07, 0x94, 0xa2, 0x49, 0x75, 0x1d, 0xc4, 0xad, 0x2b, - 0x3f, 0x0b, 0x90, 0xad, 0x53, 0xbc, 0xdb, 0x46, 0x9a, 0x8b, 0x3e, 0xf4, 0x70, 0x52, 0x0e, 0x2e, - 0x69, 0x86, 0x65, 0xda, 0x79, 0xa1, 0x24, 0x94, 0xe7, 0x55, 0x5f, 0x90, 0x1e, 0x40, 0xc6, 0x42, - 0x56, 0x13, 0xb5, 0x69, 0x3e, 0x59, 0x4a, 0x95, 0x17, 0x36, 0x6f, 0x55, 0xa2, 0x5c, 0xaa, 0xd4, - 0x19, 0x68, 0x47, 0x7c, 0x76, 0x56, 0x4c, 0xa8, 0x81, 0x8a, 0x24, 0xc3, 0x9c, 0x85, 0x5c, 0xcd, - 0xd0, 0x5c, 0x2d, 0x9f, 0x2a, 0x09, 0xe5, 0x45, 0x35, 0x94, 0xa5, 0x1b, 0x30, 0xd7, 0x6c, 0xd1, - 0x06, 0xb1, 0x5b, 0xdd, 0xbc, 0x58, 0x12, 0xca, 0x73, 0x6a, 0xa6, 0xd9, 0xa2, 0x9f, 0xda, 0xad, - 0xae, 0xb2, 0x05, 0xd7, 0x06, 0xc9, 0xa9, 0x88, 0x3a, 0xc4, 0xa6, 0xc8, 0x53, 0x62, 0x0f, 0x37, - 0x4c, 0x83, 0xf1, 0x14, 0xd5, 0x0c, 0x93, 0xf7, 0x0d, 0xe5, 0x27, 0x01, 0xde, 0xac, 0x53, 0x7c, - 0xe8, 0x18, 0x81, 0x56, 0x9d, 0xb3, 0x88, 0xf6, 0xac, 0xdf, 0x54, 0x72, 0xc0, 0x94, 0xb4, 0x0f, - 0x59, 0xdf, 0x83, 0x46, 0x87, 0x59, 0xa3, 0xf9, 0xd4, 0xd4, 0xbe, 0xbf, 0xe1, 0x6b, 0xfa, 0x34, - 0xa8, 0x52, 0x84, 0xe5, 0x48, 0x52, 0x81, 0x47, 0x8a, 0x0e, 0x57, 0x07, 0x01, 0x35, 0xc6, 0x6e, - 0x66, 0xce, 0x37, 0x61, 0xde, 0x46, 0x4f, 0x1a, 0xbe, 0x52, 0x8a, 0x29, 0xcd, 0xd9, 0xe8, 0x09, - 0xb3, 0xa6, 0x2c, 0xc3, 0xcd, 0x88, 0x47, 0x42, 0x0e, 0x88, 0xc5, 0x7b, 0x80, 0x24, 0x4f, 0xd2, - 0xcc, 0x34, 0x62, 0x32, 0xae, 0x94, 0xa0, 0x10, 0xfd, 0x4c, 0x48, 0xe4, 0x0f, 0x3f, 0x87, 0x7d, - 0x99, 0xaf, 0xe9, 0x3a, 0xe9, 0xd8, 0xee, 0x6b, 0x25, 0x22, 0x7d, 0x06, 0x97, 0x0d, 0xa4, 0x9b, - 0xd4, 0x24, 0x76, 0xc3, 0x21, 0x2d, 0x53, 0xf7, 0x2b, 0x70, 0x61, 0x33, 0x57, 0xf1, 0x5b, 0xab, - 0x12, 0xb4, 0x56, 0xa5, 0x66, 0x77, 0x77, 0xa4, 0xbf, 0x7f, 0x5f, 0xcf, 0x3e, 0xe4, 0x0a, 0x07, - 0x0c, 0xaf, 0x66, 0x8d, 0x01, 0x79, 0x5b, 0xfc, 0xfe, 0x69, 0x31, 0xa1, 0xdc, 0x67, 0xd9, 0x1e, - 0xa5, 0x1f, 0xd6, 0x6f, 0x1e, 0x32, 0x9a, 0x61, 0xb4, 0x11, 0xa5, 0xdc, 0x91, 0x40, 0x54, 0x4c, - 0x90, 0x87, 0x52, 0xe4, 0xab, 0xc6, 0x95, 0x43, 0x9f, 0xb5, 0xe4, 0x80, 0xb5, 0xf8, 0x6a, 0x58, - 0x01, 0x65, 0xfc, 0x53, 0x61, 0x2e, 0x7e, 0x15, 0xe0, 0xad, 0x48, 0xd8, 0x60, 0x24, 0x66, 0xa6, - 0x16, 0x11, 0xfc, 0xd4, 0x6b, 0x09, 0xfe, 0x3a, 0xac, 0x4e, 0xc1, 0x37, 0xf4, 0xef, 0x78, 0xb8, - 0x33, 0x39, 0x7c, 0x42, 0xed, 0x8f, 0x77, 0x2c, 0xae, 0xf4, 0xef, 0xc0, 0xed, 0xd8, 0xc7, 0x42, - 0x56, 0x7f, 0x09, 0x70, 0x25, 0x2c, 0xa1, 0x83, 0x36, 0x71, 0x08, 0xd5, 0x5a, 0xe3, 0xcb, 0x46, - 0xba, 0x05, 0xf3, 0x0e, 0x43, 0x05, 0x13, 0x7a, 0x5e, 0xed, 0x1d, 0xc4, 0x36, 0x41, 0x19, 0x44, - 0x8b, 0x62, 0x9a, 0x17, 0xd9, 0x68, 0x8b, 0x0c, 0xbe, 0xca, 0x10, 0x52, 0x05, 0x44, 0x74, 0x8a, - 0xf4, 0xfc, 0xa5, 0x92, 0x50, 0xce, 0x6e, 0xca, 0xd1, 0x43, 0x70, 0xef, 0x14, 0xe9, 0x2a, 0xc3, - 0xf1, 0x74, 0x3c, 0x80, 0x1b, 0x23, 0x8e, 0x84, 0x7d, 0x50, 0x84, 0x05, 0x87, 0x9f, 0xf5, 0x46, - 0x39, 0x04, 0x47, 0xfb, 0x86, 0xf2, 0xa7, 0x00, 0x99, 0x3a, 0xc5, 0x9f, 0x13, 0x77, 0x32, 0xd8, - 0xcb, 0xd4, 0x09, 0x71, 0x51, 0x9b, 0x67, 0xc4, 0x17, 0xa4, 0x7b, 0x90, 0xd6, 0x8f, 0x88, 0xa9, - 0x23, 0xe6, 0x7a, 0x76, 0xdc, 0xf4, 0xde, 0x65, 0x18, 0x95, 0x63, 0x07, 0x42, 0x26, 0x0e, 0x85, - 0x6c, 0xc6, 0x40, 0x28, 0x57, 0xe0, 0x32, 0xf7, 0x21, 0xcc, 0xef, 0x2f, 0x02, 0x2c, 0xf2, 0xb3, - 0x1d, 0x8d, 0x9a, 0xfa, 0x64, 0xe7, 0x7a, 0x6e, 0x24, 0x67, 0x70, 0x63, 0x1b, 0x32, 0xde, 0x56, - 0x40, 0x3a, 0x2e, 0xef, 0x2e, 0x79, 0x24, 0xc1, 0x8f, 0x83, 0xad, 0x21, 0xf8, 0x6a, 0x73, 0x05, - 0xe5, 0xb7, 0x24, 0xe4, 0xfa, 0x39, 0x4e, 0x9d, 0xb5, 0xff, 0x9f, 0x6b, 0x2f, 0xf5, 0x62, 0x7f, - 0xea, 0xbf, 0x86, 0x8c, 0xd3, 0x69, 0x36, 0x8e, 0x51, 0x97, 0xe5, 0x6a, 0xdc, 0x6c, 0x59, 0x7f, - 0x79, 0x56, 0xcc, 0x39, 0x9d, 0x66, 0xcb, 0xd4, 0x3d, 0xec, 0x1a, 0xb1, 0x4c, 0x17, 0x59, 0x8e, - 0xdb, 0xfd, 0xf7, 0xac, 0x78, 0xa5, 0xab, 0x59, 0xad, 0x6d, 0xa5, 0x77, 0xab, 0xa8, 0x69, 0xa7, - 0xd3, 0xfc, 0x08, 0x75, 0xa5, 0x25, 0x48, 0x51, 0x13, 0xe7, 0xd3, 0xac, 0x3a, 0xbc, 0x7f, 0x95, - 0x97, 0x02, 0x00, 0x8f, 0x58, 0x0d, 0x63, 0xe9, 0x1a, 0xa4, 0x29, 0xb2, 0x0d, 0xd4, 0xe6, 0xdd, - 0xca, 0xa5, 0xe1, 0xf8, 0x25, 0x47, 0xe2, 0xb7, 0xe9, 0x7b, 0xe3, 0xef, 0x1b, 0x93, 0xc2, 0xe7, - 0x43, 0xfb, 0xa3, 0x27, 0xce, 0x1a, 0xbd, 0xeb, 0x90, 0xd1, 0x30, 0x6e, 0x78, 0xde, 0x5c, 0x62, - 0xde, 0xa4, 0x35, 0x8c, 0x1f, 0x99, 0x78, 0xa0, 0x0b, 0xd2, 0x43, 0xb3, 0x2c, 0x07, 0x52, 0xcf, - 0xd7, 0xb0, 0xb0, 0x77, 0x58, 0xbf, 0x7a, 0xc5, 0x3f, 0xb9, 0x4c, 0xbc, 0xf8, 0x98, 0xd8, 0x0e, - 0x1b, 0x96, 0x4b, 0xbc, 0x5f, 0x58, 0x03, 0x71, 0xb3, 0x77, 0xef, 0x82, 0xc8, 0x6c, 0xe6, 0x60, - 0x69, 0xef, 0x8b, 0xbd, 0xdd, 0xc6, 0xe1, 0x27, 0x8f, 0x0e, 0xf6, 0x76, 0xf7, 0x3f, 0xd8, 0xdf, - 0x7b, 0xb8, 0x94, 0x90, 0x16, 0x61, 0x8e, 0x9d, 0x3e, 0x56, 0xbf, 0x5c, 0x12, 0x36, 0x5f, 0x00, - 0xa4, 0xea, 0x14, 0x4b, 0x1a, 0x2c, 0xf4, 0x2f, 0xb6, 0x2b, 0x63, 0xb6, 0xb6, 0x81, 0x0f, 0xb5, - 0xbc, 0x36, 0x0d, 0x2a, 0xec, 0x84, 0x13, 0x90, 0x22, 0x16, 0xcd, 0xd5, 0xb1, 0x36, 0x46, 0xc1, - 0xf2, 0xd6, 0x0c, 0xe0, 0xf0, 0x5d, 0x07, 0x96, 0x46, 0x56, 0xc5, 0xb7, 0xa7, 0x31, 0xc4, 0xa0, - 0xf2, 0xc6, 0xd4, 0xd0, 0xf0, 0xc5, 0x2e, 0x5c, 0x8d, 0x5a, 0x0c, 0xd7, 0xa6, 0x63, 0xef, 0xa3, - 0xe5, 0x7b, 0xb3, 0xa0, 0xfb, 0x83, 0x1c, 0xb1, 0x09, 0xae, 0x4e, 0x93, 0x28, 0x0e, 0x8e, 0x09, - 0x72, 0xcc, 0x92, 0xf6, 0x9d, 0x00, 0xd7, 0xc7, 0x2d, 0x62, 0xef, 0x4c, 0x15, 0xc1, 0x3e, 0x0d, - 0xf9, 0xdd, 0x59, 0x35, 0x42, 0x1e, 0x4f, 0x05, 0x28, 0x4d, 0x5c, 0xbf, 0xee, 0xcf, 0x60, 0x7e, - 0x50, 0x55, 0xae, 0xbd, 0xb2, 0x6a, 0x48, 0xf1, 0x07, 0x01, 0xe4, 0x98, 0x15, 0x6a, 0x6b, 0x86, - 0x17, 0xc2, 0x62, 0x79, 0xef, 0x15, 0x94, 0x42, 0x42, 0xdf, 0x42, 0x76, 0x68, 0x77, 0xba, 0x33, - 0xa1, 0x04, 0x02, 0xa0, 0x5c, 0x9d, 0x12, 0x18, 0xbe, 0xf5, 0x31, 0x88, 0x6c, 0x3f, 0x59, 0x1e, - 0xab, 0xe8, 0x5d, 0xcb, 0xb7, 0x63, 0xaf, 0x43, 0x6b, 0x87, 0x90, 0x09, 0xbe, 0x1f, 0xa5, 0x58, - 0x8d, 0x1a, 0xc6, 0x72, 0x79, 0x12, 0xa2, 0x9f, 0x24, 0x1b, 0xa0, 0xe3, 0x49, 0x7a, 0xd7, 0x31, - 0x24, 0xfb, 0xc7, 0xf1, 0xce, 0xfb, 0xcf, 0xce, 0x0b, 0xc2, 0xf3, 0xf3, 0x82, 0xf0, 0xe2, 0xbc, - 0x20, 0xfc, 0x78, 0x51, 0x48, 0x3c, 0xbf, 0x28, 0x24, 0xfe, 0xb9, 0x28, 0x24, 0xbe, 0x5a, 0xc1, - 0xa6, 0x7b, 0xd4, 0x69, 0x56, 0x74, 0x62, 0x55, 0xfd, 0x1f, 0x32, 0xf8, 0x9f, 0x75, 0x6a, 0x1c, - 0x57, 0x4f, 0xfd, 0x1f, 0x23, 0x9a, 0x69, 0xf6, 0x4d, 0xda, 0xfa, 0x2f, 0x00, 0x00, 0xff, 0xff, - 0xeb, 0x25, 0x3d, 0xeb, 0x37, 0x11, 0x00, 0x00, + 0x20, 0x71, 0x42, 0x48, 0xdc, 0xe0, 0x52, 0xbe, 0x00, 0x5c, 0xb8, 0x72, 0xe1, 0x42, 0xc5, 0xa9, + 0x47, 0x4e, 0x51, 0x95, 0xdc, 0x38, 0xf2, 0x09, 0xd0, 0xce, 0xce, 0xae, 0xff, 0xad, 0xd7, 0x76, + 0x55, 0x71, 0x4a, 0xde, 0xcc, 0xef, 0xbd, 0xf7, 0x7b, 0xff, 0x66, 0x9f, 0x0c, 0xcb, 0x6d, 0x84, + 0x91, 0x5d, 0xc5, 0x6d, 0xd2, 0x71, 0xaa, 0x27, 0x1b, 0x5a, 0xcb, 0x39, 0xd2, 0x36, 0xaa, 0xee, + 0x69, 0xc5, 0x69, 0x13, 0x97, 0x48, 0x39, 0x76, 0x5d, 0x61, 0xd7, 0x95, 0xe0, 0x5a, 0xce, 0x61, + 0x82, 0x09, 0x03, 0x54, 0xbd, 0xff, 0x7c, 0xac, 0xbc, 0xa8, 0x13, 0x6a, 0x11, 0xca, 0xa5, 0x1b, + 0x98, 0x10, 0xdc, 0x42, 0x55, 0x26, 0x35, 0x3b, 0x5f, 0x55, 0x35, 0xbb, 0xcb, 0xaf, 0x8a, 0xc3, + 0x57, 0xae, 0x69, 0x21, 0xea, 0x6a, 0x96, 0xc3, 0x01, 0xa5, 0x68, 0x52, 0x5d, 0x07, 0x71, 0xeb, + 0xca, 0x4f, 0x02, 0x64, 0xeb, 0x14, 0xef, 0xb6, 0x91, 0xe6, 0xa2, 0xf7, 0x3d, 0x9c, 0x94, 0x83, + 0x4b, 0x9a, 0x61, 0x99, 0x76, 0x5e, 0x28, 0x09, 0xe5, 0x79, 0xd5, 0x17, 0xa4, 0x07, 0x90, 0xb1, + 0x90, 0xd5, 0x44, 0x6d, 0x9a, 0x4f, 0x96, 0x52, 0xe5, 0x85, 0xcd, 0x5b, 0x95, 0xa8, 0x90, 0x2a, + 0x75, 0x06, 0xda, 0x11, 0x9f, 0x9d, 0x15, 0x13, 0x6a, 0xa0, 0x22, 0xc9, 0x30, 0x67, 0x21, 0x57, + 0x33, 0x34, 0x57, 0xcb, 0xa7, 0x4a, 0x42, 0x79, 0x51, 0x0d, 0x65, 0xe9, 0x06, 0xcc, 0x35, 0x5b, + 0xb4, 0x41, 0xec, 0x56, 0x37, 0x2f, 0x96, 0x84, 0xf2, 0x9c, 0x9a, 0x69, 0xb6, 0xe8, 0xc7, 0x76, + 0xab, 0xab, 0x6c, 0xc1, 0xb5, 0x41, 0x72, 0x2a, 0xa2, 0x0e, 0xb1, 0x29, 0xf2, 0x94, 0x98, 0xe3, + 0x86, 0x69, 0x30, 0x9e, 0xa2, 0x9a, 0x61, 0xf2, 0xbe, 0xa1, 0xfc, 0x20, 0xc0, 0xeb, 0x75, 0x8a, + 0x0f, 0x1d, 0x23, 0xd0, 0xaa, 0x73, 0x16, 0xd1, 0x91, 0xf5, 0x9b, 0x4a, 0x0e, 0x98, 0x92, 0xf6, + 0x21, 0xeb, 0x47, 0xd0, 0xe8, 0x30, 0x6b, 0x34, 0x9f, 0x9a, 0x3a, 0xf6, 0xd7, 0x7c, 0x4d, 0x9f, + 0x06, 0x55, 0x8a, 0xb0, 0x1c, 0x49, 0x2a, 0x88, 0x48, 0xd1, 0xe1, 0xea, 0x20, 0xa0, 0xc6, 0xd8, + 0xcd, 0xcc, 0xf9, 0x26, 0xcc, 0xdb, 0xe8, 0x49, 0xc3, 0x57, 0x4a, 0x31, 0xa5, 0x39, 0x1b, 0x3d, + 0x61, 0xd6, 0x94, 0x65, 0xb8, 0x19, 0xe1, 0x24, 0xe4, 0x80, 0x58, 0xbe, 0x07, 0x48, 0xf2, 0x22, + 0xcd, 0x4c, 0x23, 0xa6, 0xe2, 0x4a, 0x09, 0x0a, 0xd1, 0x6e, 0x42, 0x22, 0xbf, 0xfb, 0x35, 0xec, + 0xab, 0x7c, 0x4d, 0xd7, 0x49, 0xc7, 0x76, 0x5f, 0x29, 0x11, 0xe9, 0x13, 0xb8, 0x6c, 0x20, 0xdd, + 0xa4, 0x26, 0xb1, 0x1b, 0x0e, 0x69, 0x99, 0xba, 0xdf, 0x81, 0x0b, 0x9b, 0xb9, 0x8a, 0x3f, 0x5a, + 0x95, 0x60, 0xb4, 0x2a, 0x35, 0xbb, 0xbb, 0x23, 0xfd, 0xf5, 0xdb, 0x7a, 0xf6, 0x21, 0x57, 0x38, + 0x60, 0x78, 0x35, 0x6b, 0x0c, 0xc8, 0xdb, 0xe2, 0xb7, 0x4f, 0x8b, 0x09, 0xe5, 0x3e, 0xab, 0xf6, + 0x28, 0xfd, 0xb0, 0x7f, 0xf3, 0x90, 0xd1, 0x0c, 0xa3, 0x8d, 0x28, 0xe5, 0x81, 0x04, 0xa2, 0x62, + 0x82, 0x3c, 0x54, 0x22, 0x5f, 0x35, 0xae, 0x1d, 0xfa, 0xac, 0x25, 0x07, 0xac, 0xc5, 0x77, 0xc3, + 0x0a, 0x28, 0xe3, 0x5d, 0x85, 0xb5, 0xf8, 0x45, 0x80, 0x37, 0x22, 0x61, 0x83, 0x99, 0x98, 0x99, + 0x5a, 0x44, 0xf2, 0x53, 0xaf, 0x24, 0xf9, 0xeb, 0xb0, 0x3a, 0x05, 0xdf, 0x30, 0xbe, 0xe3, 0xe1, + 0xc9, 0xe4, 0xf0, 0x09, 0xbd, 0x3f, 0x3e, 0xb0, 0xb8, 0xd6, 0xbf, 0x03, 0xb7, 0x63, 0x9d, 0x85, + 0xac, 0xfe, 0x14, 0xe0, 0x4a, 0xd8, 0x42, 0x07, 0x6d, 0xe2, 0x10, 0xaa, 0xb5, 0xc6, 0xb7, 0x8d, + 0x74, 0x0b, 0xe6, 0x1d, 0x86, 0x0a, 0x5e, 0xe8, 0x79, 0xb5, 0x77, 0x10, 0x3b, 0x04, 0x65, 0x10, + 0x2d, 0x8a, 0x69, 0x5e, 0x64, 0x4f, 0x5b, 0x64, 0xf2, 0x55, 0x86, 0x90, 0x2a, 0x20, 0xa2, 0x53, + 0xa4, 0xe7, 0x2f, 0x95, 0x84, 0x72, 0x76, 0x53, 0x8e, 0x7e, 0x04, 0xf7, 0x4e, 0x91, 0xae, 0x32, + 0x1c, 0x2f, 0xc7, 0x03, 0xb8, 0x31, 0x12, 0x48, 0x38, 0x07, 0x45, 0x58, 0x70, 0xf8, 0x59, 0xef, + 0x29, 0x87, 0xe0, 0x68, 0xdf, 0x50, 0xfe, 0x10, 0x20, 0x53, 0xa7, 0xf8, 0x53, 0xe2, 0x4e, 0x06, + 0x7b, 0x95, 0x3a, 0x21, 0x2e, 0x6a, 0xf3, 0x8a, 0xf8, 0x82, 0x74, 0x0f, 0xd2, 0xfa, 0x11, 0x31, + 0x75, 0xc4, 0x42, 0xcf, 0x8e, 0x7b, 0xbd, 0x77, 0x19, 0x46, 0xe5, 0xd8, 0x81, 0x94, 0x89, 0x43, + 0x29, 0x9b, 0x31, 0x11, 0xca, 0x15, 0xb8, 0xcc, 0x63, 0x08, 0xeb, 0xfb, 0xb3, 0x00, 0x8b, 0xfc, + 0x6c, 0x47, 0xa3, 0xa6, 0x3e, 0x39, 0xb8, 0x5e, 0x18, 0xc9, 0x19, 0xc2, 0xd8, 0x86, 0x8c, 0xb7, + 0x15, 0x90, 0x8e, 0xcb, 0xa7, 0x4b, 0x1e, 0x29, 0xf0, 0xe3, 0x60, 0x6b, 0x08, 0xbe, 0xda, 0x5c, + 0x41, 0xf9, 0x35, 0x09, 0xb9, 0x7e, 0x8e, 0x53, 0x57, 0xed, 0xff, 0xe7, 0xda, 0x2b, 0xbd, 0xd8, + 0x5f, 0xfa, 0x2f, 0x21, 0xe3, 0x74, 0x9a, 0x8d, 0x63, 0xd4, 0x65, 0xb5, 0x1a, 0xf7, 0xb6, 0xac, + 0xff, 0x73, 0x56, 0xcc, 0x39, 0x9d, 0x66, 0xcb, 0xd4, 0x3d, 0xec, 0x1a, 0xb1, 0x4c, 0x17, 0x59, + 0x8e, 0xdb, 0xfd, 0xf7, 0xac, 0x78, 0xa5, 0xab, 0x59, 0xad, 0x6d, 0xa5, 0x77, 0xab, 0xa8, 0x69, + 0xa7, 0xd3, 0xfc, 0x00, 0x75, 0xa5, 0x25, 0x48, 0x51, 0x13, 0xe7, 0xd3, 0xac, 0x3b, 0xbc, 0x7f, + 0x95, 0x1f, 0x93, 0x00, 0x3c, 0x63, 0x35, 0x8c, 0xa5, 0x6b, 0x90, 0xa6, 0xc8, 0x36, 0x50, 0x9b, + 0x4f, 0x2b, 0x97, 0x86, 0xf3, 0x97, 0x1c, 0xc9, 0xdf, 0xa6, 0x1f, 0x8d, 0xbf, 0x6f, 0x4c, 0x4a, + 0x9f, 0x0f, 0xed, 0xcf, 0x9e, 0x38, 0x6b, 0xf6, 0xae, 0x43, 0x46, 0xc3, 0xb8, 0xe1, 0x45, 0x73, + 0x89, 0x45, 0x93, 0xd6, 0x30, 0x7e, 0x64, 0xe2, 0x81, 0x29, 0x48, 0x8f, 0x99, 0x82, 0xcc, 0x94, + 0x53, 0x90, 0x03, 0xa9, 0x97, 0x9b, 0x70, 0x10, 0x76, 0xd8, 0x7c, 0x7b, 0xb0, 0xc9, 0x6d, 0xe5, + 0xe5, 0xd3, 0xc4, 0x76, 0x38, 0xe0, 0x5c, 0xe2, 0xf3, 0xc5, 0x5c, 0x71, 0xb3, 0x77, 0xef, 0x82, + 0xc8, 0x6c, 0xe6, 0x60, 0x69, 0xef, 0xb3, 0xbd, 0xdd, 0xc6, 0xe1, 0x47, 0x8f, 0x0e, 0xf6, 0x76, + 0xf7, 0xdf, 0xdb, 0xdf, 0x7b, 0xb8, 0x94, 0x90, 0x16, 0x61, 0x8e, 0x9d, 0x3e, 0x56, 0x3f, 0x5f, + 0x12, 0x36, 0x5f, 0x00, 0xa4, 0xea, 0x14, 0x4b, 0x1a, 0x2c, 0xf4, 0x2f, 0xc2, 0x2b, 0x63, 0xb6, + 0xbc, 0x81, 0x0f, 0xbb, 0xbc, 0x36, 0x0d, 0x2a, 0x9c, 0x9c, 0x13, 0x90, 0x22, 0x16, 0xd3, 0xd5, + 0xb1, 0x36, 0x46, 0xc1, 0xf2, 0xd6, 0x0c, 0xe0, 0xd0, 0xaf, 0x03, 0x4b, 0x23, 0xab, 0xe5, 0x9b, + 0xd3, 0x18, 0x62, 0x50, 0x79, 0x63, 0x6a, 0x68, 0xe8, 0xb1, 0x0b, 0x57, 0xa3, 0x16, 0xc9, 0xb5, + 0xe9, 0xd8, 0xfb, 0x68, 0xf9, 0xde, 0x2c, 0xe8, 0xfe, 0x24, 0x47, 0x6c, 0x8e, 0xab, 0xd3, 0x14, + 0x8a, 0x83, 0x63, 0x92, 0x1c, 0xb3, 0xd4, 0x7d, 0x23, 0xc0, 0xf5, 0x71, 0x8b, 0xdb, 0x5b, 0x53, + 0x65, 0xb0, 0x4f, 0x43, 0x7e, 0x7b, 0x56, 0x8d, 0x90, 0xc7, 0x53, 0x01, 0x4a, 0x13, 0xd7, 0xb5, + 0xfb, 0x33, 0x98, 0x1f, 0x54, 0x95, 0x6b, 0x2f, 0xad, 0x1a, 0x52, 0xfc, 0x4e, 0x00, 0x39, 0x66, + 0xe5, 0xda, 0x9a, 0xc1, 0x43, 0xd8, 0x2c, 0xef, 0xbc, 0x84, 0x52, 0x48, 0xe8, 0x6b, 0xc8, 0x0e, + 0xed, 0x5a, 0x77, 0x26, 0xb4, 0x40, 0x00, 0x94, 0xab, 0x53, 0x02, 0x43, 0x5f, 0x1f, 0x82, 0xc8, + 0xf6, 0x99, 0xe5, 0xb1, 0x8a, 0xde, 0xb5, 0x7c, 0x3b, 0xf6, 0x3a, 0xb4, 0x76, 0x08, 0x99, 0xe0, + 0x7b, 0x53, 0x8a, 0xd5, 0xa8, 0x61, 0x2c, 0x97, 0x27, 0x21, 0xfa, 0x49, 0xb2, 0x07, 0x74, 0x3c, + 0x49, 0xef, 0x3a, 0x86, 0x64, 0xff, 0x73, 0xbc, 0xf3, 0xee, 0xb3, 0xf3, 0x82, 0xf0, 0xfc, 0xbc, + 0x20, 0xbc, 0x38, 0x2f, 0x08, 0xdf, 0x5f, 0x14, 0x12, 0xcf, 0x2f, 0x0a, 0x89, 0xbf, 0x2f, 0x0a, + 0x89, 0x2f, 0x56, 0xb0, 0xe9, 0x1e, 0x75, 0x9a, 0x15, 0x9d, 0x58, 0x55, 0xff, 0x87, 0x0f, 0xfe, + 0x67, 0x9d, 0x1a, 0xc7, 0xd5, 0x53, 0xff, 0xc7, 0x8b, 0x66, 0x9a, 0x7d, 0xc3, 0xb6, 0xfe, 0x0b, + 0x00, 0x00, 0xff, 0xff, 0xab, 0x37, 0x66, 0xeb, 0x67, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2947,6 +2957,11 @@ func (m *MsgVoteAgg) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Exec != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Exec)) + i-- + dAtA[i] = 0x38 + } if len(m.Metadata) > 0 { i -= len(m.Metadata) copy(dAtA[i:], m.Metadata) @@ -3505,6 +3520,9 @@ func (m *MsgVoteAgg) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if m.Exec != 0 { + n += 1 + sovTx(uint64(m.Exec)) + } return n } @@ -6274,6 +6292,25 @@ func (m *MsgVoteAgg) Unmarshal(dAtA []byte) error { m.Metadata = []byte{} } iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Exec", wireType) + } + m.Exec = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Exec |= Exec(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/group/types_test.go b/x/group/types_test.go index ea862d2518..c2c09e0398 100644 --- a/x/group/types_test.go +++ b/x/group/types_test.go @@ -4,11 +4,11 @@ import ( "testing" "time" + "github.com/cosmos/cosmos-sdk/regen/orm" + "github.com/cosmos/cosmos-sdk/regen/types/math" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" proto "github.com/gogo/protobuf/types" - "github.com/cosmos/cosmos-sdk/regen/orm" - "github.com/cosmos/cosmos-sdk/regen/types/math" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) From 34ce3d4318271dc0484eef967c17b67b7a6d811d Mon Sep 17 00:00:00 2001 From: kitty Date: Thu, 16 Sep 2021 14:09:16 +0100 Subject: [PATCH 27/34] client and server for poll and aggregated votes and integration tests --- crypto/keys/bls12381/bls12381.go | 6 +- proto/regen/group/v1alpha1/events.proto | 14 + proto/regen/group/v1alpha1/genesis.proto | 10 + proto/regen/group/v1alpha1/query.proto | 141 + proto/regen/group/v1alpha1/tx.proto | 143 +- proto/regen/group/v1alpha1/types.proto | 87 + regen/types/testutil/network/network.go | 49 + simapp/app.go | 140 +- simapp/appconfig.go | 64 + x/group/client/client_test.go | 14 + x/group/client/query.go | 231 + x/group/client/testsuite/query.go | 352 +- x/group/client/testsuite/tx.go | 890 ++- x/group/client/tx.go | 477 +- x/group/client/util.go | 28 +- x/group/codec.go | 16 +- x/group/events.pb.go | 326 +- x/group/genesis.pb.go | 214 +- x/group/msgs.go | 446 +- x/group/msgs_test.go | 707 ++- x/group/query.pb.go | 6284 +++++++++++++++------ x/group/query.pb.gw.go | 664 +++ x/group/server/genesis.go | 23 + x/group/server/msg_server.go | 401 +- x/group/server/query_server.go | 142 + x/group/server/server.go | 51 + x/group/server/testsuite/suite.go | 825 ++- x/group/{server => }/sigverify.go | 8 +- x/group/tx.pb.go | 6429 +++++++++++++++------- x/group/types.go | 119 +- x/group/types.pb.go | 2843 +++++++--- x/group/typesupport.go | 26 + 32 files changed, 17383 insertions(+), 4787 deletions(-) create mode 100644 simapp/appconfig.go create mode 100644 x/group/client/client_test.go rename x/group/{server => }/sigverify.go (60%) diff --git a/crypto/keys/bls12381/bls12381.go b/crypto/keys/bls12381/bls12381.go index fc4d02d7ae..7aa9ffb98c 100644 --- a/crypto/keys/bls12381/bls12381.go +++ b/crypto/keys/bls12381/bls12381.go @@ -24,7 +24,7 @@ const ( // SignatureSize is the size of a bls signature. Namely the size of a compressed // G2 point. SignatureSize = 96 - KeyType = "bls12381" + keyType = "bls12381" SeedSize = 32 ) @@ -76,7 +76,7 @@ func (privKey *PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool { } func (privKey *PrivKey) Type() string { - return KeyType + return keyType } // MarshalAmino overrides Amino binary marshalling. @@ -191,7 +191,7 @@ func (pubKey *PubKey) String() string { } func (pubKey *PubKey) Type() string { - return KeyType + return keyType } func (pubKey *PubKey) Equals(other cryptotypes.PubKey) bool { diff --git a/proto/regen/group/v1alpha1/events.proto b/proto/regen/group/v1alpha1/events.proto index 2181ec2c55..3b0d1c30cf 100644 --- a/proto/regen/group/v1alpha1/events.proto +++ b/proto/regen/group/v1alpha1/events.proto @@ -52,3 +52,17 @@ message EventExec { // proposal_id is the unique ID of the proposal. uint64 proposal_id = 1; } + +// EventCreateProposal is an event emitted when a proposal is created. +message EventCreatePoll { + + // poll_id is the unique ID of the poll. + uint64 poll_id = 1; +} + +// EventVotePoll is an event emitted when a voter votes on a proposal. +message EventVotePoll { + + // poll_id is the unique ID of the proposal. + uint64 poll_id = 1; +} \ No newline at end of file diff --git a/proto/regen/group/v1alpha1/genesis.proto b/proto/regen/group/v1alpha1/genesis.proto index 9567f87976..b5ac744c13 100644 --- a/proto/regen/group/v1alpha1/genesis.proto +++ b/proto/regen/group/v1alpha1/genesis.proto @@ -36,4 +36,14 @@ message GenesisState { // votes is the list of votes. repeated Vote votes = 8; + + // polls is the list of polls. + repeated Poll polls = 9; + + // poll_seq is the poll table orm.Sequence, + // it is used to get the next poll ID. + uint64 poll_seq = 10; + + // votes is the list of votes for poll. + repeated VotePoll votes_for_poll = 11; } diff --git a/proto/regen/group/v1alpha1/query.proto b/proto/regen/group/v1alpha1/query.proto index 4afe78420a..ad0e410a35 100644 --- a/proto/regen/group/v1alpha1/query.proto +++ b/proto/regen/group/v1alpha1/query.proto @@ -65,6 +65,36 @@ service Query { rpc VotesByVoter(QueryVotesByVoterRequest) returns (QueryVotesByVoterResponse) { option (google.api.http).get = "/regen/group/v1alpha1/voters/{voter}"; } + + // Poll queries a poll based on poll id. + rpc Poll(QueryPollRequest) returns (QueryPollResponse) { + option (google.api.http).get = "/regen/group/v1alpha1/polls/{poll_id}"; + } + + // PollsByGroup queries polls based on group id. + rpc PollsByGroup(QueryPollsByGroupRequest) returns (QueryPollsByGroupResponse) { + option (google.api.http).get = "/regen/group/v1alpha1/group/polls"; + } + + // PollsByCreator queries polls by creator address. + rpc PollsByCreator(QueryPollsByCreatorRequest) returns (QueryPollsByCreatorResponse) { + option (google.api.http).get = "/regen/group/v1alpha1/creators/{creator}/polls"; + } + + // VoteForPollByPollVoter queries a vote by poll id and voter. + rpc VoteForPollByPollVoter(QueryVoteForPollByPollVoterRequest) returns (QueryVoteForPollByPollVoterResponse) { + option (google.api.http).get = "/regen/group/v1alpha1/polls/{poll_id}/votes/{voter}"; + } + + // VotesForPollByPoll queries votes by poll. + rpc VotesForPollByPoll(QueryVotesForPollByPollRequest) returns (QueryVotesForPollByPollResponse) { + option (google.api.http).get = "/regen/group/v1alpha1/polls/{poll_id}/votes"; + } + + // VotesForPollByVoter queries votes for poll by voter. + rpc VotesForPollByVoter(QueryVotesForPollByVoterRequest) returns (QueryVotesForPollByVoterResponse) { + option (google.api.http).get = "/regen/group/v1alpha1/voters/{voter}"; + } } // QueryGroupInfoRequest is the Query/GroupInfo request type. @@ -264,3 +294,114 @@ message QueryVotesByVoterResponse { // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; } + + +// QueryPollRequest is the Query/Poll request type. +message QueryPollRequest { + + // poll_id is the unique ID of a poll. + uint64 poll_id = 1; +} + +// QueryPollResponse is the Query/Poll response type. +message QueryPollResponse { + + // poll is the poll info. + Poll poll = 1; +} + +// QueryPollsByGroupRequest is the Query/PollByGroup request type. +message QueryPollsByGroupRequest { + + // group_id is the group id related to polls. + uint64 group_id = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryPollsByGroupResponse is the Query/PollByGroup response type. +message QueryPollsByGroupResponse { + + // polls are the polls with given group id. + repeated Poll polls = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryPollsByCreatorRequest is the Query/PollByCreator request type. +message QueryPollsByCreatorRequest { + + // creator is the creator address related to polls. + string creator = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryPollsByCreatorResponse is the Query/PollsByCreator response type. +message QueryPollsByCreatorResponse { + + // polls are the polls with given creator. + repeated Poll polls = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryVoteForPollByPollVoterRequest is the Query/VotePollByPollVoter request type. +message QueryVoteForPollByPollVoterRequest { + + // poll_id is the unique ID of a poll. + uint64 poll_id = 1; + + // voter is a poll voter account address. + string voter = 2; +} + +// QueryVotesForPollByPollVoterResponse is the Query/VotePollByPollVoter response type. +message QueryVoteForPollByPollVoterResponse { + + // vote is the vote with given poll_id and voter. + VotePoll vote = 1; +} + +// QueryVotesForPollByPollRequest is the Query/VotePollsByPoll request type. +message QueryVotesForPollByPollRequest { + + // poll_id is the unique ID of a poll. + uint64 poll_id = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryVotesForPollByPollResponse is the Query/VotePollsByPoll response type. +message QueryVotesForPollByPollResponse { + + // votes are the list of votes for given poll_id. + repeated VotePoll votes = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryVotesForPollByVoterRequest is the Query/VotePollsByVoter request type. +message QueryVotesForPollByVoterRequest { + // voter is a poll voter account address. + string voter = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryVotesForPollByVoterResponse is the Query/VotePollsByVoter response type. +message QueryVotesForPollByVoterResponse { + + // votes are the list of votes for poll by given voter. + repeated VotePoll votes = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} \ No newline at end of file diff --git a/proto/regen/group/v1alpha1/tx.proto b/proto/regen/group/v1alpha1/tx.proto index 62254bbcd4..9ae8517a27 100644 --- a/proto/regen/group/v1alpha1/tx.proto +++ b/proto/regen/group/v1alpha1/tx.proto @@ -49,6 +49,15 @@ service Msg { // Exec executes a proposal. rpc Exec(MsgExec) returns (MsgExecResponse); + + // CreatePoll submits a new poll. + rpc CreatePoll(MsgCreatePoll) returns (MsgCreatePollResponse); + + // VotePoll allows a voter to vote on a poll. + rpc VotePoll(MsgVotePoll) returns (MsgVotePollResponse); + + // VotePollAgg allows a sender to submit a set of votes + rpc VotePollAgg(MsgVotePollAgg) returns (MsgVotePollAggResponse); } // @@ -285,8 +294,8 @@ message MsgVoteBasic { // choice is the voter's choice on the proposal. Choice choice = 2; - // timeout is the unique timestamp before which all the basic votes need to aggregated and submitted. - google.protobuf.Timestamp timeout = 3 [(gogoproto.nullable) = false]; + // expiry is the timestamp after which the basic vote expires. + google.protobuf.Timestamp expiry = 3 [(gogoproto.nullable) = false]; } // MsgVoteResponse is the basic vote that can be aggregated together @@ -297,8 +306,8 @@ message MsgVoteBasicResponse { // choice is the voter's choice on the proposal. Choice choice = 2; - // timeout is the unique timestamp before which the aggregated vote needs to submitted. - google.protobuf.Timestamp timeout = 3 [(gogoproto.nullable) = false]; + // expiry is the timestamp after which the basic vote expires. + google.protobuf.Timestamp expiry = 3 [(gogoproto.nullable) = false]; // voter is the account address of the voter. string voter = 4; @@ -311,7 +320,7 @@ message MsgVoteBasicResponse { bytes sig = 6; } -// MsgVoteRequest is the Msg/Vote request type. +// MsgVoteAgg is the Msg/VoteAgg request type. message MsgVoteAgg { // sender is the person who submits the votes string sender = 1; @@ -322,13 +331,17 @@ message MsgVoteAgg { // votes are the list of voters' choices on the proposal. repeated Choice votes = 3; - // timeout is the unique timestamp before which all the basic votes need to aggregated and submitted. - google.protobuf.Timestamp timeout = 4 [(gogoproto.nullable) = false]; + // expiry is the timestamp after which the basic vote expires. + // All the basic votes to be aggregated must have the same expiry. + // Expiry should be set to be before the proposal timeout in order to + // prevent replay attacks and also prevent the aggregator from removing + // some basic votes. + google.protobuf.Timestamp expiry = 4 [(gogoproto.nullable) = false]; // agg_sig is the bls aggregated signature for all the votes bytes agg_sig = 5; - // metadata is any arbitrary metadata to attached to the vote. + // metadata is any arbitrary metadata attached to the vote. bytes metadata = 6; // exec defines whether the proposal should be executed @@ -351,3 +364,117 @@ message MsgExec { // MsgExecResponse is the Msg/Exec request type. message MsgExecResponse { } + + + +// MsgCreateProposal is the Msg/CreateProposal request type. +message MsgCreatePoll { + option (gogoproto.goproto_getters) = false; + + // group_id is the unique ID of the group. + uint64 group_id = 1; + + string title = 2; + + Options options = 3 [(gogoproto.nullable) = false];; + + string creator = 4; + + // vote_limit is the number of options each voter can choose. + int32 vote_limit = 5; + + // metadata is any arbitrary metadata to attached to the proposal. + bytes metadata = 6; + + // timeout is the deadline of the poll. + google.protobuf.Timestamp timeout = 7 [(gogoproto.nullable) = false]; +} + +// MsgCreateProposalResponse is the Msg/CreateProposal response type. +message MsgCreatePollResponse { + + // poll_id is the unique ID of the poll. + uint64 poll_id = 1; +} + +// MsgVotePoll is the Msg/VotePoll request type. +message MsgVotePoll { + + // poll_id is the unique ID of the poll. + uint64 poll_id = 1; + + // voter is the voter account address. + string voter = 2; + + // options are the voter's choices on the poll. + Options options = 3 [(gogoproto.nullable) = false]; + + // metadata is any arbitrary metadata to attached to the vote. + bytes metadata = 4; +} + +// MsgVotePollResponse is the Msg/VotePoll response type. +message MsgVotePollResponse { } + +// MsgVoteBasicRequest is the Msg/Vote request type. +message MsgVotePollBasic { + + // poll_id is the unique ID of the poll. + uint64 poll_id = 1; + + // option is one of the voter's choices on the poll. + string option = 2; + + // expiry is the unique timestamp after which the basic vote expires. + google.protobuf.Timestamp expiry = 3 [(gogoproto.nullable) = false]; +} + +// MsgVoteResponse is the basic vote that can be aggregated together +message MsgVotePollBasicResponse { + // proposal is the unique ID of the proposal. + uint64 poll_id = 1; + + // options are the voter's choices on the poll. + Options options = 2 [(gogoproto.nullable) = false]; + + // expiry is the timestamp after which the basic vote expires. + google.protobuf.Timestamp expiry = 3 [(gogoproto.nullable) = false]; + + // voter is the account address of the voter. + string voter = 4; + + // pub_key is the voter's public key + google.protobuf.Any pub_key = 5 + [(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""]; + + // sig is the individual signature which will be aggregated with other voters' signatures + bytes sig = 6; +} + +// MsgVoteAgg is the Msg/VoteAgg request type. +message MsgVotePollAgg { + // sender is the person who submits the votes + string sender = 1; + + // poll_id is the unique ID of the poll. + uint64 poll_id = 2; + + // votes are the full list of voters' choices on the proposal. + repeated Options votes = 3 [(gogoproto.nullable) = false]; + + // expiry is the timestamp after which the basic vote expires. + // All the basic votes to be aggregated must have the same expiry. + // Expiry should be set to be before the poll timeout in order to + // prevent replay attacks and also prevent the aggregator from removing + // some basic votes. + google.protobuf.Timestamp expiry = 4 [(gogoproto.nullable) = false]; + + // agg_sig is the bls aggregated signature for all the votes + bytes agg_sig = 5; + + // metadata is any arbitrary metadata to attached to the vote. + bytes metadata = 6; +} + +// MsgVoteResponse is the Msg/Vote response type. +message MsgVotePollAggResponse { } \ No newline at end of file diff --git a/proto/regen/group/v1alpha1/types.proto b/proto/regen/group/v1alpha1/types.proto index 67f9c6871a..4c1697a071 100644 --- a/proto/regen/group/v1alpha1/types.proto +++ b/proto/regen/group/v1alpha1/types.proto @@ -275,3 +275,90 @@ message Vote { // submitted_at is the timestamp when the vote was submitted. google.protobuf.Timestamp submitted_at = 5 [(gogoproto.nullable) = false]; } + +// TallyPoll represents the sum of weighted votes for a poll. +message TallyPoll { + option (gogoproto.goproto_getters) = false; + map counts = 1; +} + +message Options { + option (gogoproto.goproto_getters) = false; + + repeated string titles = 1; +} + +message Poll { + option (gogoproto.goproto_getters) = false; + + // poll_id is the unique id of the poll. + uint64 poll_id = 1; + + // group_id is the unique ID of the group. + uint64 group_id = 2; + + string title = 3; + + Options options = 4 [(gogoproto.nullable) = false];; + + string creator = 5; + + int32 vote_limit = 6; + + // vote_state contains the sums of all weighted votes for this poll. + TallyPoll vote_state = 7 [(gogoproto.nullable) = false]; + + // metadata is any arbitrary metadata to attached to the proposal. + bytes metadata = 8; + + // submitted_at is a timestamp specifying when a proposal was submitted. + google.protobuf.Timestamp submitted_at = 9 [(gogoproto.nullable) = false]; + + // group_version tracks the version of the group that this proposal corresponds to. + // When group membership is changed, existing proposals from previous group versions will become invalid. + uint64 group_version = 10; + + // Status defines poll statuses. + enum Status { + option (gogoproto.goproto_enum_prefix) = false; + + // An empty value is invalid and not allowed. + STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "PollStatusInvalid"]; + + // Initial status of a poll when persisted. + STATUS_SUBMITTED = 1 [(gogoproto.enumvalue_customname) = "PollStatusSubmitted"]; + + // Final status of a poll when the final tally was executed. + STATUS_CLOSED = 2 [(gogoproto.enumvalue_customname) = "PollStatusClosed"]; + + // Final status of a poll when the group was modified before the final tally. + STATUS_ABORTED = 3 [(gogoproto.enumvalue_customname) = "PollStatusAborted"]; + } + + // Status represents the high level position in the life cycle of the proposal. Initial value is Submitted. + Status status = 11; + + // timeout is the timestamp of the block where the poll times out. Header times of the votes + // must be before this end time to be included in the election. + google.protobuf.Timestamp timeout = 12 [(gogoproto.nullable) = false]; +} + + +// VotePoll represents a vote for a poll. +message VotePoll { + + // poll_id is the unique ID of the pool. + uint64 poll_id = 1; + + // voter is the account address of the voter. + string voter = 2; + + // options are the voter's choices on the poll. + Options options = 3 [(gogoproto.nullable) = false];; + + // metadata is any arbitrary metadata to attached to the vote. + bytes metadata = 4; + + // submitted_at is the timestamp when the vote was submitted. + google.protobuf.Timestamp submitted_at = 5 [(gogoproto.nullable) = false]; +} \ No newline at end of file diff --git a/regen/types/testutil/network/network.go b/regen/types/testutil/network/network.go index 8f1802c02c..5a514b5075 100644 --- a/regen/types/testutil/network/network.go +++ b/regen/types/testutil/network/network.go @@ -14,6 +14,14 @@ import ( "testing" "time" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/simapp/params" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + tmrand "github.com/tendermint/tendermint/libs/rand" + dbm "github.com/tendermint/tm-db" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/codec" @@ -45,6 +53,19 @@ var lock = new(sync.Mutex) // creates an ABCI Application to provide to Tendermint. type AppConstructor = func(val Validator) servertypes.Application +// NewAppConstructor returns a new simapp AppConstructor +func NewAppConstructor(encodingCfg params.EncodingConfig) AppConstructor { + return func(val Validator) servertypes.Application { + return simapp.NewSimApp( + val.Ctx.Logger, dbm.NewMemDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0, + encodingCfg, + simapp.EmptyAppOptions{}, + baseapp.SetPruning(storetypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), + baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), + ) + } +} + // Config defines the necessary configuration used to bootstrap and start an // in-process local testing network. type Config struct { @@ -71,6 +92,34 @@ type Config struct { KeyringOptions []keyring.Option } +// DefaultConfig returns a sane default configuration suitable for nearly all +// testing requirements. +func DefaultConfig() Config { + encCfg := simapp.MakeTestEncodingConfig() + + return Config{ + Codec: encCfg.Marshaler, + TxConfig: encCfg.TxConfig, + LegacyAmino: encCfg.Amino, + InterfaceRegistry: encCfg.InterfaceRegistry, + AccountRetriever: authtypes.AccountRetriever{}, + AppConstructor: NewAppConstructor(encCfg), + GenesisState: simapp.ModuleBasics.DefaultGenesis(encCfg.Marshaler), + TimeoutCommit: 2 * time.Second, + ChainID: "chain-" + tmrand.NewRand().Str(6), + NumValidators: 4, + BondDenom: sdk.DefaultBondDenom, + MinGasPrices: fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), + AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction), + StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction), + BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction), + PruningStrategy: storetypes.PruningOptionNothing, + CleanupDir: true, + SigningAlgo: string(hd.Secp256k1Type), + KeyringOptions: []keyring.Option{}, + } +} + type ( // Network defines a local in-process testing network using SimApp. It can be // configured to start any number of validators, each with its own RPC and API diff --git a/simapp/app.go b/simapp/app.go index e3e73669b8..71393f6ee8 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -7,6 +7,8 @@ import ( "os" "path/filepath" + regenserver "github.com/cosmos/cosmos-sdk/regen/types/module/server" + airdroptypes "github.com/cosmos/cosmos-sdk/x/airdrop/types" "github.com/gorilla/mux" @@ -101,24 +103,26 @@ var ( // non-dependant module elements, such as codec registration // and genesis verification. ModuleBasics = module.NewBasicManager( - auth.AppModuleBasic{}, - genutil.AppModuleBasic{}, - bank.AppModuleBasic{}, - capability.AppModuleBasic{}, - staking.AppModuleBasic{}, - mint.AppModuleBasic{}, - distr.AppModuleBasic{}, - gov.NewAppModuleBasic( - paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler, - ), - params.AppModuleBasic{}, - crisis.AppModuleBasic{}, - slashing.AppModuleBasic{}, - feegrantmodule.AppModuleBasic{}, - upgrade.AppModuleBasic{}, - evidence.AppModuleBasic{}, - authzmodule.AppModuleBasic{}, - vesting.AppModuleBasic{}, + append([]module.AppModuleBasic{ + auth.AppModuleBasic{}, + genutil.AppModuleBasic{}, + bank.AppModuleBasic{}, + capability.AppModuleBasic{}, + staking.AppModuleBasic{}, + mint.AppModuleBasic{}, + distr.AppModuleBasic{}, + gov.NewAppModuleBasic( + paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler, + ), + params.AppModuleBasic{}, + crisis.AppModuleBasic{}, + slashing.AppModuleBasic{}, + feegrantmodule.AppModuleBasic{}, + upgrade.AppModuleBasic{}, + evidence.AppModuleBasic{}, + authzmodule.AppModuleBasic{}, + vesting.AppModuleBasic{}, + }, setCustomModuleBasics()...)..., ) // module account permissions @@ -177,6 +181,13 @@ type SimApp struct { // simulation manager sm *module.SimulationManager + // server module manager + // NOTE: We will likely want to make this new manager compatible + // with module.Manager so that we can have existing cosmos-sdk modules + // use ADR 33 approach without the need for removing their keepers + // and a larger refactoring. + smm *regenserver.Manager + // module configurator configurator module.Configurator } @@ -207,12 +218,14 @@ func NewSimApp( bApp.SetInterfaceRegistry(interfaceRegistry) keys := sdk.NewKVStoreKeys( - authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, - minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, - govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, - evidencetypes.StoreKey, capabilitytypes.StoreKey, - airdroptypes.StoreKey, - authzkeeper.StoreKey, + append([]string{ + authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, + minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, + govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, + evidencetypes.StoreKey, capabilitytypes.StoreKey, + airdroptypes.StoreKey, + authzkeeper.StoreKey, + }, setCustomKVStoreKeys()...)..., ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) // NOTE: The testingkey is just mounted for testing purposes. Actual applications should @@ -287,6 +300,9 @@ func NewSimApp( &stakingKeeper, govRouter, ) + // register custom modules here + app.smm = setCustomModules(app, interfaceRegistry) + app.AirdropKeeper = airdropkeeper.NewKeeper( appCodec, keys[airdroptypes.StoreKey], app.GetSubspace(airdroptypes.ModuleName), app.BankKeeper, authtypes.FeeCollectorName, @@ -313,25 +329,27 @@ func NewSimApp( // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. app.mm = module.NewManager( - genutil.NewAppModule( - app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx, - encodingConfig.TxConfig, - ), - auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts), - vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), - capability.NewAppModule(appCodec, *app.CapabilityKeeper), - crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), - feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), - upgrade.NewAppModule(app.UpgradeKeeper), - evidence.NewAppModule(app.EvidenceKeeper), - params.NewAppModule(app.ParamsKeeper), - authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + append([]module.AppModule{ + genutil.NewAppModule( + app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx, + encodingConfig.TxConfig, + ), + auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts), + vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), + bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), + capability.NewAppModule(appCodec, *app.CapabilityKeeper), + crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), + feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), + mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), + upgrade.NewAppModule(app.UpgradeKeeper), + evidence.NewAppModule(app.EvidenceKeeper), + params.NewAppModule(app.ParamsKeeper), + authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + }, app.setCustomModuleManager()...)..., ) // During begin block slashing happens after distr.BeginBlocker so that @@ -351,10 +369,12 @@ func NewSimApp( // so that other modules that want to create or claim capabilities afterwards in InitChain // can do so safely. app.mm.SetOrderInitGenesis( - capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, - slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, - genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, - feegrant.ModuleName, + append([]string{ + capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, + slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, + genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, + feegrant.ModuleName, + }, setCustomOrderInitGenesis()...)..., ) app.mm.RegisterInvariants(&app.CrisisKeeper) @@ -370,18 +390,20 @@ func NewSimApp( // NOTE: this is not required apps that don't use the simulator for fuzz testing // transactions app.sm = module.NewSimulationManager( - auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), - capability.NewAppModule(appCodec, *app.CapabilityKeeper), - feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), - distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - params.NewAppModule(app.ParamsKeeper), - evidence.NewAppModule(app.EvidenceKeeper), - authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + append([]module.AppModuleSimulation{ + auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts), + bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), + capability.NewAppModule(appCodec, *app.CapabilityKeeper), + feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), + mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), + staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), + distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + params.NewAppModule(app.ParamsKeeper), + evidence.NewAppModule(app.EvidenceKeeper), + authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + }, app.setCustomSimulationManager()...)..., ) app.sm.RegisterStoreDecoders() diff --git a/simapp/appconfig.go b/simapp/appconfig.go new file mode 100644 index 0000000000..d47a0e4c8c --- /dev/null +++ b/simapp/appconfig.go @@ -0,0 +1,64 @@ +package simapp + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + moduletypes "github.com/cosmos/cosmos-sdk/regen/types/module" + regenserver "github.com/cosmos/cosmos-sdk/regen/types/module/server" + + "github.com/cosmos/cosmos-sdk/types/module" + + group "github.com/cosmos/cosmos-sdk/x/group/module" +) + +// from regen-ledger: https://github.com/regen-network/regen-ledger/blob/v2.0.0-beta1/app/experimental_appconfig.go + +func setCustomModuleBasics() []module.AppModuleBasic { + return []module.AppModuleBasic{ + group.Module{}, + } +} + +func setCustomKVStoreKeys() []string { + return []string{} +} + +// setCustomModules registers new modules with the server module manager. +func setCustomModules(app *SimApp, interfaceRegistry types.InterfaceRegistry) *regenserver.Manager { + + /* New Module Wiring START */ + newModuleManager := regenserver.NewManager(app.BaseApp, codec.NewProtoCodec(interfaceRegistry)) + + // BEGIN HACK: this is a total, ugly hack until x/auth & x/bank supports ADR 033 or we have a suitable alternative + groupModule := group.Module{AccountKeeper: app.AccountKeeper, BankKeeper: app.BankKeeper} + // use a separate newModules from the global NewModules here because we need to pass state into the group module + newModules := []moduletypes.Module{ + groupModule, + } + err := newModuleManager.RegisterModules(newModules) + if err != nil { + panic(err) + } + // END HACK + + /* New Module Wiring END */ + return newModuleManager +} + +func (app *SimApp) setCustomModuleManager() []module.AppModule { + return []module.AppModule{} +} + +func setCustomOrderInitGenesis() []string { + return []string{} +} + +func (app *SimApp) setCustomSimulationManager() []module.AppModuleSimulation { + return []module.AppModuleSimulation{ + group.Module{ + Registry: app.interfaceRegistry, + BankKeeper: app.BankKeeper, + AccountKeeper: app.AccountKeeper, + }, + } +} diff --git a/x/group/client/client_test.go b/x/group/client/client_test.go new file mode 100644 index 0000000000..d042c25736 --- /dev/null +++ b/x/group/client/client_test.go @@ -0,0 +1,14 @@ +package client_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/regen/types/testutil/network" + "github.com/cosmos/cosmos-sdk/x/group/client/testsuite" + "github.com/stretchr/testify/suite" +) + +func TestIntegrationTestSuite(t *testing.T) { + cfg := network.DefaultConfig() + suite.Run(t, testsuite.NewIntegrationTestSuite(cfg)) +} diff --git a/x/group/client/query.go b/x/group/client/query.go index 5ddfea269d..e92475ab44 100644 --- a/x/group/client/query.go +++ b/x/group/client/query.go @@ -31,6 +31,12 @@ func QueryCmd(name string) *cobra.Command { QueryVoteByProposalVoterCmd(), QueryVotesByProposalCmd(), QueryVotesByVoterCmd(), + QueryPollCmd(), + QueryPollsByGroupCmd(), + QueryPollsByCreatorCmd(), + QueryVoteForPollByPollVoterCmd(), + QueryVotesForPollByPollCmd(), + QueryVotesForPollByVoterCmd(), ) return queryCmd @@ -438,3 +444,228 @@ func QueryVotesByVoterCmd() *cobra.Command { return cmd } + +// QueryPollCmd creates a CLI command for Query/Poll. +func QueryPollCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "poll [id]", + Short: "Query for poll by id", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pollID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.Poll(cmd.Context(), &group.QueryPollRequest{ + PollId: pollID, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryPollsByGroupCmd creates a CLI command for Query/PollsByGroup. +func QueryPollsByGroupCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "polls-by-group [group-id]", + Short: "Query for polls by group id with pagination flags", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + groupID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.PollsByGroup(cmd.Context(), &group.QueryPollsByGroupRequest{ + GroupId: groupID, + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryPollsByCreatorCmd creates a CLI command for Query/PollsByCreator. +func QueryPollsByCreatorCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "polls-by-group [creator]", + Short: "Query for polls by creator address with pagination flags", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.PollsByCreator(cmd.Context(), &group.QueryPollsByCreatorRequest{ + Creator: args[0], + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryVoteForPollByPollVoterCmd creates a CLI command for Query/VoteForPollByPollVoter. +func QueryVoteForPollByPollVoterCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "vote-poll [poll-id] [voter]", + Short: "Query for vote by poll id and voter account address", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pollID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.VoteForPollByPollVoter(cmd.Context(), &group.QueryVoteForPollByPollVoterRequest{ + PollId: pollID, + Voter: args[1], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryVotesForPollByPollCmd creates a CLI command for Query/VotesByProposal. +func QueryVotesForPollByPollCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "votes-by-poll [poll-id]", + Short: "Query for votes by poll id with pagination flags", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pollID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.VotesForPollByPoll(cmd.Context(), &group.QueryVotesForPollByPollRequest{ + PollId: pollID, + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// QueryVotesForPollByVoterCmd creates a CLI command for Query/VotesForPollByVoter. +func QueryVotesForPollByVoterCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "votes-poll-by-voter [voter]", + Short: "Query for votes by voter account address with pagination flags", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := group.NewQueryClient(clientCtx) + + res, err := queryClient.VotesForPollByVoter(cmd.Context(), &group.QueryVotesForPollByVoterRequest{ + Voter: args[0], + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/group/client/testsuite/query.go b/x/group/client/testsuite/query.go index c200857fd4..4475f45cdc 100644 --- a/x/group/client/testsuite/query.go +++ b/x/group/client/testsuite/query.go @@ -2,9 +2,11 @@ package testsuite import ( "fmt" - "github.com/cosmos/cosmos-sdk/regen/types/testutil/cli" "strconv" + "github.com/cosmos/cosmos-sdk/regen/types/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/group" "github.com/cosmos/cosmos-sdk/x/group/client" tmcli "github.com/tendermint/tendermint/libs/cli" @@ -121,12 +123,12 @@ func (s *IntegrationTestSuite) TestQueryGroupMembers() { var res group.QueryGroupMembersResponse s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) - s.Require().Equal(len(res.Members), len(tc.expectMembers)) + s.Require().Equal(len(tc.expectMembers), len(res.Members)) for i := range res.Members { - s.Require().Equal(res.Members[i].GroupId, tc.expectMembers[i].GroupId) - s.Require().Equal(res.Members[i].Member.Address, tc.expectMembers[i].Member.Address) - s.Require().Equal(res.Members[i].Member.Metadata, tc.expectMembers[i].Member.Metadata) - s.Require().Equal(res.Members[i].Member.Weight, tc.expectMembers[i].Member.Weight) + s.Require().Equal(tc.expectMembers[i].GroupId, res.Members[i].GroupId) + s.Require().Equal(tc.expectMembers[i].Member.Address, res.Members[i].Member.Address) + s.Require().Equal(tc.expectMembers[i].Member.Metadata, res.Members[i].Member.Metadata) + s.Require().Equal(tc.expectMembers[i].Member.Weight, res.Members[i].Member.Weight) } } }) @@ -187,13 +189,13 @@ func (s *IntegrationTestSuite) TestQueryGroupsByAdmin() { var res group.QueryGroupsByAdminResponse s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) - s.Require().Equal(len(res.Groups), len(tc.expectGroups)) + s.Require().Equal(len(tc.expectGroups), len(res.Groups)) for i := range res.Groups { - s.Require().Equal(res.Groups[i].GroupId, tc.expectGroups[i].GroupId) - s.Require().Equal(res.Groups[i].Metadata, tc.expectGroups[i].Metadata) - s.Require().Equal(res.Groups[i].Version, tc.expectGroups[i].Version) - s.Require().Equal(res.Groups[i].TotalWeight, tc.expectGroups[i].TotalWeight) - s.Require().Equal(res.Groups[i].Admin, tc.expectGroups[i].Admin) + s.Require().Equal(tc.expectGroups[i].GroupId, res.Groups[i].GroupId) + s.Require().Equal(tc.expectGroups[i].Metadata, res.Groups[i].Metadata) + s.Require().Equal(tc.expectGroups[i].Version, res.Groups[i].Version) + s.Require().Equal(tc.expectGroups[i].TotalWeight, res.Groups[i].TotalWeight) + s.Require().Equal(tc.expectGroups[i].Admin, res.Groups[i].Admin) } } }) @@ -317,13 +319,13 @@ func (s *IntegrationTestSuite) TestQueryGroupAccountsByGroup() { var res group.QueryGroupAccountsByGroupResponse s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) - s.Require().Equal(len(res.GroupAccounts), len(tc.expectGroupAccounts)) + s.Require().Equal(len(tc.expectGroupAccounts), len(res.GroupAccounts)) for i := range res.GroupAccounts { - s.Require().Equal(res.GroupAccounts[i].GroupId, tc.expectGroupAccounts[i].GroupId) - s.Require().Equal(res.GroupAccounts[i].Metadata, tc.expectGroupAccounts[i].Metadata) - s.Require().Equal(res.GroupAccounts[i].Version, tc.expectGroupAccounts[i].Version) - s.Require().Equal(res.GroupAccounts[i].Admin, tc.expectGroupAccounts[i].Admin) - s.Require().Equal(res.GroupAccounts[i].GetDecisionPolicy(), tc.expectGroupAccounts[i].GetDecisionPolicy()) + s.Require().Equal(tc.expectGroupAccounts[i].GroupId, res.GroupAccounts[i].GroupId) + s.Require().Equal(tc.expectGroupAccounts[i].Metadata, res.GroupAccounts[i].Metadata) + s.Require().Equal(tc.expectGroupAccounts[i].Version, res.GroupAccounts[i].Version) + s.Require().Equal(tc.expectGroupAccounts[i].Admin, res.GroupAccounts[i].Admin) + s.Require().Equal(tc.expectGroupAccounts[i].GetDecisionPolicy(), res.GroupAccounts[i].GetDecisionPolicy()) } } }) @@ -388,13 +390,13 @@ func (s *IntegrationTestSuite) TestQueryGroupAccountsByAdmin() { var res group.QueryGroupAccountsByAdminResponse s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) - s.Require().Equal(len(res.GroupAccounts), len(tc.expectGroupAccounts)) + s.Require().Equal(len(tc.expectGroupAccounts), len(res.GroupAccounts)) for i := range res.GroupAccounts { - s.Require().Equal(res.GroupAccounts[i].GroupId, tc.expectGroupAccounts[i].GroupId) - s.Require().Equal(res.GroupAccounts[i].Metadata, tc.expectGroupAccounts[i].Metadata) - s.Require().Equal(res.GroupAccounts[i].Version, tc.expectGroupAccounts[i].Version) - s.Require().Equal(res.GroupAccounts[i].Admin, tc.expectGroupAccounts[i].Admin) - s.Require().Equal(res.GroupAccounts[i].GetDecisionPolicy(), tc.expectGroupAccounts[i].GetDecisionPolicy()) + s.Require().Equal(tc.expectGroupAccounts[i].GroupId, res.GroupAccounts[i].GroupId) + s.Require().Equal(tc.expectGroupAccounts[i].Metadata, res.GroupAccounts[i].Metadata) + s.Require().Equal(tc.expectGroupAccounts[i].Version, res.GroupAccounts[i].Version) + s.Require().Equal(tc.expectGroupAccounts[i].Admin, res.GroupAccounts[i].Admin) + s.Require().Equal(tc.expectGroupAccounts[i].GetDecisionPolicy(), res.GroupAccounts[i].GetDecisionPolicy()) } } }) @@ -498,9 +500,9 @@ func (s *IntegrationTestSuite) TestQueryProposalsByGroupAccount() { var res group.QueryProposalsByGroupAccountResponse s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) - s.Require().Equal(len(res.Proposals), len(tc.expectProposals)) + s.Require().Equal(len(tc.expectProposals), len(res.Proposals)) for i := range res.Proposals { - s.Require().Equal(res.Proposals[i], tc.expectProposals[i]) + s.Require().Equal(tc.expectProposals[i], res.Proposals[i]) } } }) @@ -604,9 +606,9 @@ func (s *IntegrationTestSuite) TestQueryVotesByProposal() { var res group.QueryVotesByProposalResponse s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) - s.Require().Equal(len(res.Votes), len(tc.expectVotes)) + s.Require().Equal(len(tc.expectVotes), len(res.Votes)) for i := range res.Votes { - s.Require().Equal(res.Votes[i], tc.expectVotes[i]) + s.Require().Equal(tc.expectVotes[i], res.Votes[i]) } } }) @@ -667,9 +669,299 @@ func (s *IntegrationTestSuite) TestQueryVotesByVoter() { var res group.QueryVotesByVoterResponse s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) - s.Require().Equal(len(res.Votes), len(tc.expectVotes)) + s.Require().Equal(len(tc.expectVotes), len(res.Votes)) + for i := range res.Votes { + s.Require().Equal(tc.expectVotes[i], res.Votes[i]) + } + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryPoll() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + }{ + { + "not found", + []string{"12345", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "not found", + 0, + }, + { + "invalid poll id", + []string{"", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "strconv.ParseUint: parsing \"\": invalid syntax", + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryPollCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryPollsByGroup() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + expectPolls []*group.Poll + }{ + { + "invalid group id", + []string{"abcd", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "invalid syntax", + 0, + []*group.Poll{}, + }, + { + "not found", + []string{"12345", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "", + 0, + []*group.Poll{}, + }, + { + "found polls", + []string{fmt.Sprintf("%d", s.pollBls.GroupId), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.Poll{ + s.pollBls, + }, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryPollsByGroupCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + + var res group.QueryPollsByGroupResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) + s.Require().Equal(len(tc.expectPolls), len(res.Polls)) + for i := range res.Polls { + s.Require().Equal(tc.expectPolls[i], res.Polls[i]) + } + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryVoteForPollByPollVoter() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + aliceInfo, err := clientCtx.Keyring.Key("alice") + s.Require().NoError(err) + aliceAddr := sdk.AccAddress(aliceInfo.GetPubKey().Address()) + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + }{ + { + "all good", + []string{"1", aliceAddr.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + }, + { + "invalid voter address", + []string{"1", "invalid", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "decoding bech32 failed: invalid bech32", + 0, + }, + { + "invalid poll id", + []string{"", aliceAddr.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "strconv.ParseUint: parsing \"\": invalid syntax", + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryVoteForPollByPollVoterCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryVotesForPollByPoll() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + expectVotes []*group.VotePoll + }{ + { + "invalid proposal id", + []string{"", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "strconv.ParseUint: parsing \"\": invalid syntax", + 0, + []*group.VotePoll{}, + }, + { + "no votes", + []string{"12345", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.VotePoll{}, + }, + { + "found votes", + []string{"1", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.VotePoll{ + s.votePoll, + }, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryVotesForPollByPollCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + + var res group.QueryVotesForPollByPollResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) + s.Require().Equal(len(tc.expectVotes), len(res.Votes)) + for i := range res.Votes { + s.Require().Equal(tc.expectVotes[i], res.Votes[i]) + } + } + }) + } +} + +func (s *IntegrationTestSuite) TestQueryVotesForPollByVoter() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + aliceInfo, err := clientCtx.Keyring.Key("alice") + s.Require().NoError(err) + aliceAddr := sdk.AccAddress(aliceInfo.GetPubKey().Address()) + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + expectedCode uint32 + expectVotes []*group.VotePoll + }{ + { + "invalid voter address", + []string{"abcd", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "decoding bech32 failed: invalid bech32", + 0, + []*group.VotePoll{}, + }, + { + "no votes", + []string{s.groupAccounts[0].Address, fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + true, + "", + 0, + []*group.VotePoll{}, + }, + { + "found votes", + []string{aliceAddr.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + "", + 0, + []*group.VotePoll{ + s.votePoll, + }, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.QueryVotesForPollByVoterCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + + var res group.QueryVotesForPollByVoterResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) + s.Require().Equal(len(tc.expectVotes), len(res.Votes)) for i := range res.Votes { - s.Require().Equal(res.Votes[i], tc.expectVotes[i]) + s.Require().Equal(tc.expectVotes[i], res.Votes[i]) } } }) diff --git a/x/group/client/testsuite/tx.go b/x/group/client/testsuite/tx.go index 84a4d51bb8..819e32a4ed 100644 --- a/x/group/client/testsuite/tx.go +++ b/x/group/client/testsuite/tx.go @@ -4,6 +4,9 @@ import ( "fmt" "strconv" "strings" + "time" + + gogotypes "github.com/gogo/protobuf/types" tmcli "github.com/tendermint/tendermint/libs/cli" @@ -31,8 +34,16 @@ type IntegrationTestSuite struct { group *group.GroupInfo groupAccounts []*group.GroupAccountInfo - proposal *group.Proposal - vote *group.Vote + + groupBls *group.GroupInfo + groupAccountsBls []*group.GroupAccountInfo + + proposal *group.Proposal + vote *group.Vote + + proposalBls *group.Proposal + pollBls *group.Poll + votePoll *group.VotePoll } const validMetadata = "AQ==" @@ -68,6 +79,57 @@ func (s *IntegrationTestSuite) SetupSuite() { ) s.Require().NoError(err) + // Create new bls account in the keyring. + aliceInfo, _, err := val.ClientCtx.Keyring.NewMnemonic("alice", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Bls12381) + s.Require().NoError(err) + aliceAddr := sdk.AccAddress(aliceInfo.GetPubKey().Address()) + _, err = banktestutil.MsgSendExec( + val.ClientCtx, + val.Address, + aliceAddr, + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(2000))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + ) + s.Require().NoError(err) + + // perform a transaction to set pop for bls public key + bobInfo, _, err := val.ClientCtx.Keyring.NewMnemonic("bob", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Bls12381) + s.Require().NoError(err) + bobAddr := sdk.AccAddress(bobInfo.GetPubKey().Address()) + _, err = banktestutil.MsgSendExec( + val.ClientCtx, + aliceAddr, + bobAddr, + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1000))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + ) + s.Require().NoError(err) + + charlieInfo, _, err := val.ClientCtx.Keyring.NewMnemonic("charlie", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Bls12381) + s.Require().NoError(err) + charlieAddr := sdk.AccAddress(charlieInfo.GetPubKey().Address()) + _, err = banktestutil.MsgSendExec( + val.ClientCtx, + bobAddr, + charlieAddr, + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(800))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + ) + s.Require().NoError(err) + + _, err = banktestutil.MsgSendExec( + val.ClientCtx, + charlieAddr, + bobAddr, + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(300))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + ) + s.Require().NoError(err) + var commonFlags = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), @@ -75,11 +137,7 @@ func (s *IntegrationTestSuite) SetupSuite() { } // create a group - validMembers := fmt.Sprintf(`{"members": [{ - "address": "%s", - "weight": "3", - "metadata": "%s" - }]}`, val.Address.String(), validMetadata) + validMembers := fmt.Sprintf(`{"members":[{"address":"%s","weight":"3","metadata":"%s"}]}`, val.Address.String(), validMetadata) validMembersFile := testutil.WriteToNewTempFile(s.T(), validMembers) out, err := cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateGroupCmd(), append( @@ -176,6 +234,161 @@ func (s *IntegrationTestSuite) SetupSuite() { var voteRes group.QueryVoteByProposalVoterResponse s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &voteRes)) s.vote = voteRes.Vote + + // Create a bls-only group + validBlsMembers := fmt.Sprintf(`{"members": [ + { + "address": "%s", + "weight": "1", + "metadata": "%s" + }, + { + "address": "%s", + "weight": "2", + "metadata": "%s" + }, + { + "address": "%s", + "weight": "3", + "metadata": "%s" + }]}`, aliceAddr.String(), validMetadata, bobAddr.String(), validMetadata, charlieAddr.String(), validMetadata) + validBlsMembersFile := testutil.WriteToNewTempFile(s.T(), validBlsMembers) + + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateGroupCmd(), + append( + []string{ + aliceAddr.String(), + validMetadata, + validBlsMembersFile.Name(), + fmt.Sprintf("--%s", client.FlagBlsOnly), + }, + commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + s.groupBls = &group.GroupInfo{GroupId: 2, Admin: aliceAddr.String(), Metadata: []byte{1}, TotalWeight: "6", Version: 1} + + // create 5 group accounts + for i := 0; i < 5; i++ { + threshold := i + 1 + if threshold > 4 { + threshold = 4 + } + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateGroupAccountCmd(), + append( + []string{ + aliceAddr.String(), + "2", + validMetadata, + fmt.Sprintf("{\"@type\":\"/regen.group.v1alpha1.ThresholdDecisionPolicy\", \"threshold\":\"%d\", \"timeout\":\"30000s\"}", threshold), + }, + commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.QueryGroupAccountsByGroupCmd(), []string{"2", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) + s.Require().NoError(err, out.String()) + } + + var resBls group.QueryGroupAccountsByGroupResponse + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &resBls)) + s.Require().Equal(len(resBls.GroupAccounts), 5) + s.groupAccountsBls = resBls.GroupAccounts + + // give group account 0 some balance + blsAddr0, err := sdk.AccAddressFromBech32(s.groupAccountsBls[0].Address) + s.Require().NoError(err) + _, err = banktestutil.MsgSendExec( + val.ClientCtx, + val.Address, + blsAddr0, + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(2000))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + ) + s.Require().NoError(err) + + // create a proposal for bls group + validTxFileNameBls := getTxSendFileName(s, s.groupAccountsBls[0].Address, aliceAddr.String()) + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateProposalCmd(), + append( + []string{ + s.groupAccountsBls[0].Address, + aliceAddr.String(), + validTxFileNameBls, + "", + fmt.Sprintf("--%s=%s", flags.FlagFrom, aliceAddr.String()), + }, + commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.QueryProposalCmd(), []string{"2", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &proposalRes)) + s.proposalBls = proposalRes.Proposal + + // create a poll for bls group + now := time.Now() + expiryTime := now.Add(time.Second * 3000) + expiry, err := gogotypes.TimestampProto(expiryTime) + s.Require().NoError(err) + expiryStr := expiry.String() + + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreatePollCmd(), + append( + []string{ + aliceAddr.String(), + "2", + "2022 Election", + "alice,bob,charlie,linda,tom", + "2", + expiryStr, + "", + }, + commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + // vote-poll + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgVotePollCmd(), + append( + []string{ + "1", + aliceAddr.String(), + "alice,linda", + "", + }, + commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + var pollRes group.QueryPollResponse + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.QueryPollCmd(), []string{"1", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &pollRes)) + s.pollBls = pollRes.Poll + + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.QueryVoteForPollByPollVoterCmd(), []string{"1", aliceAddr.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) + s.Require().NoError(err, out.String()) + var votePollRes group.QueryVoteForPollByPollVoterResponse + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &votePollRes)) + s.votePoll = votePollRes.Vote } func (s *IntegrationTestSuite) TearDownSuite() { @@ -382,7 +595,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAdmin() { append( []string{ val.Address.String(), - "3", + "4", s.network.Validators[1].Address.String(), }, commonFlags..., @@ -397,7 +610,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAdmin() { append( []string{ val.Address.String(), - "4", + "5", s.network.Validators[1].Address.String(), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, @@ -483,7 +696,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMetadata() { append( []string{ val.Address.String(), - "2", + "3", validMetadata, }, commonFlags..., @@ -498,7 +711,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMetadata() { append( []string{ val.Address.String(), - "2", + "3", validMetadata, fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, @@ -520,7 +733,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMetadata() { commonFlags..., ), true, - "group metadata: limit exceeded", + "metadata: limit exceeded", nil, 0, }, @@ -586,7 +799,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMembers() { append( []string{ val.Address.String(), - "2", + "3", validUpdatedMembersFileName, }, commonFlags..., @@ -601,7 +814,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMembers() { append( []string{ val.Address.String(), - "2", + "3", testutil.WriteToNewTempFile(s.T(), fmt.Sprintf(`{"members": [{ "address": "%s", "weight": "2", @@ -627,7 +840,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMembers() { commonFlags..., ), true, - "group member metadata: limit exceeded", + "member metadata: limit exceeded", nil, 0, }, @@ -750,7 +963,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupAccount() { commonFlags..., ), true, - "group account metadata: limit exceeded", + "metadata: limit exceeded", &sdk.TxResponse{}, 0, }, @@ -1355,7 +1568,7 @@ func (s *IntegrationTestSuite) TestTxVote() { "correct data", append( []string{ - "2", + "3", val.Address.String(), "CHOICE_YES", "", @@ -1371,7 +1584,7 @@ func (s *IntegrationTestSuite) TestTxVote() { "with try exec", append( []string{ - "7", + "8", val.Address.String(), "CHOICE_YES", "", @@ -1388,7 +1601,7 @@ func (s *IntegrationTestSuite) TestTxVote() { "with try exec, not enough yes votes for proposal to pass", append( []string{ - "8", + "9", val.Address.String(), "CHOICE_NO", "", @@ -1405,7 +1618,7 @@ func (s *IntegrationTestSuite) TestTxVote() { "with amino-json", append( []string{ - "5", + "6", val.Address.String(), "CHOICE_YES", "", @@ -1454,7 +1667,7 @@ func (s *IntegrationTestSuite) TestTxVote() { "metadata too long", append( []string{ - "2", + "3", val.Address.String(), "CHOICE_YES", "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ==", @@ -1470,7 +1683,7 @@ func (s *IntegrationTestSuite) TestTxVote() { "invalid choice", append( []string{ - "2", + "3", val.Address.String(), "INVALID_CHOICE", "", @@ -1504,6 +1717,150 @@ func (s *IntegrationTestSuite) TestTxVote() { } } +func (s *IntegrationTestSuite) TestTxVoteAgg() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + aliceInfo, err := clientCtx.Keyring.Key("alice") + s.Require().NoError(err) + aliceAddr := sdk.AccAddress(aliceInfo.GetPubKey().Address()) + + bobInfo, err := clientCtx.Keyring.Key("bob") + s.Require().NoError(err) + bobAddr := sdk.AccAddress(bobInfo.GetPubKey().Address()) + + charlieInfo, err := clientCtx.Keyring.Key("charlie") + s.Require().NoError(err) + charlieAddr := sdk.AccAddress(charlieInfo.GetPubKey().Address()) + + // query group members + cmd := client.QueryGroupMembersCmd() + out, err := cli.ExecTestCLICmd(clientCtx, cmd, []string{strconv.FormatUint(s.groupBls.GroupId, 10), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) + var res group.QueryGroupMembersResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) + fileGroupMembers := testutil.WriteToNewTempFile(s.T(), out.String()).Name() + + // create a proposal for bls group + var txResp = sdk.TxResponse{} + validTxFileNameBls := getTxSendFileName(s, s.groupAccountsBls[3].Address, aliceAddr.String()) + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateProposalCmd(), + append( + []string{ + s.groupAccountsBls[3].Address, + aliceAddr.String(), + validTxFileNameBls, + "", + fmt.Sprintf("--%s=%s", flags.FlagFrom, aliceAddr.String()), + }, + commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + voteFlags := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + + now := time.Now() + expiryTime := now.Add(time.Second * 30) + expiry, err := gogotypes.TimestampProto(expiryTime) + s.Require().NoError(err) + expiryStr := expiry.String() + + // basic vote from alice + cmd = client.GetVoteBasicCmd() + out, err = cli.ExecTestCLICmd(clientCtx, cmd, + append( + []string{ + aliceAddr.String(), + "2", + expiryStr, + "CHOICE_YES", + }, + voteFlags..., + ), + ) + aliceVoteYes := testutil.WriteToNewTempFile(s.T(), out.String()).Name() + + cmd = client.GetVerifyVoteBasicCmd() + out, err = cli.ExecTestCLICmd(clientCtx, cmd, []string{aliceVoteYes}) + s.Require().NoError(err) + + // basic vote from bob + cmd = client.GetVoteBasicCmd() + out, err = cli.ExecTestCLICmd(clientCtx, cmd, + append( + []string{ + bobAddr.String(), + "2", + expiryStr, + "CHOICE_NO", + }, + voteFlags..., + ), + ) + bobVoteNo := testutil.WriteToNewTempFile(s.T(), out.String()).Name() + + cmd = client.GetVerifyVoteBasicCmd() + out, err = cli.ExecTestCLICmd(clientCtx, cmd, []string{bobVoteNo}) + s.Require().NoError(err) + + // basic vote from charlie + cmd = client.GetVoteBasicCmd() + out, err = cli.ExecTestCLICmd(clientCtx, cmd, + append( + []string{ + charlieAddr.String(), + "2", + expiryStr, + "CHOICE_YES", + }, + voteFlags..., + ), + ) + charlieVoteYes := testutil.WriteToNewTempFile(s.T(), out.String()).Name() + cmd = client.GetVerifyVoteBasicCmd() + out, err = cli.ExecTestCLICmd(clientCtx, cmd, []string{charlieVoteYes}) + s.Require().NoError(err) + + // aggregate everyone's vote + cmd = client.MsgVoteAggCmd() + voteAggFlags := append(commonFlags, fmt.Sprintf("--%s=try", client.FlagExec)) + out, err = cli.ExecTestCLICmd(clientCtx, cmd, + append( + []string{ + aliceAddr.String(), + "2", + expiryStr, + fileGroupMembers, + aliceVoteYes, + bobVoteNo, + charlieVoteYes, + }, + voteAggFlags..., + ), + ) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + var proposalRes group.QueryProposalResponse + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.QueryProposalCmd(), []string{"2", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &proposalRes)) + s.Require().Equal(proposalRes.Proposal.Status, group.ProposalStatusClosed) + s.Require().Equal(proposalRes.Proposal.Result, group.ProposalResultAccepted) + s.Require().Equal(proposalRes.Proposal.ExecutorResult, group.ProposalExecutorResultSuccess) +} + func (s *IntegrationTestSuite) TestTxExec() { val := s.network.Validators[0] clientCtx := val.ClientCtx @@ -1515,7 +1872,7 @@ func (s *IntegrationTestSuite) TestTxExec() { } // create proposals and vote - for i := 3; i <= 4; i++ { + for i := 4; i <= 5; i++ { validTxFileName := getTxSendFileName(s, s.groupAccounts[0].Address, val.Address.String()) out, err := cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateProposalCmd(), append( @@ -1557,7 +1914,7 @@ func (s *IntegrationTestSuite) TestTxExec() { "correct data", append( []string{ - "3", + "4", fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), }, commonFlags..., @@ -1571,7 +1928,7 @@ func (s *IntegrationTestSuite) TestTxExec() { "with amino-json", append( []string{ - "4", + "5", fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, @@ -1632,6 +1989,489 @@ func (s *IntegrationTestSuite) TestTxExec() { } } +func (s *IntegrationTestSuite) TestTxCreatePoll() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + aliceInfo, err := clientCtx.Keyring.Key("alice") + s.Require().NoError(err) + aliceAddr := sdk.AccAddress(aliceInfo.GetPubKey().Address()) + + now := time.Now() + deadline := now.Add(time.Second * 3000) + timeout, err := gogotypes.TimestampProto(deadline) + s.Require().NoError(err) + timeoutStr := timeout.String() + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + expectedCode uint32 + }{ + { + "correct data", + append( + []string{ + aliceAddr.String(), + "2", + "2023 Election", + "alice,bob,charlie,eva", + "2", + timeoutStr, + validMetadata, + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "poll expired", + append( + []string{ + aliceAddr.String(), + "2", + "2022 Election", + "alice,bob,charlie", + "2", + "2021-08-15T12:00:00Z", + validMetadata, + }, + commonFlags..., + ), + true, + "deadline of the poll has passed", + nil, + 0, + }, + { + "title too long", + append( + []string{ + aliceAddr.String(), + "2", + "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ==", + "alice,bob,charlie", + "2", + timeoutStr, + validMetadata, + }, + commonFlags..., + ), + true, + "poll title: limit exceeded", + nil, + 0, + }, + { + "metadata too long", + append( + []string{ + aliceAddr.String(), + "2", + "2022 Election", + "alice,bob,charlie", + "2", + timeoutStr, + "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ==", + }, + commonFlags..., + ), + true, + "metadata: limit exceeded", + nil, + 0, + }, + { + "invalid creator", + append( + []string{ + "invalid", + "2", + "2022 Election", + "alice,bob,charlie", + "2", + timeoutStr, + "", + }, + commonFlags..., + ), + true, + "invalid.info: key not found", + nil, + 0, + }, + { + "invalid group id", + append( + []string{ + aliceAddr.String(), + "invalid", + "2022 Election", + "alice,bob,charlie,linda,tom", + "2", + timeoutStr, + validMetadata, + }, + commonFlags..., + ), + true, + "strconv.ParseUint: parsing", + nil, + 0, + }, + { + "invalid limit", + append( + []string{ + aliceAddr.String(), + "2", + "2022 Election", + "alice,bob,charlie", + "5", + timeoutStr, + validMetadata, + }, + commonFlags..., + ), + true, + "vote limit exceeds the number of options: invalid value", + nil, + 0, + }, + { + "repeated options", + append( + []string{ + aliceAddr.String(), + "2", + "2022 Election", + "alice,bob,bob", + "2", + timeoutStr, + validMetadata, + }, + commonFlags..., + ), + true, + "duplicate value", + nil, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.MsgCreatePollCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestTxVotePoll() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + aliceInfo, err := clientCtx.Keyring.Key("alice") + s.Require().NoError(err) + aliceAddr := sdk.AccAddress(aliceInfo.GetPubKey().Address()) + + testCases := []struct { + name string + args []string + expectErr bool + expectErrMsg string + respType proto.Message + expectedCode uint32 + }{ + { + "correct data", + append( + []string{ + "2", + aliceAddr.String(), + "alice,bob", + "", + }, + commonFlags..., + ), + false, + "", + &sdk.TxResponse{}, + 0, + }, + { + "invalid poll id", + append( + []string{ + "abcd", + aliceAddr.String(), + "alice,bob", + "", + }, + commonFlags..., + ), + true, + "invalid syntax", + nil, + 0, + }, + { + "poll not found", + append( + []string{ + "1234", + aliceAddr.String(), + "alice,bob", + "", + }, + commonFlags..., + ), + true, + "load poll: not found", + nil, + 0, + }, + { + "metadata too long", + append( + []string{ + "1", + aliceAddr.String(), + "alice,bob", + "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ==", + }, + commonFlags..., + ), + true, + "metadata: limit exceeded", + nil, + 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := client.MsgVotePollCmd() + + out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Contains(out.String(), tc.expectErrMsg) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestTxVotePollAgg() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + var commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + aliceInfo, err := clientCtx.Keyring.Key("alice") + s.Require().NoError(err) + aliceAddr := sdk.AccAddress(aliceInfo.GetPubKey().Address()) + + bobInfo, err := clientCtx.Keyring.Key("bob") + s.Require().NoError(err) + bobAddr := sdk.AccAddress(bobInfo.GetPubKey().Address()) + + charlieInfo, err := clientCtx.Keyring.Key("charlie") + s.Require().NoError(err) + charlieAddr := sdk.AccAddress(charlieInfo.GetPubKey().Address()) + + // query group members + cmd := client.QueryGroupMembersCmd() + out, err := cli.ExecTestCLICmd(clientCtx, cmd, []string{strconv.FormatUint(s.groupBls.GroupId, 10), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) + var res group.QueryGroupMembersResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) + fileGroupMembers := testutil.WriteToNewTempFile(s.T(), out.String()).Name() + + now := time.Now() + timeout, err := gogotypes.TimestampProto(now.Add(time.Second * 3000)) + s.Require().NoError(err) + + expiry, err := gogotypes.TimestampProto(now.Add(time.Second * 1000)) + s.Require().NoError(err) + expiryStr := expiry.String() + + // create a poll for bls group + var txResp = sdk.TxResponse{} + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreatePollCmd(), + append( + []string{ + aliceAddr.String(), + "2", + "2024 Election", + "alice,bob,clare,david,eva,fred,george", + "3", + timeout.String(), + "", + }, + commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + voteFlags := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + + pollID := "3" + + // basic vote from alice + cmd = client.GetVotePollBasicCmd() + out, err = cli.ExecTestCLICmd(clientCtx, cmd, + append( + []string{ + aliceAddr.String(), + pollID, + expiryStr, + "alice", + "david", + "eva", + }, + voteFlags..., + ), + ) + s.Require().NoError(err) + aliceVote := testutil.WriteToNewTempFile(s.T(), out.String()).Name() + + cmd = client.GetVerifyVotePollBasicCmd() + out, err = cli.ExecTestCLICmd(clientCtx, cmd, []string{aliceVote}) + s.Require().NoError(err) + + // basic vote from bob + cmd = client.GetVotePollBasicCmd() + out, err = cli.ExecTestCLICmd(clientCtx, cmd, + append( + []string{ + bobAddr.String(), + pollID, + expiryStr, + "bob", + "david", + }, + voteFlags..., + ), + ) + s.Require().NoError(err) + bobVote := testutil.WriteToNewTempFile(s.T(), out.String()).Name() + + cmd = client.GetVerifyVotePollBasicCmd() + out, err = cli.ExecTestCLICmd(clientCtx, cmd, []string{bobVote}) + s.Require().NoError(err) + + // basic vote from charlie + cmd = client.GetVotePollBasicCmd() + out, err = cli.ExecTestCLICmd(clientCtx, cmd, + append( + []string{ + charlieAddr.String(), + pollID, + expiryStr, + "david", + "eva", + }, + voteFlags..., + ), + ) + s.Require().NoError(err) + charlieVote := testutil.WriteToNewTempFile(s.T(), out.String()).Name() + cmd = client.GetVerifyVotePollBasicCmd() + out, err = cli.ExecTestCLICmd(clientCtx, cmd, []string{charlieVote}) + s.Require().NoError(err) + + // aggregate everyone's vote + cmd = client.MsgVotePollAggCmd() + out, err = cli.ExecTestCLICmd(clientCtx, cmd, + append( + []string{ + aliceAddr.String(), + pollID, + expiryStr, + fileGroupMembers, + aliceVote, + bobVote, + charlieVote, + }, + commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + var pollRes group.QueryPollResponse + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.QueryPollCmd(), []string{pollID, fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &pollRes)) + s.Require().Equal(pollRes.Poll.Status, group.PollStatusSubmitted) + s.Require().Equal(pollRes.Poll.VoteState.Counts, map[string]string{ + "alice": "1", "bob": "2", "david": "6", "eva": "4", + }) + + // test invalid + // duplicate options in basic votes + cmd = client.GetVotePollBasicCmd() + out, err = cli.ExecTestCLICmd(clientCtx, cmd, + append( + []string{ + aliceAddr.String(), + pollID, + expiryStr, + "alice", + "alice", + }, + voteFlags..., + ), + ) + s.Require().Contains(err.Error(), "duplicate value") +} + func getTxSendFileName(s *IntegrationTestSuite, from string, to string) string { tx := fmt.Sprintf( `{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"%s","to_address":"%s","amount":[{"denom":"%s","amount":"10"}]}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}`, diff --git a/x/group/client/tx.go b/x/group/client/tx.go index a36c42e706..b18254bd7e 100644 --- a/x/group/client/tx.go +++ b/x/group/client/tx.go @@ -1,17 +1,16 @@ package client import ( - "bytes" "encoding/base64" "fmt" - - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "sort" "strconv" "strings" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" + "github.com/gogo/protobuf/types" tmcli "github.com/tendermint/tendermint/libs/cli" @@ -54,11 +53,16 @@ func TxCmd(name string) *cobra.Command { MsgUpdateGroupAccountDecisionPolicyCmd(), MsgUpdateGroupAccountMetadataCmd(), MsgCreateProposalCmd(), + MsgCreatePollCmd(), MsgVoteCmd(), - MsgExecCmd(), MsgVoteAggCmd(), + MsgExecCmd(), + MsgVotePollCmd(), + MsgVotePollAggCmd(), GetVoteBasicCmd(), GetVerifyVoteBasicCmd(), + GetVotePollBasicCmd(), + GetVerifyVotePollBasicCmd(), ) return txCmd @@ -557,6 +561,90 @@ Parameters: return cmd } +// MsgCreatePollCmd creates a CLI command for Msg/CreatePoll. +func MsgCreatePollCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-poll [creator] [group-id] [title] [option[,option]*] [vote-limit] [timeout] [metadata]", + Short: "Submit a new poll", + Long: `Submit a new poll. + +Parameters: + group-id: unique id of the group + title: title of the poll + option: comma separated (no spaces) list of options. Example: "option1,option2" + vote-limit: number of options each voter can choose + time-out: deadline for voting the poll + Metadata: metadata for the poll +`, + Args: cobra.ExactArgs(7), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + groupID, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } + + title := args[2] + + optionTitles := strings.Split(args[3], ",") + for i := range optionTitles { + optionTitles[i] = strings.TrimSpace(optionTitles[i]) + } + options := group.Options{Titles: optionTitles} + + voteLimit, err := strconv.ParseInt(args[4], 10, 32) + if err != nil { + return err + } + + timeString := fmt.Sprintf("\"%s\"", args[5]) + var timeout types.Timestamp + err = clientCtx.Codec.UnmarshalJSON([]byte(timeString), &timeout) + if err != nil { + return err + } + timeNow := gogotypes.TimestampNow() + if timeout.Compare(timeNow) <= 0 { + return fmt.Errorf("deadline of the poll has passed") + } + + b, err := base64.StdEncoding.DecodeString(args[6]) + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "metadata is malformed, proper base64 string is required") + } + + msg := &group.MsgCreatePoll{ + GroupId: groupID, + Title: title, + Options: options, + Creator: args[0], + VoteLimit: int32(voteLimit), + Metadata: b, + Timeout: timeout, + } + if err = msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(FlagExec, "", "Set to 1 to try to execute proposal immediately after creation (proposers signatures are considered as Yes votes)") + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + // MsgVoteCmd creates a CLI command for Msg/Vote. func MsgVoteCmd() *cobra.Command { cmd := &cobra.Command{ @@ -669,7 +757,7 @@ func MsgExecCmd() *cobra.Command { func MsgVoteAggCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "vote-agg [sender] [propsal_id] [timeout] [group-members-json-file] [[vote-json-file]...]", + Use: "vote-agg [sender] [proposal_id] [timeout] [group-members-json-file] [[vote-json-file]...]", Short: "Aggregate signatures of basic votes into aggregated signature and submit the combined votes", Long: `Aggregate signatures of basic votes into aggregated signature and submit the combined votes. @@ -718,6 +806,16 @@ Parameters: } } + // make sure group members are sorted by their addresses + sorted := sort.SliceIsSorted(groupMembers, func(i, j int) bool { + return groupMembers[i].Member.Address < groupMembers[j].Member.Address + }) + if !sorted { + sort.Slice(groupMembers, func(i, j int) bool { + return groupMembers[i].Member.Address < groupMembers[j].Member.Address + }) + } + index := make(map[string]int, len(groupMembers)) for i, mem := range groupMembers { addr := mem.Member.Address @@ -739,7 +837,7 @@ Parameters: return err } - if vote.ProposalId != proposalID || !vote.Timeout.Equal(timeout) { + if vote.ProposalId != proposalID || !vote.Expiry.Equal(timeout) { return fmt.Errorf("invalid vote from %s: expected proposal id %d and timeout %s", vote.Voter, proposalID, timeout.String()) } @@ -757,13 +855,201 @@ Parameters: return err } + execStr, _ := cmd.Flags().GetString(FlagExec) + msg := &group.MsgVoteAgg{ Sender: args[0], ProposalId: proposalID, Votes: votes, - Timeout: timeout, + Expiry: timeout, AggSig: sigma, Metadata: nil, + Exec: execFromString(execStr), + } + + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(FlagExec, "", "Set to 1 to try to execute proposal immediately after voting") + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// MsgVotePollCmd creates a CLI command for Msg/Vote. +func MsgVotePollCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "vote-poll [poll-id] [voter] [option[,option]*] [metadata]", + Short: "Vote on a poll", + Long: `Vote on a poll. + +Parameters: + poll-id: unique ID of the poll + voter: voter account addresses. + option: options chosen by the voter + Metadata: metadata for the vote +`, + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[1]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + pollID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + optionTitles := strings.Split(args[2], ",") + for i := range optionTitles { + optionTitles[i] = strings.TrimSpace(optionTitles[i]) + } + options := group.Options{Titles: optionTitles} + + b, err := base64.StdEncoding.DecodeString(args[3]) + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "metadata is malformed, proper base64 string is required") + } + + msg := &group.MsgVotePoll{ + PollId: pollID, + Voter: args[1], + Options: options, + Metadata: b, + } + if err != nil { + return err + } + + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func MsgVotePollAggCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "vote-poll-agg [sender] [poll_id] [expiry] [group-members-json-file] [[vote-json-file]...]", + Short: "Aggregate signatures of basic votes into aggregated signature and submit the combined votes", + Long: `Aggregate signatures of basic votes into aggregated signature and submit the combined votes. + +Parameters: + sender: sender's account address + poll-id: unique ID of the poll + timeout: UTC time for the submission deadline of the aggregated vote, e.g., 2021-08-15T12:00:00Z + group-members-json-file: path to json file that contains group members + vote-json-file: path to json file that contains a basic vote with a verified signature +`, + Args: cobra.MinimumNArgs(5), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + pollID, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } + + timeString := fmt.Sprintf("\"%s\"", args[2]) + var timeout types.Timestamp + err = clientCtx.Codec.UnmarshalJSON([]byte(timeString), &timeout) + if err != nil { + return err + } + timeNow := gogotypes.TimestampNow() + if timeout.Compare(timeNow) <= 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "deadline for submitting the vote has passed") + } + + groupMembers, err := parseGroupMembers(clientCtx, args[3]) + if err != nil { + return err + } + for _, mem := range groupMembers { + if err = mem.ValidateBasic(); err != nil { + return err + } + } + + // make sure group members are sorted by their addresses + sorted := sort.SliceIsSorted(groupMembers, func(i, j int) bool { + return groupMembers[i].Member.Address < groupMembers[j].Member.Address + }) + if !sorted { + sort.Slice(groupMembers, func(i, j int) bool { + return groupMembers[i].Member.Address < groupMembers[j].Member.Address + }) + } + + index := make(map[string]int, len(groupMembers)) + for i, mem := range groupMembers { + addr := mem.Member.Address + if _, exists := index[addr]; exists { + return fmt.Errorf("duplicate address: %s", addr) + } + index[addr] = i + } + + votes := make([]group.Options, len(groupMembers)) + + var sigs [][]byte + for i := 4; i < len(args); i++ { + vote, err := parseVotePollBasic(clientCtx, args[i]) + if err != nil { + return err + } + + if vote.PollId != pollID || !vote.Expiry.Equal(timeout) { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, + "invalid vote from %s: expect poll id %d and timeout %s", vote.Voter, pollID, timeout.String()) + } + + memIndex, ok := index[vote.Voter] + if !ok { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "voter %s", vote.Voter) + } + + votes[memIndex] = vote.Options + sigs = append(sigs, vote.Sig) + } + + sigma, err := bls12381.AggregateSignature(sigs) + if err != nil { + return err + } + + msg := &group.MsgVotePollAgg{ + Sender: args[0], + PollId: pollID, + Votes: votes, + Expiry: timeout, + AggSig: sigma, + Metadata: []byte(fmt.Sprintf("submitted as aggregated vote by account %s", args[0])), } if err = msg.ValidateBasic(); err != nil { @@ -782,7 +1068,7 @@ Parameters: // GetVoteBasicCmd creates a CLI command for Msg/VoteBasic. func GetVoteBasicCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "vote-basic [voter] [proposal-id] [choice] [timeout]", + Use: "vote-basic [voter] [proposal-id] [expiry] [choice]", Short: "Vote on a proposal", Long: `Vote on a proposal and the vote will be aggregated with other votes. @@ -814,27 +1100,27 @@ Parameters: return err } - choice, err := group.ChoiceFromString(args[2]) - if err != nil { - return err - } - - timeString := fmt.Sprintf("\"%s\"", args[3]) - var timeout types.Timestamp - err = clientCtx.Codec.UnmarshalJSON([]byte(timeString), &timeout) + timeString := fmt.Sprintf("\"%s\"", args[2]) + var expiry types.Timestamp + err = clientCtx.Codec.UnmarshalJSON([]byte(timeString), &expiry) if err != nil { return err } timeNow := gogotypes.TimestampNow() - if timeout.Compare(timeNow) <= 0 { + if expiry.Compare(timeNow) <= 0 { return fmt.Errorf("deadline for submitting the vote has passed") } + choice, err := group.ChoiceFromString(args[3]) + if err != nil { + return err + } + msg := &group.MsgVoteBasic{ ProposalId: proposalID, Choice: choice, - Timeout: timeout, + Expiry: expiry, } if err = msg.ValidateBasic(); err != nil { @@ -852,7 +1138,7 @@ Parameters: vote := &group.MsgVoteBasicResponse{ ProposalId: proposalID, Choice: choice, - Timeout: timeout, + Expiry: expiry, Voter: args[0], PubKey: pubKeyAny, Sig: sigBytes, @@ -891,26 +1177,155 @@ Parameters: } if err = vote.ValidateBasic(); err != nil { - return fmt.Errorf("message validation failed: %w", err) + return err + } + + if err = vote.VerifySignature(); err != nil { + return err } - msgBytes := vote.GetSignBytes() + cmd.Println("Verification Successful!") + + return nil + }, + } + + return cmd +} + +// GetVotePollBasicCmd creates a CLI command for Msg/VotePollBasic. +func GetVotePollBasicCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "vote-poll-basic [voter] [poll-id] [expiry] [[option]...] ", + Short: "Vote on a poll", + Long: `Vote on a proposal and the vote will be aggregated with other votes. - pubKey, ok := vote.PubKey.GetCachedValue().(cryptotypes.PubKey) - if !ok { - return fmt.Errorf("failed to get public key") +Parameters: + voter: voter account addresses. + proposal-id: unique ID of the proposal + timeout: UTC time for the submission deadline of the vote, e.g., 2021-08-15T12:00:00Z + options: options chosen by the voter(s) +`, + Args: cobra.MinimumNArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + err := cmd.Flags().Set(flags.FlagFrom, args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + pollID, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } + + timeString := fmt.Sprintf("\"%s\"", args[2]) + var timeout types.Timestamp + err = clientCtx.Codec.UnmarshalJSON([]byte(timeString), &timeout) + if err != nil { + return err + } + + timeNow := gogotypes.TimestampNow() + if timeout.Compare(timeNow) <= 0 { + return fmt.Errorf("deadline for submitting the vote has passed") + } + + keyInfo, err := clientCtx.Keyring.Key(clientCtx.GetFromName()) + if err != nil { + return err + } + pubKey := keyInfo.GetPubKey() + pubKeyAny, err := codectypes.NewAnyWithValue(pubKey) + if err != nil { + return err + } + + var optionTitles []string + var sigs [][]byte + for i := 3; i < len(args); i++ { + option := args[i] + optionTitles = append(optionTitles, option) + + msg := group.MsgVotePollBasic{ + PollId: pollID, + Option: option, + Expiry: timeout, + } + if err = msg.ValidateBasic(); err != nil { + return err + } + + bytesToSign := msg.GetSignBytes() + sigBytes, _, err := clientCtx.Keyring.Sign(clientCtx.GetFromName(), bytesToSign) + if err != nil { + return err + } + + sigs = append(sigs, sigBytes) + } + + sigBytes, err := bls12381.AggregateSignature(sigs) + if err != nil { + return err + } + + options := group.Options{Titles: optionTitles} + if err = options.ValidateBasic(); err != nil { + return err + } + + vote := &group.MsgVotePollBasicResponse{ + PollId: pollID, + Options: options, + Expiry: timeout, + Voter: args[0], + PubKey: pubKeyAny, + Sig: sigBytes, + } + + return clientCtx.PrintProto(vote) + }, + } + + cmd.Flags().String(flags.FlagFrom, "", "Name or address of private key with which to sign") + cmd.Flags().StringP(tmcli.OutputFlag, "o", "text", "Output format (text|json)") + + return cmd +} + +// GetVerifyVoteBasicCmd creates a CLI command for aggregating basic votes. +func GetVerifyVotePollBasicCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "verify-vote-poll-basic [file]", + Short: "Verify signature for a basic vote for poll", + Long: `Verify signature for a basic vote for poll. + +Parameters: + file: a basic vote for poll with signature +`, + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err } - voterAddress, err := sdk.AccAddressFromBech32(vote.Voter) + vote, err := parseVotePollBasic(clientCtx, args[0]) if err != nil { return err } - if !bytes.Equal(pubKey.Address(), voterAddress) { - return fmt.Errorf("public key does not match the voter's address %s", vote.Voter) + + if err = vote.ValidateBasic(); err != nil { + return err } - if !pubKey.VerifySignature(msgBytes, vote.Sig) { - return fmt.Errorf("verification failed") + if err = vote.VerifySignature(); err != nil { + return err } cmd.Println("Verification Successful!") diff --git a/x/group/client/util.go b/x/group/client/util.go index 5069524eb0..02052e380b 100644 --- a/x/group/client/util.go +++ b/x/group/client/util.go @@ -1,6 +1,7 @@ package client import ( + "fmt" "io/ioutil" "github.com/cosmos/cosmos-sdk/client" @@ -45,11 +46,15 @@ func parseGroupMembers(clientCtx client.Context, membersFile string) ([]*group.G contents, err := ioutil.ReadFile(membersFile) if err != nil { - return nil, err + return nil, err } err = clientCtx.Codec.UnmarshalJSON(contents, &res) if err != nil { - return nil, err + return nil, err + } + + if res.Pagination.NextKey != nil { + return nil, fmt.Errorf("require all the group members") } return res.Members, nil @@ -73,5 +78,24 @@ func parseVoteBasic(clientCtx client.Context, voteFile string) (group.MsgVoteBas } return vote, nil +} + +func parseVotePollBasic(clientCtx client.Context, voteFile string) (group.MsgVotePollBasicResponse, error) { + vote := group.MsgVotePollBasicResponse{} + if voteFile == "" { + return vote, nil + } + + contents, err := ioutil.ReadFile(voteFile) + if err != nil { + return vote, err + } + + err = clientCtx.Codec.UnmarshalJSON(contents, &vote) + if err != nil { + return vote, err + } + + return vote, nil } diff --git a/x/group/codec.go b/x/group/codec.go index 8d6cc2fb3d..ba80481792 100644 --- a/x/group/codec.go +++ b/x/group/codec.go @@ -23,9 +23,13 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgUpdateGroupAccountMetadata{}, "cosmos-sdk/MsgUpdateGroupAccountMetadata", nil) cdc.RegisterConcrete(&MsgCreateProposal{}, "cosmos-sdk/group/MsgCreateProposal", nil) cdc.RegisterConcrete(&MsgVote{}, "cosmos-sdk/group/MsgVote", nil) - cdc.RegisterConcrete(&MsgExec{}, "cosmos-sdk/group/MsgExec", nil) - cdc.RegisterConcrete(&MsgVoteAgg{}, "cosmos-sdk/group/MsgVoteAgg", nil) cdc.RegisterConcrete(&MsgVoteBasicResponse{}, "cosmos-sdk/group/MsgVoteBasic", nil) + cdc.RegisterConcrete(&MsgVoteAgg{}, "cosmos-sdk/group/MsgVoteAgg", nil) + cdc.RegisterConcrete(&MsgExec{}, "cosmos-sdk/group/MsgExec", nil) + cdc.RegisterConcrete(&MsgCreatePoll{}, "cosmos-sdk/group/MsgCreatePoll", nil) + cdc.RegisterConcrete(&MsgVotePoll{}, "cosmos-sdk/group/MsgVotePoll", nil) + cdc.RegisterConcrete(&MsgVotePollBasicResponse{}, "cosmos-sdk/group/MsgVotePollBasic", nil) + cdc.RegisterConcrete(&MsgVotePollAgg{}, "cosmos-sdk/group/MsgVotePollAgg", nil) } func RegisterTypes(registry cdctypes.InterfaceRegistry) { @@ -40,9 +44,13 @@ func RegisterTypes(registry cdctypes.InterfaceRegistry) { &MsgUpdateGroupAccountMetadata{}, &MsgCreateProposal{}, &MsgVote{}, - &MsgExec{}, - &MsgVoteAgg{}, &MsgVoteBasicResponse{}, + &MsgVoteAgg{}, + &MsgExec{}, + &MsgCreatePoll{}, + &MsgVotePoll{}, + &MsgVotePollBasicResponse{}, + &MsgVotePollAgg{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/group/events.pb.go b/x/group/events.pb.go index 3e27bf80c3..a8f8cf7695 100644 --- a/x/group/events.pb.go +++ b/x/group/events.pb.go @@ -344,6 +344,98 @@ func (m *EventExec) GetProposalId() uint64 { return 0 } +// EventCreateProposal is an event emitted when a proposal is created. +type EventCreatePoll struct { + // poll_id is the unique ID of the poll. + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` +} + +func (m *EventCreatePoll) Reset() { *m = EventCreatePoll{} } +func (m *EventCreatePoll) String() string { return proto.CompactTextString(m) } +func (*EventCreatePoll) ProtoMessage() {} +func (*EventCreatePoll) Descriptor() ([]byte, []int) { + return fileDescriptor_3545d78da3f76a06, []int{7} +} +func (m *EventCreatePoll) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventCreatePoll) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventCreatePoll.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 *EventCreatePoll) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventCreatePoll.Merge(m, src) +} +func (m *EventCreatePoll) XXX_Size() int { + return m.Size() +} +func (m *EventCreatePoll) XXX_DiscardUnknown() { + xxx_messageInfo_EventCreatePoll.DiscardUnknown(m) +} + +var xxx_messageInfo_EventCreatePoll proto.InternalMessageInfo + +func (m *EventCreatePoll) GetPollId() uint64 { + if m != nil { + return m.PollId + } + return 0 +} + +// EventVotePoll is an event emitted when a voter votes on a proposal. +type EventVotePoll struct { + // poll_id is the unique ID of the proposal. + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` +} + +func (m *EventVotePoll) Reset() { *m = EventVotePoll{} } +func (m *EventVotePoll) String() string { return proto.CompactTextString(m) } +func (*EventVotePoll) ProtoMessage() {} +func (*EventVotePoll) Descriptor() ([]byte, []int) { + return fileDescriptor_3545d78da3f76a06, []int{8} +} +func (m *EventVotePoll) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventVotePoll) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventVotePoll.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 *EventVotePoll) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventVotePoll.Merge(m, src) +} +func (m *EventVotePoll) XXX_Size() int { + return m.Size() +} +func (m *EventVotePoll) XXX_DiscardUnknown() { + xxx_messageInfo_EventVotePoll.DiscardUnknown(m) +} + +var xxx_messageInfo_EventVotePoll proto.InternalMessageInfo + +func (m *EventVotePoll) GetPollId() uint64 { + if m != nil { + return m.PollId + } + return 0 +} + func init() { proto.RegisterType((*EventCreateGroup)(nil), "regen.group.v1alpha1.EventCreateGroup") proto.RegisterType((*EventUpdateGroup)(nil), "regen.group.v1alpha1.EventUpdateGroup") @@ -352,12 +444,14 @@ func init() { proto.RegisterType((*EventCreateProposal)(nil), "regen.group.v1alpha1.EventCreateProposal") proto.RegisterType((*EventVote)(nil), "regen.group.v1alpha1.EventVote") proto.RegisterType((*EventExec)(nil), "regen.group.v1alpha1.EventExec") + proto.RegisterType((*EventCreatePoll)(nil), "regen.group.v1alpha1.EventCreatePoll") + proto.RegisterType((*EventVotePoll)(nil), "regen.group.v1alpha1.EventVotePoll") } func init() { proto.RegisterFile("regen/group/v1alpha1/events.proto", fileDescriptor_3545d78da3f76a06) } var fileDescriptor_3545d78da3f76a06 = []byte{ - // 256 bytes of a gzipped FileDescriptorProto + // 287 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2c, 0x4a, 0x4d, 0x4f, 0xcd, 0xd3, 0x4f, 0x2f, 0xca, 0x2f, 0x2d, 0xd0, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, 0x48, 0x34, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x01, @@ -369,11 +463,13 @@ var fileDescriptor_3545d78da3f76a06 = []byte{ 0x85, 0x6b, 0x42, 0xb2, 0x83, 0xb0, 0x26, 0x33, 0x2e, 0x61, 0x24, 0x9b, 0x02, 0x8a, 0xf2, 0x0b, 0xf2, 0x8b, 0x13, 0x73, 0x84, 0xe4, 0xb9, 0xb8, 0x0b, 0xa0, 0x6c, 0x84, 0xf3, 0xb8, 0x60, 0x42, 0x9e, 0x29, 0x4a, 0x3a, 0x5c, 0x9c, 0x60, 0x7d, 0x61, 0xf9, 0x25, 0xa9, 0xc4, 0xab, 0x76, 0xad, - 0x48, 0x4d, 0x26, 0xa8, 0xda, 0xc9, 0xee, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, - 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, - 0xa2, 0x54, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x93, 0xf3, 0x8b, - 0x73, 0xf3, 0x8b, 0xa1, 0x94, 0x6e, 0x71, 0x4a, 0xb6, 0x7e, 0x05, 0x24, 0x1e, 0x93, 0xd8, 0xc0, - 0x11, 0x67, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x64, 0x0c, 0x52, 0xdd, 0x01, 0x00, 0x00, + 0x48, 0x4d, 0x26, 0xac, 0x5a, 0x8b, 0x8b, 0x1f, 0xd9, 0x4d, 0xf9, 0x39, 0x39, 0x42, 0xe2, 0x5c, + 0xec, 0x05, 0xf9, 0x39, 0x48, 0xea, 0xd9, 0x40, 0x5c, 0xcf, 0x14, 0x25, 0x0d, 0x2e, 0x5e, 0xb8, + 0x3b, 0xf0, 0xaa, 0x74, 0xb2, 0x3b, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, + 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, + 0x95, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xe4, 0xfc, 0xe2, 0xdc, + 0xfc, 0x62, 0x28, 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x5f, 0x01, 0x49, 0x1d, 0x49, 0x6c, 0xe0, 0xe4, + 0x60, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x48, 0x73, 0xd9, 0x89, 0x33, 0x02, 0x00, 0x00, } func (m *EventCreateGroup) Marshal() (dAtA []byte, err error) { @@ -576,6 +672,62 @@ func (m *EventExec) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *EventCreatePoll) 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 *EventCreatePoll) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventCreatePoll) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PollId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *EventVotePoll) 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 *EventVotePoll) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventVotePoll) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PollId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { offset -= sovEvents(v) base := offset @@ -673,6 +825,30 @@ func (m *EventExec) Size() (n int) { return n } +func (m *EventCreatePoll) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovEvents(uint64(m.PollId)) + } + return n +} + +func (m *EventVotePoll) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovEvents(uint64(m.PollId)) + } + return n +} + func sovEvents(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1188,6 +1364,144 @@ func (m *EventExec) Unmarshal(dAtA []byte) error { } return nil } +func (m *EventCreatePoll) 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 ErrIntOverflowEvents + } + 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: EventCreatePoll: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventCreatePoll: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) + } + m.PollId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PollId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventVotePoll) 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 ErrIntOverflowEvents + } + 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: EventVotePoll: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventVotePoll: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) + } + m.PollId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PollId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipEvents(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/group/genesis.pb.go b/x/group/genesis.pb.go index a47f90d8ee..b7fd4bf8c2 100644 --- a/x/group/genesis.pb.go +++ b/x/group/genesis.pb.go @@ -44,6 +44,13 @@ type GenesisState struct { Proposals []*Proposal `protobuf:"bytes,7,rep,name=proposals,proto3" json:"proposals,omitempty"` // votes is the list of votes. Votes []*Vote `protobuf:"bytes,8,rep,name=votes,proto3" json:"votes,omitempty"` + // polls is the list of polls. + Polls []*Poll `protobuf:"bytes,9,rep,name=polls,proto3" json:"polls,omitempty"` + // poll_seq is the poll table orm.Sequence, + // it is used to get the next poll ID. + PollSeq uint64 `protobuf:"varint,10,opt,name=poll_seq,json=pollSeq,proto3" json:"poll_seq,omitempty"` + // votes is the list of votes for poll. + VotesForPoll []*VotePoll `protobuf:"bytes,11,rep,name=votes_for_poll,json=votesForPoll,proto3" json:"votes_for_poll,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -135,6 +142,27 @@ func (m *GenesisState) GetVotes() []*Vote { return nil } +func (m *GenesisState) GetPolls() []*Poll { + if m != nil { + return m.Polls + } + return nil +} + +func (m *GenesisState) GetPollSeq() uint64 { + if m != nil { + return m.PollSeq + } + return 0 +} + +func (m *GenesisState) GetVotesForPoll() []*VotePoll { + if m != nil { + return m.VotesForPoll + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "regen.group.v1alpha1.GenesisState") } @@ -144,30 +172,33 @@ func init() { } var fileDescriptor_6ccc5d002e96a4ab = []byte{ - // 355 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xbd, 0x4e, 0xc2, 0x50, - 0x14, 0xc7, 0xa9, 0x7c, 0x08, 0x17, 0xd0, 0xd8, 0x30, 0x34, 0x98, 0x54, 0x20, 0xc6, 0x10, 0x13, - 0x5b, 0xd1, 0xc1, 0xc5, 0x98, 0xe8, 0x20, 0x71, 0x20, 0x31, 0x25, 0x71, 0x70, 0x31, 0xa5, 0x5e, - 0x2f, 0x44, 0xda, 0x53, 0x7a, 0x2e, 0x44, 0xdf, 0xc2, 0xe7, 0xf1, 0x09, 0x1c, 0x19, 0x1d, 0x0d, - 0xbc, 0x88, 0xe9, 0xb9, 0x25, 0x68, 0xd2, 0x30, 0xf5, 0x9e, 0xd3, 0xdf, 0xff, 0x63, 0x38, 0xac, - 0x15, 0x71, 0xc1, 0x03, 0x5b, 0x44, 0x30, 0x0d, 0xed, 0x59, 0xc7, 0x1d, 0x87, 0x43, 0xb7, 0x63, - 0x0b, 0x1e, 0x70, 0x1c, 0xa1, 0x15, 0x46, 0x20, 0x41, 0xaf, 0x11, 0x63, 0x11, 0x63, 0xad, 0x98, - 0x7a, 0x4d, 0x80, 0x00, 0x02, 0xec, 0xf8, 0xa5, 0xd8, 0x7a, 0x23, 0xd5, 0x4f, 0xbe, 0x87, 0x3c, - 0x71, 0x6b, 0x7d, 0x66, 0x59, 0xa5, 0xab, 0xfc, 0xfb, 0xd2, 0x95, 0x5c, 0xdf, 0x67, 0x25, 0xc2, - 0x9f, 0x90, 0x4f, 0x0c, 0xad, 0xa1, 0xb5, 0x73, 0x4e, 0x91, 0x16, 0x7d, 0x3e, 0xd1, 0x2f, 0x58, - 0x81, 0xde, 0x68, 0x6c, 0x35, 0xb2, 0xed, 0xf2, 0xd9, 0x81, 0x95, 0x56, 0xc6, 0xea, 0xc6, 0xe3, - 0x5d, 0xf0, 0x02, 0x4e, 0x82, 0xeb, 0xb7, 0xac, 0xaa, 0x5c, 0x7d, 0xee, 0x0f, 0x78, 0x84, 0x46, - 0x96, 0xf4, 0xcd, 0x0d, 0xfa, 0x1e, 0x91, 0x4e, 0x45, 0xac, 0x07, 0xd4, 0x8f, 0xd9, 0x9e, 0xf2, - 0x71, 0x3d, 0x0f, 0xa6, 0x81, 0xa4, 0x96, 0x39, 0x6a, 0xb9, 0x4b, 0x3f, 0xae, 0xd5, 0x3e, 0x2e, - 0xdb, 0x63, 0x3b, 0xff, 0x58, 0x34, 0xf2, 0x14, 0x7a, 0xb4, 0x21, 0x34, 0x91, 0x53, 0xf7, 0xea, - 0x5f, 0x43, 0xd4, 0x9b, 0xac, 0x12, 0x46, 0x10, 0x02, 0xba, 0x63, 0x4a, 0x2d, 0x50, 0x6a, 0x79, - 0xb5, 0x8b, 0x13, 0x2f, 0x59, 0x69, 0x35, 0xa2, 0xb1, 0x4d, 0x61, 0x66, 0x7a, 0xd8, 0x7d, 0x82, - 0x39, 0x6b, 0x81, 0x7e, 0xca, 0xf2, 0x33, 0x90, 0x1c, 0x8d, 0x22, 0x29, 0xeb, 0xe9, 0xca, 0x07, - 0x90, 0xdc, 0x51, 0xe0, 0xcd, 0xd5, 0xd7, 0xc2, 0xd4, 0xe6, 0x0b, 0x53, 0xfb, 0x59, 0x98, 0xda, - 0xc7, 0xd2, 0xcc, 0xcc, 0x97, 0x66, 0xe6, 0x7b, 0x69, 0x66, 0x1e, 0x0f, 0xc5, 0x48, 0x0e, 0xa7, - 0x03, 0xcb, 0x03, 0xdf, 0xf6, 0x00, 0x7d, 0xc0, 0xe4, 0x73, 0x82, 0xcf, 0xaf, 0xf6, 0x9b, 0xba, - 0x88, 0x41, 0x81, 0x6e, 0xe0, 0xfc, 0x37, 0x00, 0x00, 0xff, 0xff, 0x86, 0xdc, 0xfe, 0x27, 0x77, - 0x02, 0x00, 0x00, + // 408 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xcd, 0xaa, 0xda, 0x40, + 0x14, 0xc7, 0x4d, 0xfd, 0x1e, 0xa3, 0xa5, 0x83, 0x8b, 0xa9, 0x85, 0x54, 0xa5, 0x14, 0x29, 0x34, + 0xa9, 0xed, 0xa2, 0x9b, 0x52, 0x68, 0x29, 0x4a, 0x17, 0x82, 0x44, 0xe8, 0xa2, 0x1b, 0x89, 0xe9, + 0x18, 0xa5, 0x49, 0x4e, 0xcc, 0x8c, 0xd2, 0xbe, 0x45, 0x1f, 0xab, 0x9b, 0x0b, 0x2e, 0xef, 0xf2, + 0xa2, 0x2f, 0x72, 0x99, 0x33, 0x11, 0xef, 0x85, 0x90, 0x55, 0xe6, 0x9c, 0xfc, 0xfe, 0x1f, 0x03, + 0x43, 0x86, 0x29, 0x0f, 0x78, 0xec, 0x04, 0x29, 0xec, 0x13, 0xe7, 0x30, 0xf6, 0xc2, 0x64, 0xe3, + 0x8d, 0x9d, 0x80, 0xc7, 0x5c, 0x6c, 0x85, 0x9d, 0xa4, 0x20, 0x81, 0x76, 0x91, 0xb1, 0x91, 0xb1, + 0x2f, 0x4c, 0xaf, 0x1b, 0x40, 0x00, 0x08, 0x38, 0xea, 0xa4, 0xd9, 0x5e, 0x3f, 0xd7, 0x4f, 0xfe, + 0x4d, 0x78, 0xe6, 0x36, 0xbc, 0xa9, 0x10, 0x73, 0xaa, 0xfd, 0x17, 0xd2, 0x93, 0x9c, 0xbe, 0x20, + 0x4d, 0xc4, 0x97, 0x82, 0xef, 0x98, 0xd1, 0x37, 0x46, 0x15, 0xb7, 0x81, 0x8b, 0x05, 0xdf, 0xd1, + 0x8f, 0xa4, 0x86, 0x67, 0xc1, 0x9e, 0xf4, 0xcb, 0xa3, 0xd6, 0xfb, 0x97, 0x76, 0x5e, 0x19, 0x7b, + 0xaa, 0xc6, 0xef, 0xf1, 0x1a, 0xdc, 0x0c, 0xa7, 0x13, 0xd2, 0xd6, 0xae, 0x11, 0x8f, 0x56, 0x3c, + 0x15, 0xac, 0x8c, 0xfa, 0x41, 0x81, 0x7e, 0x86, 0xa4, 0x6b, 0x06, 0xd7, 0x41, 0xd0, 0x37, 0xe4, + 0x99, 0xf6, 0xf1, 0x7c, 0x1f, 0xf6, 0xb1, 0xc4, 0x96, 0x15, 0x6c, 0xf9, 0x14, 0x7f, 0x7c, 0xd1, + 0x7b, 0x55, 0x76, 0x46, 0x3a, 0x8f, 0x58, 0xc1, 0xaa, 0x18, 0xfa, 0xba, 0x20, 0x34, 0x93, 0x63, + 0xf7, 0xf6, 0x43, 0x43, 0x41, 0x07, 0xc4, 0x4c, 0x52, 0x48, 0x40, 0x78, 0x21, 0xa6, 0xd6, 0x30, + 0xb5, 0x75, 0xd9, 0xa9, 0xc4, 0x4f, 0xa4, 0x79, 0x19, 0x05, 0xab, 0x63, 0x98, 0x95, 0x1f, 0x36, + 0xcf, 0x30, 0xf7, 0x2a, 0xa0, 0xef, 0x48, 0xf5, 0x00, 0x92, 0x0b, 0xd6, 0x40, 0x65, 0x2f, 0x5f, + 0xf9, 0x03, 0x24, 0x77, 0x35, 0xa8, 0x14, 0x09, 0x84, 0xa1, 0x60, 0xcd, 0x22, 0xc5, 0x1c, 0xc2, + 0xd0, 0xd5, 0x20, 0x7d, 0x4e, 0x1a, 0xea, 0x80, 0x17, 0x20, 0x78, 0x81, 0xba, 0x9a, 0x55, 0xf9, + 0x6f, 0xa4, 0x83, 0xae, 0xcb, 0x35, 0xa4, 0x4b, 0xb5, 0x64, 0xad, 0xa2, 0x1b, 0xa8, 0x1e, 0xe8, + 0x6c, 0xa2, 0x6a, 0x02, 0xa9, 0x9a, 0xbe, 0x7e, 0xfe, 0x7f, 0xb2, 0x8c, 0xe3, 0xc9, 0x32, 0xee, + 0x4e, 0x96, 0xf1, 0xef, 0x6c, 0x95, 0x8e, 0x67, 0xab, 0x74, 0x7b, 0xb6, 0x4a, 0x3f, 0x5f, 0x05, + 0x5b, 0xb9, 0xd9, 0xaf, 0x6c, 0x1f, 0x22, 0xc7, 0x07, 0x11, 0x81, 0xc8, 0x3e, 0x6f, 0xc5, 0xaf, + 0xdf, 0xce, 0x1f, 0xfd, 0x48, 0x57, 0x35, 0x7c, 0x96, 0x1f, 0xee, 0x03, 0x00, 0x00, 0xff, 0xff, + 0x2c, 0xd4, 0x57, 0x01, 0x0a, 0x03, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -190,6 +221,39 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.VotesForPoll) > 0 { + for iNdEx := len(m.VotesForPoll) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.VotesForPoll[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + } + } + if m.PollSeq != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.PollSeq)) + i-- + dAtA[i] = 0x50 + } + if len(m.Polls) > 0 { + for iNdEx := len(m.Polls) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Polls[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + } + } if len(m.Votes) > 0 { for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { { @@ -334,6 +398,21 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.Polls) > 0 { + for _, e := range m.Polls { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.PollSeq != 0 { + n += 1 + sovGenesis(uint64(m.PollSeq)) + } + if len(m.VotesForPoll) > 0 { + for _, e := range m.VotesForPoll { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -599,6 +678,93 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Polls", 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.Polls = append(m.Polls, &Poll{}) + if err := m.Polls[len(m.Polls)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PollSeq", wireType) + } + m.PollSeq = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PollSeq |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VotesForPoll", 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.VotesForPoll = append(m.VotesForPoll, &VotePoll{}) + if err := m.VotesForPoll[len(m.VotesForPoll)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/group/msgs.go b/x/group/msgs.go index 2bcbb43e5b..443141208f 100644 --- a/x/group/msgs.go +++ b/x/group/msgs.go @@ -1,6 +1,7 @@ package group import ( + "bytes" "fmt" "github.com/cosmos/cosmos-sdk/codec/types" @@ -12,6 +13,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" proto "github.com/gogo/protobuf/proto" + prototypes "github.com/gogo/protobuf/types" ) var _ sdk.Msg = &MsgCreateGroup{} @@ -44,6 +46,10 @@ func (m MsgCreateGroup) ValidateBasic() error { return sdkerrors.Wrap(err, "admin") } + if err := assertMetadataLength(m.Metadata, "group metadata"); err != nil { + return err + } + members := Members{Members: m.Members} if err := members.ValidateBasic(); err != nil { return sdkerrors.Wrap(err, "members") @@ -66,6 +72,10 @@ func (m Member) ValidateBasic() error { return sdkerrors.Wrap(err, "weight") } + if err := assertMetadataLength(m.Metadata, "member metadata"); err != nil { + return err + } + return nil } @@ -151,6 +161,9 @@ func (m MsgUpdateGroupMetadata) ValidateBasic() error { if err != nil { return sdkerrors.Wrap(err, "admin") } + if err = assertMetadataLength(m.Metadata, "metadata"); err != nil { + return err + } return nil } @@ -238,10 +251,15 @@ func (m MsgCreateGroupAccount) ValidateBasic() error { if err != nil { return sdkerrors.Wrap(err, "admin") } + if m.GroupId == 0 { return sdkerrors.Wrap(ErrEmpty, "group") } + if err := assertMetadataLength(m.Metadata, "metadata"); err != nil { + return err + } + policy := m.GetDecisionPolicy() if policy == nil { return sdkerrors.Wrap(ErrEmpty, "decision policy") @@ -423,6 +441,10 @@ func (m MsgUpdateGroupAccountMetadata) ValidateBasic() error { return sdkerrors.Wrap(err, "group account") } + if err := assertMetadataLength(m.Metadata, "group account metadata"); err != nil { + return err + } + return nil } @@ -532,6 +554,10 @@ func (m MsgCreateProposal) ValidateBasic() error { return sdkerrors.Wrap(err, "group account") } + if err := assertMetadataLength(m.Metadata, "metadata"); err != nil { + return err + } + if len(m.Proposers) == 0 { return sdkerrors.Wrap(ErrEmpty, "proposers") } @@ -553,6 +579,7 @@ func (m MsgCreateProposal) ValidateBasic() error { return sdkerrors.Wrapf(err, "msg %d", i) } } + return nil } @@ -618,6 +645,9 @@ func (m MsgVote) ValidateBasic() error { if _, ok := Choice_name[int32(m.Choice)]; !ok { return sdkerrors.Wrap(ErrInvalid, "choice") } + if err := assertMetadataLength(m.Metadata, "metadata"); err != nil { + return err + } return nil } @@ -632,12 +662,7 @@ func (m MsgVoteBasic) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg. func (m MsgVoteBasic) GetSignBytes() []byte { - req := MsgVoteBasic{ - ProposalId: m.ProposalId, - Choice: m.Choice, - Timeout: m.Timeout, - } - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&req)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgVoteRequest. @@ -656,6 +681,13 @@ func (m MsgVoteBasic) ValidateBasic() error { if _, ok := Choice_name[int32(m.Choice)]; !ok { return sdkerrors.Wrap(ErrInvalid, "choice") } + t, err := prototypes.TimestampFromProto(&m.Expiry) + if err != nil { + return sdkerrors.Wrap(err, "vote expiry") + } + if t.IsZero() { + return sdkerrors.Wrap(ErrEmpty, "vote expiry") + } return nil } @@ -674,7 +706,7 @@ func (m MsgVoteBasicResponse) GetSignBytes() []byte { res := MsgVoteBasic{ ProposalId: m.ProposalId, Choice: m.Choice, - Timeout: m.Timeout, + Expiry: m.Expiry, } return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&res)) } @@ -693,12 +725,34 @@ func (m MsgVoteBasicResponse) ValidateBasic() error { if m.ProposalId == 0 { return sdkerrors.Wrap(ErrEmpty, "proposal") } + if m.Choice == Choice_CHOICE_UNSPECIFIED { return sdkerrors.Wrap(ErrEmpty, "choice") } if _, ok := Choice_name[int32(m.Choice)]; !ok { return sdkerrors.Wrap(ErrInvalid, "choice") } + + _, err := sdk.AccAddressFromBech32(m.Voter) + if err != nil { + return sdkerrors.Wrap(err, "voter account") + } + + if m.PubKey == nil { + return sdkerrors.Wrap(ErrEmpty, "public key") + } + + if len(m.Sig) == 0 { + return sdkerrors.Wrap(ErrEmpty, "voter signature") + } + + t, err := prototypes.TimestampFromProto(&m.Expiry) + if err != nil { + return sdkerrors.Wrap(err, "expiry") + } + if t.IsZero() { + return sdkerrors.Wrap(ErrEmpty, "expiry") + } return nil } @@ -708,6 +762,26 @@ func (m MsgVoteBasicResponse) UnpackInterfaces(unpacker types.AnyUnpacker) error return unpacker.UnpackAny(m.PubKey, &pk) } +func (m MsgVoteBasicResponse) VerifySignature() error { + msgBytes := m.GetSignBytes() + voterAddress := m.GetSigners()[0] + + pubKey, ok := m.PubKey.GetCachedValue().(cryptotypes.PubKey) + if !ok { + return sdkerrors.Wrap(ErrInvalid, "public key") + } + + if !bytes.Equal(pubKey.Address(), voterAddress) { + return sdkerrors.Wrapf(ErrInvalid, "public key does not match the voter's address %s", m.Voter) + } + + if !pubKey.VerifySignature(msgBytes, m.Sig) { + return sdkerrors.Wrap(ErrInvalid, "sigature verification failed") + } + + return nil +} + var _ sdk.Msg = &MsgVoteAgg{} var _ legacytx.LegacyMsg = &MsgVoteAgg{} @@ -737,50 +811,36 @@ func (m MsgVoteAgg) ValidateBasic() error { if err != nil { return sdkerrors.Wrap(err, "sender") } + if m.ProposalId == 0 { return sdkerrors.Wrap(ErrEmpty, "proposal") } + + if len(m.Votes) == 0 { + return sdkerrors.Wrap(ErrEmpty, "votes") + } for _, c := range m.Votes { if _, ok := Choice_name[int32(c)]; !ok { return sdkerrors.Wrap(ErrInvalid, "choice") } } - return nil -} -func (m MsgVoteAgg) VerifyAggSig(pks []cryptotypes.PubKey) error { - n := len(m.Votes) - if n <= 0 { - return fmt.Errorf("empty votes") - } - if len(pks) != n { - return fmt.Errorf("the length of public keys and votes must equal") + if err := assertMetadataLength(m.Metadata, "metadata"); err != nil { + return err } - pkeys := make([][]*bls12381.PubKey, len(Choice_name)) - for i, pk := range pks { - pkey, ok := pk.(*bls12381.PubKey) - if !ok { - return fmt.Errorf("only support bls12381 public key") - } - c := m.Votes[i] - pkeys[c] = append(pkeys[c], pkey) + if len(m.AggSig) == 0 { + return sdkerrors.Wrap(ErrEmpty, "voter signature") } - var votes [][]byte - var pubkeys [][]*bls12381.PubKey - - // skip the unspecified choice - for i := 1; i < len(Choice_name); i++ { - if len(pkeys[i]) != 0 { - vote := MsgVoteBasic{m.ProposalId, Choice(i), m.Timeout} - voteBytes := vote.GetSignBytes() - votes = append(votes, voteBytes) - pubkeys = append(pubkeys, pkeys[i]) - } + t, err := prototypes.TimestampFromProto(&m.Expiry) + if err != nil { + return sdkerrors.Wrap(err, "expiry") } - - return bls12381.VerifyAggregateSignature(votes, false, m.AggSig, pubkeys) + if t.IsZero() { + return sdkerrors.Wrap(ErrEmpty, "expiry") + } + return nil } var _ sdk.Msg = &MsgExec{} @@ -817,3 +877,315 @@ func (m MsgExec) ValidateBasic() error { } return nil } + +var _ sdk.Msg = &MsgCreatePoll{} +var _ legacytx.LegacyMsg = &MsgCreatePoll{} + +// Route Implements Msg. +func (m MsgCreatePoll) Route() string { return sdk.MsgTypeURL(&m) } + +// Type Implements Msg. +func (m MsgCreatePoll) Type() string { return sdk.MsgTypeURL(&m) } + +// GetSignBytes Implements Msg. +func (m MsgCreatePoll) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgCreateProposal. +func (m MsgCreatePoll) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgCreatePoll) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Creator) + if err != nil { + return sdkerrors.Wrap(err, "creator account") + } + + if m.GroupId == 0 { + return sdkerrors.Wrap(ErrEmpty, "group") + } + + if len(m.Title) == 0 { + return sdkerrors.Wrap(ErrEmpty, "poll title") + } + + if err := assertMetadataLength(m.Metadata, "metadata"); err != nil { + return err + } + if err := assertTitleLength(m.Title, "poll title"); err != nil { + return err + } + + if err := m.Options.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "options") + } + + if m.VoteLimit <= 0 { + return sdkerrors.Wrap(ErrInvalid, "vote limit must be positive") + } + + if int(m.VoteLimit) > len(m.Options.Titles) { + return sdkerrors.Wrap(ErrInvalid, "vote limit exceeds the number of options") + } + + t, err := prototypes.TimestampFromProto(&m.Timeout) + if err != nil { + return sdkerrors.Wrap(err, "timeout") + } + if t.IsZero() { + return sdkerrors.Wrap(ErrEmpty, "timeout") + } + + return nil +} + +var _ sdk.Msg = &MsgVotePoll{} +var _ legacytx.LegacyMsg = &MsgVotePoll{} + +// Route Implements Msg. +func (m MsgVotePoll) Route() string { return sdk.MsgTypeURL(&m) } + +// Type Implements Msg. +func (m MsgVotePoll) Type() string { return sdk.MsgTypeURL(&m) } + +// GetSignBytes Implements Msg. +func (m MsgVotePoll) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgCreateProposal. +func (m MsgVotePoll) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Voter) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgVotePoll) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Voter) + if err != nil { + return sdkerrors.Wrap(err, "creator account") + } + + if m.PollId == 0 { + return sdkerrors.Wrap(ErrEmpty, "poll") + } + + if err := assertMetadataLength(m.Metadata, "metadata"); err != nil { + return err + } + + if err := m.Options.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "options") + } + + return nil +} + +var _ sdk.Msg = &MsgVotePollBasic{} +var _ legacytx.LegacyMsg = &MsgVotePollBasic{} + +// Route Implements Msg. +func (m MsgVotePollBasic) Route() string { return sdk.MsgTypeURL(&m) } + +// Type Implements Msg. +func (m MsgVotePollBasic) Type() string { return sdk.MsgTypeURL(&m) } + +// GetSignBytes Implements Msg. +func (m MsgVotePollBasic) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgCreateProposal. +func (m MsgVotePollBasic) GetSigners() []sdk.AccAddress { + panic("not implemented for this message") +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgVotePollBasic) ValidateBasic() error { + if m.PollId == 0 { + return sdkerrors.Wrap(ErrEmpty, "poll") + } + + if len(m.Option) == 0 { + return sdkerrors.Wrap(ErrEmpty, "vote option") + } + + t, err := prototypes.TimestampFromProto(&m.Expiry) + if err != nil { + return sdkerrors.Wrap(err, "vote expiry") + } + if t.IsZero() { + return sdkerrors.Wrap(ErrEmpty, "vote expiry") + } + return nil +} + +var _ sdk.Msg = &MsgVotePollBasicResponse{} +var _ legacytx.LegacyMsg = &MsgVotePollBasicResponse{} +var _ types.UnpackInterfacesMessage = MsgVotePollBasicResponse{} + +// Route Implements Msg. +func (m MsgVotePollBasicResponse) Route() string { return sdk.MsgTypeURL(&m) } + +// Type Implements Msg. +func (m MsgVotePollBasicResponse) Type() string { return sdk.MsgTypeURL(&m) } + +// GetSignBytes Implements Msg. +func (m MsgVotePollBasicResponse) GetSignBytes() []byte { + panic("not implemented") +} + +func (m MsgVotePollBasicResponse) GetSignBytesMany() [][]byte { + signBytesMany := make([][]byte, 0, len(m.Options.Titles)) + for _, x := range m.Options.Titles { + y := MsgVotePollBasic{ + PollId: m.PollId, + Option: x, + Expiry: m.Expiry, + } + signBytesMany = append(signBytesMany, y.GetSignBytes()) + } + return signBytesMany +} + +// GetSigners returns the expected signers for a MsgVoteRequest. +func (m MsgVotePollBasicResponse) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Voter) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgVotePollBasicResponse) ValidateBasic() error { + if m.PollId == 0 { + return sdkerrors.Wrap(ErrEmpty, "proposal") + } + if err := m.Options.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "options") + } + _, err := sdk.AccAddressFromBech32(m.Voter) + if err != nil { + return sdkerrors.Wrap(err, "voter account") + } + if m.PubKey == nil { + return sdkerrors.Wrap(ErrEmpty, "public key") + } + if len(m.Sig) == 0 { + return sdkerrors.Wrap(ErrEmpty, "voter signature") + } + t, err := prototypes.TimestampFromProto(&m.Expiry) + if err != nil { + return sdkerrors.Wrap(err, "expiry") + } + if t.IsZero() { + return sdkerrors.Wrap(ErrEmpty, "expiry") + } + return nil +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (m MsgVotePollBasicResponse) UnpackInterfaces(unpacker types.AnyUnpacker) error { + var pk cryptotypes.PubKey + return unpacker.UnpackAny(m.PubKey, &pk) +} + +func (m MsgVotePollBasicResponse) VerifySignature() error { + msgsBytes := m.GetSignBytesMany() + voterAddress := m.GetSigners()[0] + + pubKey, ok := m.PubKey.GetCachedValue().(cryptotypes.PubKey) + if !ok { + return sdkerrors.Wrap(ErrInvalid, "public key") + } + + if !bytes.Equal(pubKey.Address(), voterAddress) { + return sdkerrors.Wrapf(ErrInvalid, "public key does not match the voter's address %s", m.Voter) + } + + pkBls, ok := pubKey.(*bls12381.PubKey) + if !ok { + return fmt.Errorf("only support bls public key") + } + + // todo: repeated public keys can be coalesced in pairings + var pkss [][]*bls12381.PubKey + for _ = range m.Options.Titles { + pkss = append(pkss, []*bls12381.PubKey{pkBls}) + } + + if err := bls12381.VerifyAggregateSignature(msgsBytes, false, m.Sig, pkss); err != nil { + return err + } + + return nil +} + +var _ sdk.Msg = &MsgVotePollAgg{} +var _ legacytx.LegacyMsg = &MsgVotePollAgg{} + +// Route Implements Msg. +func (m MsgVotePollAgg) Route() string { return sdk.MsgTypeURL(&m) } + +// Type Implements Msg. +func (m MsgVotePollAgg) Type() string { return sdk.MsgTypeURL(&m) } + +// GetSignBytes Implements Msg. +func (m MsgVotePollAgg) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgVoteRequest. +func (m MsgVotePollAgg) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check on the provided data +func (m MsgVotePollAgg) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return sdkerrors.Wrap(err, "sender") + } + if m.PollId == 0 { + return sdkerrors.Wrap(ErrEmpty, "poll") + } + if len(m.Votes) == 0 { + return sdkerrors.Wrap(ErrEmpty, "votes") + } + for _, v := range m.Votes { + if len(v.Titles) != 0 { + if err := v.ValidateBasic(); err != nil { + return sdkerrors.Wrap(ErrInvalid, "options") + } + } + } + if err := assertMetadataLength(m.Metadata, "metadata"); err != nil { + return err + } + if len(m.AggSig) == 0 { + return sdkerrors.Wrap(ErrEmpty, "signature") + } + t, err := prototypes.TimestampFromProto(&m.Expiry) + if err != nil { + return sdkerrors.Wrap(err, "expiry") + } + if t.IsZero() { + return sdkerrors.Wrap(ErrEmpty, "expiry") + } + return nil +} diff --git a/x/group/msgs_test.go b/x/group/msgs_test.go index 4bb5ca78ab..6963b59411 100644 --- a/x/group/msgs_test.go +++ b/x/group/msgs_test.go @@ -1,10 +1,17 @@ package group import ( + "bytes" + "fmt" + "strings" "testing" + "time" + + codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + gogotypes "github.com/gogo/protobuf/types" proto "github.com/gogo/protobuf/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -99,6 +106,22 @@ func TestMsgCreateGroupValidation(t *testing.T) { }, expErr: true, }, + "group metadata too long": { + src: MsgCreateGroup{ + Admin: myAddr.String(), + Metadata: bytes.Repeat([]byte{1}, 256), + }, + expErr: true, + }, + "members metadata too long": { + src: MsgCreateGroup{ + Admin: myAddr.String(), + Members: []Member{ + {Address: myAddr.String(), Weight: "1", Metadata: bytes.Repeat([]byte{1}, 256)}, + }, + }, + expErr: true, + }, } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { @@ -123,6 +146,7 @@ func TestMsgCreateGroupAccount(t *testing.T) { specs := map[string]struct { admin sdk.AccAddress group uint64 + metadata []byte threshold string timeout proto.Duration expErr bool @@ -183,13 +207,21 @@ func TestMsgCreateGroupAccount(t *testing.T) { timeout: proto.Duration{Seconds: 1}, expErr: true, }, + "metadata too long": { + admin: myAddr, + group: 1, + metadata: []byte(strings.Repeat("a", 256)), + threshold: "1", + timeout: proto.Duration{Seconds: 1}, + expErr: true, + }, } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { m, err := NewMsgCreateGroupAccount( spec.admin, spec.group, - nil, + spec.metadata, &ThresholdDecisionPolicy{ Threshold: spec.threshold, Timeout: spec.timeout, @@ -256,6 +288,14 @@ func TestMsgCreateProposalRequest(t *testing.T) { }, expErr: true, }, + "metadata too long": { + src: MsgCreateProposal{ + Address: groupAccAddr, + Proposers: []string{memberAddr}, + Metadata: bytes.Repeat([]byte{1}, 256), + }, + expErr: true, + }, } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { @@ -329,6 +369,671 @@ func TestMsgVote(t *testing.T) { }, expErr: true, }, + "metadata too long": { + src: MsgVote{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + Voter: memberAddr, + Metadata: bytes.Repeat([]byte{1}, 256), + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgVoteBasicResponse(t *testing.T) { + sk, pk, addr := testdata.KeyTestPubAddrBls12381() + memberAddr := addr.String() + + sk2, pk2, addr2 := testdata.KeyTestPubAddrBls12381() + + now := time.Now() + expiry, err := gogotypes.TimestampProto(now.Add(time.Second * 3000)) + require.NoError(t, err) + + msg := MsgVoteBasic{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + Expiry: *expiry, + } + err = msg.ValidateBasic() + require.NoError(t, err) + + bytesToSign := msg.GetSignBytes() + + sig, err := sk.Sign(bytesToSign) + require.NoError(t, err) + + sig2, err := sk2.Sign(bytesToSign) + require.NoError(t, err) + + pubKeyAny, err := codectypes.NewAnyWithValue(pk) + require.NoError(t, err) + + pubKeyAny2, err := codectypes.NewAnyWithValue(pk2) + require.NoError(t, err) + + specs := map[string]struct { + src MsgVoteBasicResponse + expErr bool + sigErr bool + }{ + "all good": { + src: MsgVoteBasicResponse{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + Expiry: *expiry, + Voter: memberAddr, + PubKey: pubKeyAny, + Sig: sig, + }, + }, + "proposal required": { + src: MsgVoteBasicResponse{ + Choice: Choice_CHOICE_YES, + Expiry: *expiry, + Voter: memberAddr, + PubKey: pubKeyAny, + Sig: sig, + }, + expErr: true, + }, + "choice required": { + src: MsgVoteBasicResponse{ + ProposalId: 1, + Expiry: *expiry, + Voter: memberAddr, + PubKey: pubKeyAny, + Sig: sig, + }, + expErr: true, + }, + "valid choice required": { + src: MsgVoteBasicResponse{ + ProposalId: 1, + Choice: 5, + Expiry: *expiry, + Voter: memberAddr, + PubKey: pubKeyAny, + Sig: sig, + }, + expErr: true, + }, + "voter required": { + src: MsgVoteBasicResponse{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + Expiry: *expiry, + PubKey: pubKeyAny, + Sig: sig, + }, + expErr: true, + }, + "valid voter address required": { + src: MsgVoteBasicResponse{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + Expiry: *expiry, + Voter: "invalid member address", + PubKey: pubKeyAny, + Sig: sig, + }, + expErr: true, + }, + "wrong voter": { + src: MsgVoteBasicResponse{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + Expiry: *expiry, + Voter: addr2.String(), + PubKey: pubKeyAny, + Sig: sig, + }, + sigErr: true, + }, + "wrong choice": { + src: MsgVoteBasicResponse{ + ProposalId: 1, + Choice: Choice_CHOICE_NO, + Expiry: *expiry, + Voter: memberAddr, + PubKey: pubKeyAny, + Sig: sig, + }, + sigErr: true, + }, + "wrong signature": { + src: MsgVoteBasicResponse{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + Expiry: *expiry, + Voter: addr.String(), + PubKey: pubKeyAny, + Sig: sig2, + }, + sigErr: true, + }, + "empty public key": { + src: MsgVoteBasicResponse{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + Expiry: *expiry, + Voter: memberAddr, + Sig: sig, + }, + expErr: true, + }, + "wrong public key": { + src: MsgVoteBasicResponse{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + Expiry: *expiry, + Voter: memberAddr, + PubKey: pubKeyAny2, + Sig: sig, + }, + sigErr: true, + }, + "empty voters address not allowed": { + src: MsgVoteBasicResponse{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + Expiry: *expiry, + PubKey: pubKeyAny, + Sig: sig, + }, + expErr: true, + }, + "empty signature": { + src: MsgVoteBasicResponse{ + ProposalId: 1, + Choice: Choice_CHOICE_YES, + Expiry: *expiry, + Voter: memberAddr, + PubKey: pubKeyAny, + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + err = spec.src.VerifySignature() + if spec.sigErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + } + }) + } +} + +func TestMsgVoteAggRequest(t *testing.T) { + _, _, addr := testdata.KeyTestPubAddrBls12381() + memberAddr := addr.String() + + now := time.Now() + expiry, err := gogotypes.TimestampProto(now.Add(time.Second * 3000)) + require.NoError(t, err) + + specs := map[string]struct { + src MsgVoteAgg + expErr bool + }{ + "all good with minimus fields": { + src: MsgVoteAgg{ + Sender: memberAddr, + ProposalId: 1, + Votes: []Choice{Choice_CHOICE_YES, Choice_CHOICE_NO}, + Expiry: *expiry, + AggSig: []byte("does not check signature"), + }, + }, + "proposal required": { + src: MsgVoteAgg{ + Sender: memberAddr, + Votes: []Choice{Choice_CHOICE_YES, Choice_CHOICE_NO}, + Expiry: *expiry, + AggSig: []byte("does not check signature"), + }, + expErr: true, + }, + "votes required": { + src: MsgVoteAgg{ + Sender: memberAddr, + ProposalId: 1, + Expiry: *expiry, + AggSig: []byte("does not check signature"), + }, + expErr: true, + }, + "valid votes required": { + src: MsgVoteAgg{ + Sender: memberAddr, + ProposalId: 1, + Votes: []Choice{5, Choice_CHOICE_NO}, + Expiry: *expiry, + AggSig: []byte("does not check signature"), + }, + expErr: true, + }, + "sender required": { + src: MsgVoteAgg{ + ProposalId: 1, + Votes: []Choice{Choice_CHOICE_YES, Choice_CHOICE_NO}, + Expiry: *expiry, + AggSig: []byte("does not check signature"), + }, + expErr: true, + }, + "valid sender address required": { + src: MsgVoteAgg{ + Sender: "invalid sender address", + ProposalId: 1, + Votes: []Choice{Choice_CHOICE_YES, Choice_CHOICE_NO}, + Expiry: *expiry, + AggSig: []byte("does not check signature"), + }, + expErr: true, + }, + "empty signature": { + src: MsgVoteAgg{ + Sender: memberAddr, + ProposalId: 1, + Votes: []Choice{Choice_CHOICE_YES, Choice_CHOICE_NO}, + Expiry: *expiry, + }, + expErr: true, + }, + "metadata too long": { + src: MsgVoteAgg{ + Sender: memberAddr, + ProposalId: 1, + Votes: []Choice{Choice_CHOICE_YES, Choice_CHOICE_NO}, + Expiry: *expiry, + AggSig: []byte("does not check signature"), + Metadata: bytes.Repeat([]byte{1}, 256), + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgCreatePollRequest(t *testing.T) { + _, _, addr := testdata.KeyTestPubAddr() + memberAddr := addr.String() + + now := time.Now() + expiry, err := gogotypes.TimestampProto(now.Add(time.Second * 3000)) + require.NoError(t, err) + + longTitle := strings.Repeat("my title", 256) + manyOptions := make([]string, 300) + for i, _ := range manyOptions { + manyOptions[i] = fmt.Sprintf("option-%d", i) + } + + specs := map[string]struct { + src MsgCreatePoll + expErr bool + }{ + "all good": { + src: MsgCreatePoll{ + GroupId: 1, + Title: "2022 Election", + Options: Options{Titles: []string{"alice", "bob"}}, + Creator: memberAddr, + VoteLimit: 1, + Timeout: *expiry, + }, + }, + "group id required": { + src: MsgCreatePoll{ + Title: "2022 Election", + Options: Options{Titles: []string{"alice", "bob"}}, + Creator: memberAddr, + VoteLimit: 1, + Timeout: *expiry, + }, + expErr: true, + }, + "Creator required": { + src: MsgCreatePoll{ + GroupId: 1, + Title: "2022 Election", + Options: Options{Titles: []string{"alice", "bob"}}, + VoteLimit: 1, + Timeout: *expiry, + }, + expErr: true, + }, + "valid creator address required": { + src: MsgCreatePoll{ + GroupId: 1, + Title: "2022 Election", + Options: Options{Titles: []string{"alice", "bob"}}, + Creator: "invalid member address", + VoteLimit: 1, + Timeout: *expiry, + }, + expErr: true, + }, + "title required": { + src: MsgCreatePoll{ + GroupId: 1, + Options: Options{Titles: []string{"alice", "bob"}}, + Creator: memberAddr, + VoteLimit: 1, + Timeout: *expiry, + }, + expErr: true, + }, + "options required": { + src: MsgCreatePoll{ + GroupId: 1, + Title: "2022 Election", + Creator: memberAddr, + VoteLimit: 1, + Timeout: *expiry, + }, + expErr: true, + }, + "empty option": { + src: MsgCreatePoll{ + GroupId: 1, + Title: "2022 Election", + Options: Options{Titles: []string{"alice", ""}}, + Creator: memberAddr, + VoteLimit: 1, + Timeout: *expiry, + }, + expErr: true, + }, + "repeated options": { + src: MsgCreatePoll{ + GroupId: 1, + Title: "2022 Election", + Options: Options{Titles: []string{"alice", "alice"}}, + Creator: memberAddr, + VoteLimit: 1, + Timeout: *expiry, + }, + expErr: true, + }, + "vote limit required": { + src: MsgCreatePoll{ + GroupId: 1, + Title: "2022 Election", + Options: Options{Titles: []string{"alice", "bob"}}, + Creator: memberAddr, + Timeout: *expiry, + }, + expErr: true, + }, + "vote limit exceed": { + src: MsgCreatePoll{ + GroupId: 1, + Title: "2022 Election", + Options: Options{Titles: []string{"alice", "bob"}}, + Creator: memberAddr, + VoteLimit: 3, + Timeout: *expiry, + }, + expErr: true, + }, + "metadata too long": { + src: MsgCreatePoll{ + GroupId: 1, + Title: "2022 Election", + Options: Options{Titles: []string{"alice", "bob"}}, + Creator: memberAddr, + VoteLimit: 1, + Metadata: bytes.Repeat([]byte{1}, 256), + Timeout: *expiry, + }, + expErr: true, + }, + "title too long": { + src: MsgCreatePoll{ + GroupId: 1, + Title: longTitle, + Options: Options{Titles: []string{"alice", "bob"}}, + Creator: memberAddr, + VoteLimit: 1, + Timeout: *expiry, + }, + expErr: true, + }, + "option title too long": { + src: MsgCreatePoll{ + GroupId: 1, + Title: "2022 Election", + Options: Options{Titles: []string{"alice", longTitle}}, + Creator: memberAddr, + VoteLimit: 1, + Timeout: *expiry, + }, + expErr: true, + }, + "too many options": { + src: MsgCreatePoll{ + GroupId: 1, + Title: "2022 Election", + Options: Options{Titles: manyOptions}, + Creator: memberAddr, + VoteLimit: 2, + Timeout: *expiry, + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgVotePoll(t *testing.T) { + _, _, addr := testdata.KeyTestPubAddr() + memberAddr := addr.String() + + specs := map[string]struct { + src MsgVotePoll + expErr bool + }{ + "all good with minimum fields set": { + src: MsgVotePoll{ + PollId: 1, + Voter: memberAddr, + Options: Options{Titles: []string{"alice"}}, + }, + }, + "poll required": { + src: MsgVotePoll{ + Voter: memberAddr, + Options: Options{Titles: []string{"alice"}}, + }, + expErr: true, + }, + "options required": { + src: MsgVotePoll{ + PollId: 1, + Voter: memberAddr, + }, + expErr: true, + }, + "valid options required": { + src: MsgVotePoll{ + PollId: 1, + Voter: memberAddr, + Options: Options{Titles: []string{"alice", ""}}, + }, + expErr: true, + }, + "voter required": { + src: MsgVotePoll{ + PollId: 1, + Options: Options{Titles: []string{"alice"}}, + }, + expErr: true, + }, + "valid voter address required": { + src: MsgVotePoll{ + PollId: 1, + Voter: "invalid member address", + Options: Options{Titles: []string{"alice"}}, + }, + expErr: true, + }, + "empty voters address not allowed": { + src: MsgVotePoll{ + PollId: 1, + Voter: "", + Options: Options{Titles: []string{"alice"}}, + }, + expErr: true, + }, + "metadata too long": { + src: MsgVotePoll{ + PollId: 1, + Voter: memberAddr, + Options: Options{Titles: []string{"alice"}}, + Metadata: bytes.Repeat([]byte{1}, 256), + }, + expErr: true, + }, + } + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + err := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgVotePollAggRequest(t *testing.T) { + _, _, addr := testdata.KeyTestPubAddrBls12381() + memberAddr := addr.String() + + now := time.Now() + expiry, err := gogotypes.TimestampProto(now.Add(time.Second * 3000)) + require.NoError(t, err) + + specs := map[string]struct { + src MsgVotePollAgg + expErr bool + }{ + "all good with minimus fields": { + src: MsgVotePollAgg{ + Sender: memberAddr, + PollId: 1, + Votes: []Options{Options{Titles: []string{"alice", "bob"}}, Options{Titles: []string{"alice"}}}, + Expiry: *expiry, + AggSig: []byte("does not check signature"), + }, + }, + "poll required": { + src: MsgVotePollAgg{ + Sender: memberAddr, + Votes: []Options{Options{Titles: []string{"alice", "bob"}}, Options{Titles: []string{"alice"}}}, + Expiry: *expiry, + AggSig: []byte("does not check signature"), + }, + expErr: true, + }, + "votes required": { + src: MsgVotePollAgg{ + Sender: memberAddr, + PollId: 1, + Expiry: *expiry, + AggSig: []byte("does not check signature"), + }, + expErr: true, + }, + "valid votes required": { + src: MsgVotePollAgg{ + Sender: memberAddr, + PollId: 1, + Votes: []Options{Options{Titles: []string{"alice", ""}}, Options{Titles: []string{"alice"}}}, + Expiry: *expiry, + AggSig: []byte("does not check signature"), + }, + expErr: true, + }, + "sender required": { + src: MsgVotePollAgg{ + PollId: 1, + Votes: []Options{Options{Titles: []string{"alice", "bob"}}, Options{Titles: []string{"alice"}}}, + Expiry: *expiry, + AggSig: []byte("does not check signature"), + }, + expErr: true, + }, + "valid sender address required": { + src: MsgVotePollAgg{ + Sender: "invalid sender address", + PollId: 1, + Votes: []Options{Options{Titles: []string{"alice", "bob"}}, Options{Titles: []string{"alice"}}}, + Expiry: *expiry, + AggSig: []byte("does not check signature"), + }, + expErr: true, + }, + "empty signature": { + src: MsgVotePollAgg{ + Sender: memberAddr, + PollId: 1, + Votes: []Options{Options{Titles: []string{"alice", "bob"}}, Options{Titles: []string{"alice"}}}, + Expiry: *expiry, + }, + expErr: true, + }, + "metadata too long": { + src: MsgVotePollAgg{ + Sender: memberAddr, + PollId: 1, + Votes: []Options{Options{Titles: []string{"alice", "bob"}}, Options{Titles: []string{"alice"}}}, + Expiry: *expiry, + AggSig: []byte("does not check signature"), + Metadata: bytes.Repeat([]byte{1}, 256), + }, + expErr: true, + }, } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { diff --git a/x/group/query.pb.go b/x/group/query.pb.go index 5202c0f143..e74a3a1306 100644 --- a/x/group/query.pb.go +++ b/x/group/query.pb.go @@ -1177,1831 +1177,4664 @@ func (m *QueryVotesByVoterResponse) GetPagination() *query.PageResponse { return nil } -func init() { - proto.RegisterType((*QueryGroupInfoRequest)(nil), "regen.group.v1alpha1.QueryGroupInfoRequest") - proto.RegisterType((*QueryGroupInfoResponse)(nil), "regen.group.v1alpha1.QueryGroupInfoResponse") - proto.RegisterType((*QueryGroupAccountInfoRequest)(nil), "regen.group.v1alpha1.QueryGroupAccountInfoRequest") - proto.RegisterType((*QueryGroupAccountInfoResponse)(nil), "regen.group.v1alpha1.QueryGroupAccountInfoResponse") - proto.RegisterType((*QueryGroupMembersRequest)(nil), "regen.group.v1alpha1.QueryGroupMembersRequest") - proto.RegisterType((*QueryGroupMembersResponse)(nil), "regen.group.v1alpha1.QueryGroupMembersResponse") - proto.RegisterType((*QueryGroupsByAdminRequest)(nil), "regen.group.v1alpha1.QueryGroupsByAdminRequest") - proto.RegisterType((*QueryGroupsByAdminResponse)(nil), "regen.group.v1alpha1.QueryGroupsByAdminResponse") - proto.RegisterType((*QueryGroupAccountsByGroupRequest)(nil), "regen.group.v1alpha1.QueryGroupAccountsByGroupRequest") - proto.RegisterType((*QueryGroupAccountsByGroupResponse)(nil), "regen.group.v1alpha1.QueryGroupAccountsByGroupResponse") - proto.RegisterType((*QueryGroupAccountsByAdminRequest)(nil), "regen.group.v1alpha1.QueryGroupAccountsByAdminRequest") - proto.RegisterType((*QueryGroupAccountsByAdminResponse)(nil), "regen.group.v1alpha1.QueryGroupAccountsByAdminResponse") - proto.RegisterType((*QueryProposalRequest)(nil), "regen.group.v1alpha1.QueryProposalRequest") - proto.RegisterType((*QueryProposalResponse)(nil), "regen.group.v1alpha1.QueryProposalResponse") - proto.RegisterType((*QueryProposalsByGroupAccountRequest)(nil), "regen.group.v1alpha1.QueryProposalsByGroupAccountRequest") - proto.RegisterType((*QueryProposalsByGroupAccountResponse)(nil), "regen.group.v1alpha1.QueryProposalsByGroupAccountResponse") - proto.RegisterType((*QueryVoteByProposalVoterRequest)(nil), "regen.group.v1alpha1.QueryVoteByProposalVoterRequest") - proto.RegisterType((*QueryVoteByProposalVoterResponse)(nil), "regen.group.v1alpha1.QueryVoteByProposalVoterResponse") - proto.RegisterType((*QueryVotesByProposalRequest)(nil), "regen.group.v1alpha1.QueryVotesByProposalRequest") - proto.RegisterType((*QueryVotesByProposalResponse)(nil), "regen.group.v1alpha1.QueryVotesByProposalResponse") - proto.RegisterType((*QueryVotesByVoterRequest)(nil), "regen.group.v1alpha1.QueryVotesByVoterRequest") - proto.RegisterType((*QueryVotesByVoterResponse)(nil), "regen.group.v1alpha1.QueryVotesByVoterResponse") +// QueryPollRequest is the Query/Poll request type. +type QueryPollRequest struct { + // poll_id is the unique ID of a poll. + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` } -func init() { proto.RegisterFile("regen/group/v1alpha1/query.proto", fileDescriptor_2523b81f3b315123) } - -var fileDescriptor_2523b81f3b315123 = []byte{ - // 1084 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xdf, 0x6b, 0x1c, 0x55, - 0x14, 0xee, 0xad, 0x69, 0x93, 0x9c, 0xb4, 0x56, 0xae, 0xab, 0x6e, 0xc7, 0xba, 0x49, 0xc7, 0x50, - 0x4b, 0x93, 0xcc, 0xcd, 0xee, 0x9a, 0x6e, 0x4c, 0x54, 0xec, 0x0a, 0x96, 0x3c, 0x04, 0xea, 0x0a, - 0x22, 0xfa, 0x20, 0xb3, 0xd9, 0xe9, 0x74, 0x31, 0x3b, 0x77, 0xba, 0x33, 0x1b, 0x1a, 0xc2, 0x82, - 0x08, 0xea, 0xab, 0x20, 0x08, 0x8a, 0x0a, 0x3e, 0xe9, 0x8b, 0x6f, 0xfa, 0x24, 0x08, 0xbe, 0xe9, - 0x83, 0x50, 0xf4, 0xc5, 0x47, 0x49, 0xfc, 0x43, 0x64, 0xee, 0x8f, 0xf9, 0xb1, 0x7b, 0x77, 0x7e, - 0x94, 0xa5, 0xfa, 0x94, 0xbd, 0x93, 0xf3, 0xdd, 0xf3, 0x9d, 0xef, 0x9c, 0xb9, 0xf7, 0x63, 0x60, - 0xa9, 0x6f, 0xd9, 0x96, 0x43, 0xec, 0x3e, 0x1d, 0xb8, 0xe4, 0xa0, 0x6a, 0xee, 0xbb, 0x77, 0xcc, - 0x2a, 0xb9, 0x3b, 0xb0, 0xfa, 0x87, 0x86, 0xdb, 0xa7, 0x3e, 0xc5, 0x25, 0x16, 0x61, 0xb0, 0x08, - 0x43, 0x46, 0x68, 0x6a, 0x9c, 0x7f, 0xe8, 0x5a, 0x1e, 0xc7, 0x69, 0x97, 0x6c, 0x4a, 0xed, 0x7d, - 0x8b, 0x98, 0x6e, 0x97, 0x98, 0x8e, 0x43, 0x7d, 0xd3, 0xef, 0x52, 0x47, 0xfe, 0xb7, 0x64, 0x53, - 0x9b, 0xb2, 0x9f, 0x24, 0xf8, 0x25, 0x9e, 0x5e, 0xdb, 0xa3, 0x5e, 0x8f, 0x7a, 0xa4, 0x6d, 0x7a, - 0x16, 0x27, 0x41, 0x0e, 0xaa, 0x6d, 0xcb, 0x37, 0xab, 0xc4, 0x35, 0xed, 0xae, 0xc3, 0xb6, 0xe0, - 0xb1, 0x7a, 0x0d, 0x9e, 0x78, 0x3d, 0x88, 0xb8, 0x19, 0x50, 0xd8, 0x71, 0x6e, 0xd3, 0x96, 0x75, - 0x77, 0x60, 0x79, 0x3e, 0xbe, 0x08, 0x73, 0x8c, 0xd6, 0xbb, 0xdd, 0x4e, 0x19, 0x2d, 0xa1, 0xab, - 0x33, 0xad, 0x59, 0xb6, 0xde, 0xe9, 0xe8, 0xbb, 0xf0, 0xe4, 0x28, 0xc6, 0x73, 0xa9, 0xe3, 0x59, - 0xb8, 0x0e, 0x33, 0x5d, 0xe7, 0x36, 0x65, 0x80, 0x85, 0xda, 0xa2, 0xa1, 0x2a, 0xda, 0x88, 0x60, - 0x2c, 0x58, 0xdf, 0x84, 0x4b, 0xd1, 0x76, 0x37, 0xf6, 0xf6, 0xe8, 0xc0, 0xf1, 0xe3, 0x4c, 0xca, - 0x30, 0x6b, 0x76, 0x3a, 0x7d, 0xcb, 0xf3, 0xd8, 0xbe, 0xf3, 0x2d, 0xb9, 0xd4, 0xdf, 0x81, 0x67, - 0x26, 0x20, 0x05, 0x9f, 0xad, 0x04, 0x9f, 0x2b, 0x29, 0x7c, 0xe2, 0x68, 0x4e, 0x6b, 0x08, 0xe5, - 0x68, 0xf3, 0x5d, 0xab, 0xd7, 0xb6, 0xfa, 0x5e, 0xb6, 0x38, 0xf8, 0x35, 0x80, 0x48, 0xe4, 0xf2, - 0x69, 0x91, 0x98, 0x77, 0xc4, 0x08, 0x3a, 0x62, 0xf0, 0xb1, 0x10, 0x1d, 0x31, 0x6e, 0x99, 0xb6, - 0x25, 0xb6, 0x6d, 0xc5, 0x90, 0xfa, 0x37, 0x08, 0x2e, 0x2a, 0xf2, 0x8b, 0xc2, 0xb6, 0x61, 0xb6, - 0xc7, 0x1f, 0x95, 0xd1, 0xd2, 0x23, 0x57, 0x17, 0x6a, 0x97, 0x53, 0x6a, 0xe3, 0xe0, 0x96, 0x44, - 0xe0, 0x9b, 0x0a, 0x8a, 0xcf, 0x65, 0x52, 0xe4, 0x99, 0x13, 0x1c, 0x0f, 0xe3, 0x14, 0xbd, 0xe6, - 0xe1, 0x8d, 0x4e, 0xaf, 0xeb, 0x48, 0x8d, 0x4a, 0x70, 0xc6, 0x0c, 0xd6, 0xa2, 0x69, 0x7c, 0x31, - 0x35, 0x79, 0xbe, 0x46, 0xa0, 0xa9, 0x72, 0x0b, 0x7d, 0x1a, 0x70, 0x96, 0x29, 0x21, 0xe5, 0xc9, - 0x1c, 0x45, 0x11, 0x3e, 0x3d, 0x6d, 0x3e, 0x44, 0xb0, 0x34, 0x36, 0x9c, 0x5e, 0x93, 0x2f, 0x1f, - 0xe2, 0x1c, 0xfd, 0x84, 0xe0, 0x72, 0x0a, 0x0f, 0xa1, 0xd7, 0x2e, 0x3c, 0xca, 0x89, 0x98, 0x22, - 0x40, 0xe8, 0x96, 0xf7, 0x95, 0x39, 0x6f, 0xc7, 0x77, 0x9f, 0x9e, 0x8a, 0xef, 0x4f, 0x50, 0xf1, - 0x21, 0x4e, 0xda, 0x24, 0x01, 0x93, 0x03, 0xf7, 0x7f, 0x15, 0xb0, 0x01, 0x25, 0x46, 0xfe, 0x56, - 0x9f, 0xba, 0xd4, 0x33, 0xf7, 0xa5, 0x66, 0x8b, 0xb0, 0xe0, 0x8a, 0x47, 0xd1, 0xf0, 0x81, 0x7c, - 0xb4, 0xd3, 0xd1, 0xdf, 0x10, 0x17, 0x43, 0x04, 0x0c, 0xcf, 0xd4, 0x39, 0x19, 0x26, 0xce, 0xd5, - 0x8a, 0xba, 0xc6, 0x10, 0x19, 0xc6, 0xeb, 0x1f, 0x23, 0x78, 0x36, 0xb1, 0xab, 0x1c, 0x44, 0x51, - 0x78, 0xe6, 0x91, 0x3f, 0xb5, 0xae, 0x7e, 0x8f, 0x60, 0x39, 0x9d, 0x89, 0x28, 0xf7, 0x45, 0x98, - 0x97, 0xf4, 0x65, 0x4f, 0xb3, 0xea, 0x8d, 0x00, 0xd3, 0xeb, 0xe3, 0x5b, 0xb0, 0xc8, 0xe8, 0xbe, - 0x49, 0x7d, 0xab, 0x19, 0x92, 0x0e, 0x56, 0xfd, 0xbc, 0x2d, 0x0d, 0xde, 0x93, 0x83, 0x00, 0xc0, - 0x78, 0xcc, 0xb7, 0xf8, 0x42, 0x6f, 0x89, 0x37, 0x4c, 0xb9, 0xb3, 0x10, 0xc1, 0x80, 0x99, 0x20, - 0x58, 0xf4, 0x5b, 0x53, 0xd7, 0x1f, 0x40, 0x5a, 0x2c, 0x4e, 0xff, 0x08, 0xc1, 0xd3, 0xe1, 0xa6, - 0x5e, 0xb3, 0xf0, 0xf4, 0x4d, 0xad, 0xcd, 0x9f, 0x23, 0x61, 0x2e, 0xc6, 0x88, 0x88, 0xca, 0xd6, - 0xb9, 0x26, 0xb2, 0xb5, 0x69, 0xa5, 0xf1, 0xc0, 0xe9, 0xb5, 0xf4, 0x9e, 0x30, 0x18, 0x82, 0x5a, - 0xa2, 0x97, 0x61, 0xab, 0x50, 0xac, 0x55, 0x53, 0x53, 0xe5, 0x33, 0xe9, 0x2d, 0x92, 0xa9, 0xff, - 0x73, 0x49, 0x6a, 0xbf, 0x5f, 0x80, 0x33, 0x8c, 0x18, 0xfe, 0x12, 0xc1, 0x7c, 0x78, 0x3b, 0xe3, - 0x15, 0x35, 0x07, 0xa5, 0x73, 0xd5, 0x56, 0xf3, 0x05, 0xf3, 0xf4, 0xfa, 0xf3, 0x1f, 0xfc, 0xf9, - 0xcf, 0xa7, 0xa7, 0x0d, 0xbc, 0x4a, 0x94, 0x5e, 0x9c, 0xdb, 0x02, 0x72, 0x24, 0xaf, 0xe9, 0x21, - 0x09, 0xcc, 0x21, 0xfe, 0x01, 0xc1, 0x63, 0xa3, 0x67, 0x38, 0xae, 0x65, 0x25, 0x1e, 0x37, 0xb7, - 0x5a, 0xbd, 0x10, 0x46, 0x70, 0x6e, 0x30, 0xce, 0x55, 0x4c, 0x52, 0x39, 0xcb, 0x9b, 0x88, 0x1c, - 0x89, 0xc3, 0x73, 0x88, 0xbf, 0x43, 0x70, 0x2e, 0xee, 0x27, 0xb1, 0x91, 0x95, 0x3e, 0x69, 0x7c, - 0x35, 0x92, 0x3b, 0xbe, 0x10, 0xd5, 0x98, 0xbc, 0xd2, 0xa4, 0x7e, 0x8b, 0xe0, 0x7c, 0xc2, 0xdb, - 0xe1, 0xcc, 0xdc, 0x23, 0xbe, 0x40, 0x5b, 0xcf, 0x0f, 0x10, 0x6c, 0xeb, 0x8c, 0xed, 0x1a, 0x5e, - 0x49, 0x17, 0x36, 0xc0, 0x30, 0x59, 0x7b, 0x5d, 0x67, 0x88, 0x7f, 0x41, 0x50, 0x52, 0x99, 0x2b, - 0x7c, 0x3d, 0x67, 0x6f, 0x47, 0x5c, 0xa1, 0xd6, 0x28, 0x8c, 0x13, 0xf4, 0x37, 0x19, 0xfd, 0x1a, - 0x5e, 0xcf, 0x2b, 0xb6, 0x1c, 0x11, 0xfc, 0xf3, 0x78, 0x0d, 0x5c, 0xf4, 0x02, 0x35, 0x24, 0xb4, - 0x6f, 0x14, 0xc6, 0x89, 0x1a, 0x36, 0x58, 0x0d, 0x04, 0xaf, 0xa9, 0x6b, 0x48, 0x6a, 0x1f, 0x15, - 0xf0, 0x05, 0x82, 0x39, 0x79, 0xb8, 0xe3, 0x6b, 0x29, 0xc9, 0x47, 0xae, 0x22, 0x6d, 0x25, 0x57, - 0x6c, 0x3e, 0x72, 0xe1, 0xbd, 0x4f, 0x8e, 0x62, 0xd7, 0xdb, 0x10, 0xff, 0x81, 0xe0, 0xa9, 0x09, - 0x3e, 0x03, 0xbf, 0x90, 0x23, 0xbf, 0xda, 0x25, 0x69, 0x5b, 0x0f, 0x02, 0x15, 0x95, 0xbc, 0xc2, - 0x2a, 0xd9, 0xc2, 0x9b, 0x29, 0xa3, 0xb2, 0x36, 0x7e, 0x82, 0x44, 0x25, 0xe2, 0xdf, 0x10, 0x3c, - 0xae, 0xf0, 0x0c, 0x78, 0x23, 0x85, 0xd5, 0x64, 0xf7, 0xa2, 0x5d, 0x2f, 0x0a, 0x13, 0x85, 0xbc, - 0xca, 0x0a, 0x79, 0x09, 0x6f, 0x17, 0x6a, 0x09, 0x61, 0x17, 0x17, 0x39, 0x62, 0xf7, 0xea, 0x10, - 0xff, 0x88, 0xe0, 0xc2, 0x88, 0x43, 0xc0, 0xd5, 0x0c, 0x42, 0xe3, 0xb6, 0x46, 0xab, 0x15, 0x81, - 0x08, 0xfe, 0xdb, 0x8c, 0xff, 0x06, 0xae, 0x3f, 0x00, 0x7f, 0xfc, 0x15, 0x82, 0x73, 0xf1, 0x3b, - 0x3c, 0xf5, 0x3c, 0x57, 0xf8, 0x8c, 0xd4, 0xf3, 0x5c, 0x65, 0x0e, 0xf4, 0x55, 0x46, 0xf7, 0x0a, - 0x5e, 0x56, 0xd3, 0x65, 0x7a, 0x86, 0xba, 0x36, 0x5f, 0xfe, 0xf5, 0xb8, 0x82, 0xee, 0x1f, 0x57, - 0xd0, 0xdf, 0xc7, 0x15, 0xf4, 0xc9, 0x49, 0xe5, 0xd4, 0xfd, 0x93, 0xca, 0xa9, 0xbf, 0x4e, 0x2a, - 0xa7, 0xde, 0x5e, 0xb6, 0xbb, 0xfe, 0x9d, 0x41, 0xdb, 0xd8, 0xa3, 0x3d, 0x22, 0x3e, 0x57, 0xf1, - 0x3f, 0x6b, 0x5e, 0xe7, 0x3d, 0x72, 0x8f, 0xef, 0xdb, 0x3e, 0xcb, 0x3e, 0x52, 0xd5, 0xff, 0x0d, - 0x00, 0x00, 0xff, 0xff, 0xe6, 0x36, 0xbb, 0xc3, 0x60, 0x13, 0x00, 0x00, +func (m *QueryPollRequest) Reset() { *m = QueryPollRequest{} } +func (m *QueryPollRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPollRequest) ProtoMessage() {} +func (*QueryPollRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{22} } - -// 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 { - // GroupInfo queries group info based on group id. - GroupInfo(ctx context.Context, in *QueryGroupInfoRequest, opts ...grpc.CallOption) (*QueryGroupInfoResponse, error) - // GroupAccountInfo queries group account info based on group account address. - GroupAccountInfo(ctx context.Context, in *QueryGroupAccountInfoRequest, opts ...grpc.CallOption) (*QueryGroupAccountInfoResponse, error) - // GroupMembers queries members of a group - GroupMembers(ctx context.Context, in *QueryGroupMembersRequest, opts ...grpc.CallOption) (*QueryGroupMembersResponse, error) - // GroupsByAdmin queries groups by admin address. - GroupsByAdmin(ctx context.Context, in *QueryGroupsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupsByAdminResponse, error) - // GroupAccountsByGroup queries group accounts by group id. - GroupAccountsByGroup(ctx context.Context, in *QueryGroupAccountsByGroupRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByGroupResponse, error) - // GroupsByAdmin queries group accounts by admin address. - GroupAccountsByAdmin(ctx context.Context, in *QueryGroupAccountsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByAdminResponse, error) - // Proposal queries a proposal based on proposal id. - Proposal(ctx context.Context, in *QueryProposalRequest, opts ...grpc.CallOption) (*QueryProposalResponse, error) - // ProposalsByGroupAccount queries proposals based on group account address. - ProposalsByGroupAccount(ctx context.Context, in *QueryProposalsByGroupAccountRequest, opts ...grpc.CallOption) (*QueryProposalsByGroupAccountResponse, error) - // VoteByProposalVoter queries a vote by proposal id and voter. - VoteByProposalVoter(ctx context.Context, in *QueryVoteByProposalVoterRequest, opts ...grpc.CallOption) (*QueryVoteByProposalVoterResponse, error) - // VotesByProposal queries a vote by proposal. - VotesByProposal(ctx context.Context, in *QueryVotesByProposalRequest, opts ...grpc.CallOption) (*QueryVotesByProposalResponse, error) - // VotesByVoter queries a vote by voter. - VotesByVoter(ctx context.Context, in *QueryVotesByVoterRequest, opts ...grpc.CallOption) (*QueryVotesByVoterResponse, error) +func (m *QueryPollRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } - -type queryClient struct { - cc grpc1.ClientConn +func (m *QueryPollRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPollRequest.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 NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} +func (m *QueryPollRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPollRequest.Merge(m, src) +} +func (m *QueryPollRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPollRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPollRequest.DiscardUnknown(m) } -func (c *queryClient) GroupInfo(ctx context.Context, in *QueryGroupInfoRequest, opts ...grpc.CallOption) (*QueryGroupInfoResponse, error) { - out := new(QueryGroupInfoResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupInfo", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_QueryPollRequest proto.InternalMessageInfo + +func (m *QueryPollRequest) GetPollId() uint64 { + if m != nil { + return m.PollId } - return out, nil + return 0 } -func (c *queryClient) GroupAccountInfo(ctx context.Context, in *QueryGroupAccountInfoRequest, opts ...grpc.CallOption) (*QueryGroupAccountInfoResponse, error) { - out := new(QueryGroupAccountInfoResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupAccountInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +// QueryPollResponse is the Query/Poll response type. +type QueryPollResponse struct { + // poll is the poll info. + Poll *Poll `protobuf:"bytes,1,opt,name=poll,proto3" json:"poll,omitempty"` } -func (c *queryClient) GroupMembers(ctx context.Context, in *QueryGroupMembersRequest, opts ...grpc.CallOption) (*QueryGroupMembersResponse, error) { - out := new(QueryGroupMembersResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupMembers", in, out, opts...) - if err != nil { - return nil, err +func (m *QueryPollResponse) Reset() { *m = QueryPollResponse{} } +func (m *QueryPollResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPollResponse) ProtoMessage() {} +func (*QueryPollResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{23} +} +func (m *QueryPollResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPollResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPollResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil +} +func (m *QueryPollResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPollResponse.Merge(m, src) +} +func (m *QueryPollResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPollResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPollResponse.DiscardUnknown(m) } -func (c *queryClient) GroupsByAdmin(ctx context.Context, in *QueryGroupsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupsByAdminResponse, error) { - out := new(QueryGroupsByAdminResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupsByAdmin", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_QueryPollResponse proto.InternalMessageInfo + +func (m *QueryPollResponse) GetPoll() *Poll { + if m != nil { + return m.Poll } - return out, nil + return nil } -func (c *queryClient) GroupAccountsByGroup(ctx context.Context, in *QueryGroupAccountsByGroupRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByGroupResponse, error) { - out := new(QueryGroupAccountsByGroupResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupAccountsByGroup", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +// QueryPollsByGroupRequest is the Query/PollByGroup request type. +type QueryPollsByGroupRequest struct { + // group_id is the group id related to polls. + GroupId uint64 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (c *queryClient) GroupAccountsByAdmin(ctx context.Context, in *QueryGroupAccountsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByAdminResponse, error) { - out := new(QueryGroupAccountsByAdminResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupAccountsByAdmin", in, out, opts...) - if err != nil { - return nil, err +func (m *QueryPollsByGroupRequest) Reset() { *m = QueryPollsByGroupRequest{} } +func (m *QueryPollsByGroupRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPollsByGroupRequest) ProtoMessage() {} +func (*QueryPollsByGroupRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{24} +} +func (m *QueryPollsByGroupRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPollsByGroupRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPollsByGroupRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil +} +func (m *QueryPollsByGroupRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPollsByGroupRequest.Merge(m, src) +} +func (m *QueryPollsByGroupRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPollsByGroupRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPollsByGroupRequest.DiscardUnknown(m) } -func (c *queryClient) Proposal(ctx context.Context, in *QueryProposalRequest, opts ...grpc.CallOption) (*QueryProposalResponse, error) { - out := new(QueryProposalResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/Proposal", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_QueryPollsByGroupRequest proto.InternalMessageInfo + +func (m *QueryPollsByGroupRequest) GetGroupId() uint64 { + if m != nil { + return m.GroupId } - return out, nil + return 0 } -func (c *queryClient) ProposalsByGroupAccount(ctx context.Context, in *QueryProposalsByGroupAccountRequest, opts ...grpc.CallOption) (*QueryProposalsByGroupAccountResponse, error) { - out := new(QueryProposalsByGroupAccountResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/ProposalsByGroupAccount", in, out, opts...) - if err != nil { - return nil, err +func (m *QueryPollsByGroupRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination } - return out, nil + return nil } -func (c *queryClient) VoteByProposalVoter(ctx context.Context, in *QueryVoteByProposalVoterRequest, opts ...grpc.CallOption) (*QueryVoteByProposalVoterResponse, error) { - out := new(QueryVoteByProposalVoterResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VoteByProposalVoter", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +// QueryPollsByGroupResponse is the Query/PollByGroup response type. +type QueryPollsByGroupResponse struct { + // polls are the polls with given group id. + Polls []*Poll `protobuf:"bytes,1,rep,name=polls,proto3" json:"polls,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (c *queryClient) VotesByProposal(ctx context.Context, in *QueryVotesByProposalRequest, opts ...grpc.CallOption) (*QueryVotesByProposalResponse, error) { - out := new(QueryVotesByProposalResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VotesByProposal", in, out, opts...) - if err != nil { - return nil, err +func (m *QueryPollsByGroupResponse) Reset() { *m = QueryPollsByGroupResponse{} } +func (m *QueryPollsByGroupResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPollsByGroupResponse) ProtoMessage() {} +func (*QueryPollsByGroupResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{25} +} +func (m *QueryPollsByGroupResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPollsByGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPollsByGroupResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil +} +func (m *QueryPollsByGroupResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPollsByGroupResponse.Merge(m, src) +} +func (m *QueryPollsByGroupResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPollsByGroupResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPollsByGroupResponse.DiscardUnknown(m) } -func (c *queryClient) VotesByVoter(ctx context.Context, in *QueryVotesByVoterRequest, opts ...grpc.CallOption) (*QueryVotesByVoterResponse, error) { - out := new(QueryVotesByVoterResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VotesByVoter", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_QueryPollsByGroupResponse proto.InternalMessageInfo + +func (m *QueryPollsByGroupResponse) GetPolls() []*Poll { + if m != nil { + return m.Polls } - return out, nil + return nil } -// QueryServer is the server API for Query service. -type QueryServer interface { - // GroupInfo queries group info based on group id. - GroupInfo(context.Context, *QueryGroupInfoRequest) (*QueryGroupInfoResponse, error) - // GroupAccountInfo queries group account info based on group account address. - GroupAccountInfo(context.Context, *QueryGroupAccountInfoRequest) (*QueryGroupAccountInfoResponse, error) - // GroupMembers queries members of a group - GroupMembers(context.Context, *QueryGroupMembersRequest) (*QueryGroupMembersResponse, error) - // GroupsByAdmin queries groups by admin address. - GroupsByAdmin(context.Context, *QueryGroupsByAdminRequest) (*QueryGroupsByAdminResponse, error) - // GroupAccountsByGroup queries group accounts by group id. - GroupAccountsByGroup(context.Context, *QueryGroupAccountsByGroupRequest) (*QueryGroupAccountsByGroupResponse, error) - // GroupsByAdmin queries group accounts by admin address. - GroupAccountsByAdmin(context.Context, *QueryGroupAccountsByAdminRequest) (*QueryGroupAccountsByAdminResponse, error) - // Proposal queries a proposal based on proposal id. - Proposal(context.Context, *QueryProposalRequest) (*QueryProposalResponse, error) - // ProposalsByGroupAccount queries proposals based on group account address. - ProposalsByGroupAccount(context.Context, *QueryProposalsByGroupAccountRequest) (*QueryProposalsByGroupAccountResponse, error) - // VoteByProposalVoter queries a vote by proposal id and voter. - VoteByProposalVoter(context.Context, *QueryVoteByProposalVoterRequest) (*QueryVoteByProposalVoterResponse, error) - // VotesByProposal queries a vote by proposal. - VotesByProposal(context.Context, *QueryVotesByProposalRequest) (*QueryVotesByProposalResponse, error) - // VotesByVoter queries a vote by voter. - VotesByVoter(context.Context, *QueryVotesByVoterRequest) (*QueryVotesByVoterResponse, error) +func (m *QueryPollsByGroupResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil } -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { +// QueryPollsByCreatorRequest is the Query/PollByCreator request type. +type QueryPollsByCreatorRequest struct { + // creator is the creator address related to polls. + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (*UnimplementedQueryServer) GroupInfo(ctx context.Context, req *QueryGroupInfoRequest) (*QueryGroupInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GroupInfo not implemented") -} -func (*UnimplementedQueryServer) GroupAccountInfo(ctx context.Context, req *QueryGroupAccountInfoRequest) (*QueryGroupAccountInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GroupAccountInfo not implemented") +func (m *QueryPollsByCreatorRequest) Reset() { *m = QueryPollsByCreatorRequest{} } +func (m *QueryPollsByCreatorRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPollsByCreatorRequest) ProtoMessage() {} +func (*QueryPollsByCreatorRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{26} } -func (*UnimplementedQueryServer) GroupMembers(ctx context.Context, req *QueryGroupMembersRequest) (*QueryGroupMembersResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GroupMembers not implemented") +func (m *QueryPollsByCreatorRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } -func (*UnimplementedQueryServer) GroupsByAdmin(ctx context.Context, req *QueryGroupsByAdminRequest) (*QueryGroupsByAdminResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GroupsByAdmin not implemented") -} -func (*UnimplementedQueryServer) GroupAccountsByGroup(ctx context.Context, req *QueryGroupAccountsByGroupRequest) (*QueryGroupAccountsByGroupResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GroupAccountsByGroup not implemented") -} -func (*UnimplementedQueryServer) GroupAccountsByAdmin(ctx context.Context, req *QueryGroupAccountsByAdminRequest) (*QueryGroupAccountsByAdminResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GroupAccountsByAdmin not implemented") +func (m *QueryPollsByCreatorRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPollsByCreatorRequest.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 (*UnimplementedQueryServer) Proposal(ctx context.Context, req *QueryProposalRequest) (*QueryProposalResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Proposal not implemented") +func (m *QueryPollsByCreatorRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPollsByCreatorRequest.Merge(m, src) } -func (*UnimplementedQueryServer) ProposalsByGroupAccount(ctx context.Context, req *QueryProposalsByGroupAccountRequest) (*QueryProposalsByGroupAccountResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ProposalsByGroupAccount not implemented") +func (m *QueryPollsByCreatorRequest) XXX_Size() int { + return m.Size() } -func (*UnimplementedQueryServer) VoteByProposalVoter(ctx context.Context, req *QueryVoteByProposalVoterRequest) (*QueryVoteByProposalVoterResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method VoteByProposalVoter not implemented") +func (m *QueryPollsByCreatorRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPollsByCreatorRequest.DiscardUnknown(m) } -func (*UnimplementedQueryServer) VotesByProposal(ctx context.Context, req *QueryVotesByProposalRequest) (*QueryVotesByProposalResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method VotesByProposal not implemented") + +var xxx_messageInfo_QueryPollsByCreatorRequest proto.InternalMessageInfo + +func (m *QueryPollsByCreatorRequest) GetCreator() string { + if m != nil { + return m.Creator + } + return "" } -func (*UnimplementedQueryServer) VotesByVoter(ctx context.Context, req *QueryVotesByVoterRequest) (*QueryVotesByVoterResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method VotesByVoter not implemented") + +func (m *QueryPollsByCreatorRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil } -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) +// QueryPollsByCreatorResponse is the Query/PollsByCreator response type. +type QueryPollsByCreatorResponse struct { + // polls are the polls with given creator. + Polls []*Poll `protobuf:"bytes,1,rep,name=polls,proto3" json:"polls,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func _Query_GroupInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGroupInfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GroupInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/GroupInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GroupInfo(ctx, req.(*QueryGroupInfoRequest)) +func (m *QueryPollsByCreatorResponse) Reset() { *m = QueryPollsByCreatorResponse{} } +func (m *QueryPollsByCreatorResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPollsByCreatorResponse) ProtoMessage() {} +func (*QueryPollsByCreatorResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{27} +} +func (m *QueryPollsByCreatorResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPollsByCreatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPollsByCreatorResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return interceptor(ctx, in, info, handler) +} +func (m *QueryPollsByCreatorResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPollsByCreatorResponse.Merge(m, src) +} +func (m *QueryPollsByCreatorResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPollsByCreatorResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPollsByCreatorResponse.DiscardUnknown(m) } -func _Query_GroupAccountInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGroupAccountInfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GroupAccountInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/GroupAccountInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GroupAccountInfo(ctx, req.(*QueryGroupAccountInfoRequest)) +var xxx_messageInfo_QueryPollsByCreatorResponse proto.InternalMessageInfo + +func (m *QueryPollsByCreatorResponse) GetPolls() []*Poll { + if m != nil { + return m.Polls } - return interceptor(ctx, in, info, handler) + return nil } -func _Query_GroupMembers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGroupMembersRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GroupMembers(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/GroupMembers", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GroupMembers(ctx, req.(*QueryGroupMembersRequest)) +func (m *QueryPollsByCreatorResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination } - return interceptor(ctx, in, info, handler) + return nil } -func _Query_GroupsByAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGroupsByAdminRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GroupsByAdmin(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/GroupsByAdmin", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GroupsByAdmin(ctx, req.(*QueryGroupsByAdminRequest)) - } - return interceptor(ctx, in, info, handler) +// QueryVoteForPollByPollVoterRequest is the Query/VotePollByPollVoter request type. +type QueryVoteForPollByPollVoterRequest struct { + // poll_id is the unique ID of a poll. + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` + // voter is a poll voter account address. + Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"` } -func _Query_GroupAccountsByGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGroupAccountsByGroupRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GroupAccountsByGroup(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/GroupAccountsByGroup", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GroupAccountsByGroup(ctx, req.(*QueryGroupAccountsByGroupRequest)) +func (m *QueryVoteForPollByPollVoterRequest) Reset() { *m = QueryVoteForPollByPollVoterRequest{} } +func (m *QueryVoteForPollByPollVoterRequest) String() string { return proto.CompactTextString(m) } +func (*QueryVoteForPollByPollVoterRequest) ProtoMessage() {} +func (*QueryVoteForPollByPollVoterRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{28} +} +func (m *QueryVoteForPollByPollVoterRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVoteForPollByPollVoterRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVoteForPollByPollVoterRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return interceptor(ctx, in, info, handler) +} +func (m *QueryVoteForPollByPollVoterRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVoteForPollByPollVoterRequest.Merge(m, src) +} +func (m *QueryVoteForPollByPollVoterRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryVoteForPollByPollVoterRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVoteForPollByPollVoterRequest.DiscardUnknown(m) } -func _Query_GroupAccountsByAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGroupAccountsByAdminRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GroupAccountsByAdmin(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/GroupAccountsByAdmin", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GroupAccountsByAdmin(ctx, req.(*QueryGroupAccountsByAdminRequest)) +var xxx_messageInfo_QueryVoteForPollByPollVoterRequest proto.InternalMessageInfo + +func (m *QueryVoteForPollByPollVoterRequest) GetPollId() uint64 { + if m != nil { + return m.PollId } - return interceptor(ctx, in, info, handler) + return 0 } -func _Query_Proposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryProposalRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Proposal(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/Proposal", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Proposal(ctx, req.(*QueryProposalRequest)) +func (m *QueryVoteForPollByPollVoterRequest) GetVoter() string { + if m != nil { + return m.Voter } - return interceptor(ctx, in, info, handler) + return "" } -func _Query_ProposalsByGroupAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryProposalsByGroupAccountRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ProposalsByGroupAccount(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/ProposalsByGroupAccount", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ProposalsByGroupAccount(ctx, req.(*QueryProposalsByGroupAccountRequest)) - } - return interceptor(ctx, in, info, handler) +// QueryVotesForPollByPollVoterResponse is the Query/VotePollByPollVoter response type. +type QueryVoteForPollByPollVoterResponse struct { + // vote is the vote with given poll_id and voter. + Vote *VotePoll `protobuf:"bytes,1,opt,name=vote,proto3" json:"vote,omitempty"` } -func _Query_VoteByProposalVoter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryVoteByProposalVoterRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).VoteByProposalVoter(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/VoteByProposalVoter", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).VoteByProposalVoter(ctx, req.(*QueryVoteByProposalVoterRequest)) +func (m *QueryVoteForPollByPollVoterResponse) Reset() { *m = QueryVoteForPollByPollVoterResponse{} } +func (m *QueryVoteForPollByPollVoterResponse) String() string { return proto.CompactTextString(m) } +func (*QueryVoteForPollByPollVoterResponse) ProtoMessage() {} +func (*QueryVoteForPollByPollVoterResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{29} +} +func (m *QueryVoteForPollByPollVoterResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVoteForPollByPollVoterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVoteForPollByPollVoterResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return interceptor(ctx, in, info, handler) +} +func (m *QueryVoteForPollByPollVoterResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVoteForPollByPollVoterResponse.Merge(m, src) +} +func (m *QueryVoteForPollByPollVoterResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryVoteForPollByPollVoterResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVoteForPollByPollVoterResponse.DiscardUnknown(m) } -func _Query_VotesByProposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryVotesByProposalRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).VotesByProposal(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/VotesByProposal", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).VotesByProposal(ctx, req.(*QueryVotesByProposalRequest)) +var xxx_messageInfo_QueryVoteForPollByPollVoterResponse proto.InternalMessageInfo + +func (m *QueryVoteForPollByPollVoterResponse) GetVote() *VotePoll { + if m != nil { + return m.Vote } - return interceptor(ctx, in, info, handler) + return nil } -func _Query_VotesByVoter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryVotesByVoterRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).VotesByVoter(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Query/VotesByVoter", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).VotesByVoter(ctx, req.(*QueryVotesByVoterRequest)) - } - return interceptor(ctx, in, info, handler) +// QueryVotesForPollByPollRequest is the Query/VotePollsByPoll request type. +type QueryVotesForPollByPollRequest struct { + // poll_id is the unique ID of a poll. + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "regen.group.v1alpha1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GroupInfo", - Handler: _Query_GroupInfo_Handler, - }, - { - MethodName: "GroupAccountInfo", - Handler: _Query_GroupAccountInfo_Handler, - }, - { - MethodName: "GroupMembers", - Handler: _Query_GroupMembers_Handler, - }, - { - MethodName: "GroupsByAdmin", - Handler: _Query_GroupsByAdmin_Handler, - }, - { - MethodName: "GroupAccountsByGroup", - Handler: _Query_GroupAccountsByGroup_Handler, - }, - { - MethodName: "GroupAccountsByAdmin", - Handler: _Query_GroupAccountsByAdmin_Handler, - }, - { - MethodName: "Proposal", - Handler: _Query_Proposal_Handler, - }, - { - MethodName: "ProposalsByGroupAccount", - Handler: _Query_ProposalsByGroupAccount_Handler, - }, - { - MethodName: "VoteByProposalVoter", - Handler: _Query_VoteByProposalVoter_Handler, - }, - { - MethodName: "VotesByProposal", - Handler: _Query_VotesByProposal_Handler, - }, - { - MethodName: "VotesByVoter", - Handler: _Query_VotesByVoter_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "regen/group/v1alpha1/query.proto", +func (m *QueryVotesForPollByPollRequest) Reset() { *m = QueryVotesForPollByPollRequest{} } +func (m *QueryVotesForPollByPollRequest) String() string { return proto.CompactTextString(m) } +func (*QueryVotesForPollByPollRequest) ProtoMessage() {} +func (*QueryVotesForPollByPollRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{30} } - -func (m *QueryGroupInfoRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryVotesForPollByPollRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVotesForPollByPollRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVotesForPollByPollRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return dAtA[:n], nil } - -func (m *QueryGroupInfoRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QueryVotesForPollByPollRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVotesForPollByPollRequest.Merge(m, src) +} +func (m *QueryVotesForPollByPollRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryVotesForPollByPollRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVotesForPollByPollRequest.DiscardUnknown(m) } -func (m *QueryGroupInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.GroupId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.GroupId)) - i-- - dAtA[i] = 0x8 +var xxx_messageInfo_QueryVotesForPollByPollRequest proto.InternalMessageInfo + +func (m *QueryVotesForPollByPollRequest) GetPollId() uint64 { + if m != nil { + return m.PollId } - return len(dAtA) - i, nil + return 0 } -func (m *QueryGroupInfoResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryVotesForPollByPollRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination } - return dAtA[:n], nil + return nil } -func (m *QueryGroupInfoResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// QueryVotesForPollByPollResponse is the Query/VotePollsByPoll response type. +type QueryVotesForPollByPollResponse struct { + // votes are the list of votes for given poll_id. + Votes []*VotePoll `protobuf:"bytes,1,rep,name=votes,proto3" json:"votes,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryGroupInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Info != nil { - { - size, err := m.Info.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) +func (m *QueryVotesForPollByPollResponse) Reset() { *m = QueryVotesForPollByPollResponse{} } +func (m *QueryVotesForPollByPollResponse) String() string { return proto.CompactTextString(m) } +func (*QueryVotesForPollByPollResponse) ProtoMessage() {} +func (*QueryVotesForPollByPollResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{31} +} +func (m *QueryVotesForPollByPollResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVotesForPollByPollResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVotesForPollByPollResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } - i-- - dAtA[i] = 0xa + return b[:n], nil } - return len(dAtA) - i, nil } - -func (m *QueryGroupAccountInfoRequest) 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 *QueryVotesForPollByPollResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVotesForPollByPollResponse.Merge(m, src) } - -func (m *QueryGroupAccountInfoRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QueryVotesForPollByPollResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryVotesForPollByPollResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVotesForPollByPollResponse.DiscardUnknown(m) } -func (m *QueryGroupAccountInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0xa +var xxx_messageInfo_QueryVotesForPollByPollResponse proto.InternalMessageInfo + +func (m *QueryVotesForPollByPollResponse) GetVotes() []*VotePoll { + if m != nil { + return m.Votes } - return len(dAtA) - i, nil + return nil } -func (m *QueryGroupAccountInfoResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryVotesForPollByPollResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination } - return dAtA[:n], nil + return nil } -func (m *QueryGroupAccountInfoResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// QueryVotesForPollByVoterRequest is the Query/VotePollsByVoter request type. +type QueryVotesForPollByVoterRequest struct { + // voter is a poll voter account address. + Voter string `protobuf:"bytes,1,opt,name=voter,proto3" json:"voter,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryGroupAccountInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Info != nil { - { - size, err := m.Info.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) +func (m *QueryVotesForPollByVoterRequest) Reset() { *m = QueryVotesForPollByVoterRequest{} } +func (m *QueryVotesForPollByVoterRequest) String() string { return proto.CompactTextString(m) } +func (*QueryVotesForPollByVoterRequest) ProtoMessage() {} +func (*QueryVotesForPollByVoterRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{32} +} +func (m *QueryVotesForPollByVoterRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVotesForPollByVoterRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVotesForPollByVoterRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } - i-- - dAtA[i] = 0xa + return b[:n], nil } - return len(dAtA) - i, nil +} +func (m *QueryVotesForPollByVoterRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVotesForPollByVoterRequest.Merge(m, src) +} +func (m *QueryVotesForPollByVoterRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryVotesForPollByVoterRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVotesForPollByVoterRequest.DiscardUnknown(m) } -func (m *QueryGroupMembersRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +var xxx_messageInfo_QueryVotesForPollByVoterRequest proto.InternalMessageInfo + +func (m *QueryVotesForPollByVoterRequest) GetVoter() string { + if m != nil { + return m.Voter } - return dAtA[:n], nil + return "" } -func (m *QueryGroupMembersRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QueryVotesForPollByVoterRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil } -func (m *QueryGroupMembersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +// QueryVotesForPollByVoterResponse is the Query/VotePollsByVoter response type. +type QueryVotesForPollByVoterResponse struct { + // votes are the list of votes for poll by given voter. + Votes []*VotePoll `protobuf:"bytes,1,rep,name=votes,proto3" json:"votes,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryVotesForPollByVoterResponse) Reset() { *m = QueryVotesForPollByVoterResponse{} } +func (m *QueryVotesForPollByVoterResponse) String() string { return proto.CompactTextString(m) } +func (*QueryVotesForPollByVoterResponse) ProtoMessage() {} +func (*QueryVotesForPollByVoterResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2523b81f3b315123, []int{33} +} +func (m *QueryVotesForPollByVoterResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVotesForPollByVoterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVotesForPollByVoterResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - if m.GroupId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.GroupId)) - i-- - dAtA[i] = 0x8 +} +func (m *QueryVotesForPollByVoterResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVotesForPollByVoterResponse.Merge(m, src) +} +func (m *QueryVotesForPollByVoterResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryVotesForPollByVoterResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVotesForPollByVoterResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryVotesForPollByVoterResponse proto.InternalMessageInfo + +func (m *QueryVotesForPollByVoterResponse) GetVotes() []*VotePoll { + if m != nil { + return m.Votes } - return len(dAtA) - i, nil + return nil } -func (m *QueryGroupMembersResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryVotesForPollByVoterResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination } - return dAtA[:n], nil + return nil } -func (m *QueryGroupMembersResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func init() { + proto.RegisterType((*QueryGroupInfoRequest)(nil), "regen.group.v1alpha1.QueryGroupInfoRequest") + proto.RegisterType((*QueryGroupInfoResponse)(nil), "regen.group.v1alpha1.QueryGroupInfoResponse") + proto.RegisterType((*QueryGroupAccountInfoRequest)(nil), "regen.group.v1alpha1.QueryGroupAccountInfoRequest") + proto.RegisterType((*QueryGroupAccountInfoResponse)(nil), "regen.group.v1alpha1.QueryGroupAccountInfoResponse") + proto.RegisterType((*QueryGroupMembersRequest)(nil), "regen.group.v1alpha1.QueryGroupMembersRequest") + proto.RegisterType((*QueryGroupMembersResponse)(nil), "regen.group.v1alpha1.QueryGroupMembersResponse") + proto.RegisterType((*QueryGroupsByAdminRequest)(nil), "regen.group.v1alpha1.QueryGroupsByAdminRequest") + proto.RegisterType((*QueryGroupsByAdminResponse)(nil), "regen.group.v1alpha1.QueryGroupsByAdminResponse") + proto.RegisterType((*QueryGroupAccountsByGroupRequest)(nil), "regen.group.v1alpha1.QueryGroupAccountsByGroupRequest") + proto.RegisterType((*QueryGroupAccountsByGroupResponse)(nil), "regen.group.v1alpha1.QueryGroupAccountsByGroupResponse") + proto.RegisterType((*QueryGroupAccountsByAdminRequest)(nil), "regen.group.v1alpha1.QueryGroupAccountsByAdminRequest") + proto.RegisterType((*QueryGroupAccountsByAdminResponse)(nil), "regen.group.v1alpha1.QueryGroupAccountsByAdminResponse") + proto.RegisterType((*QueryProposalRequest)(nil), "regen.group.v1alpha1.QueryProposalRequest") + proto.RegisterType((*QueryProposalResponse)(nil), "regen.group.v1alpha1.QueryProposalResponse") + proto.RegisterType((*QueryProposalsByGroupAccountRequest)(nil), "regen.group.v1alpha1.QueryProposalsByGroupAccountRequest") + proto.RegisterType((*QueryProposalsByGroupAccountResponse)(nil), "regen.group.v1alpha1.QueryProposalsByGroupAccountResponse") + proto.RegisterType((*QueryVoteByProposalVoterRequest)(nil), "regen.group.v1alpha1.QueryVoteByProposalVoterRequest") + proto.RegisterType((*QueryVoteByProposalVoterResponse)(nil), "regen.group.v1alpha1.QueryVoteByProposalVoterResponse") + proto.RegisterType((*QueryVotesByProposalRequest)(nil), "regen.group.v1alpha1.QueryVotesByProposalRequest") + proto.RegisterType((*QueryVotesByProposalResponse)(nil), "regen.group.v1alpha1.QueryVotesByProposalResponse") + proto.RegisterType((*QueryVotesByVoterRequest)(nil), "regen.group.v1alpha1.QueryVotesByVoterRequest") + proto.RegisterType((*QueryVotesByVoterResponse)(nil), "regen.group.v1alpha1.QueryVotesByVoterResponse") + proto.RegisterType((*QueryPollRequest)(nil), "regen.group.v1alpha1.QueryPollRequest") + proto.RegisterType((*QueryPollResponse)(nil), "regen.group.v1alpha1.QueryPollResponse") + proto.RegisterType((*QueryPollsByGroupRequest)(nil), "regen.group.v1alpha1.QueryPollsByGroupRequest") + proto.RegisterType((*QueryPollsByGroupResponse)(nil), "regen.group.v1alpha1.QueryPollsByGroupResponse") + proto.RegisterType((*QueryPollsByCreatorRequest)(nil), "regen.group.v1alpha1.QueryPollsByCreatorRequest") + proto.RegisterType((*QueryPollsByCreatorResponse)(nil), "regen.group.v1alpha1.QueryPollsByCreatorResponse") + proto.RegisterType((*QueryVoteForPollByPollVoterRequest)(nil), "regen.group.v1alpha1.QueryVoteForPollByPollVoterRequest") + proto.RegisterType((*QueryVoteForPollByPollVoterResponse)(nil), "regen.group.v1alpha1.QueryVoteForPollByPollVoterResponse") + proto.RegisterType((*QueryVotesForPollByPollRequest)(nil), "regen.group.v1alpha1.QueryVotesForPollByPollRequest") + proto.RegisterType((*QueryVotesForPollByPollResponse)(nil), "regen.group.v1alpha1.QueryVotesForPollByPollResponse") + proto.RegisterType((*QueryVotesForPollByVoterRequest)(nil), "regen.group.v1alpha1.QueryVotesForPollByVoterRequest") + proto.RegisterType((*QueryVotesForPollByVoterResponse)(nil), "regen.group.v1alpha1.QueryVotesForPollByVoterResponse") } -func (m *QueryGroupMembersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Members) > 0 { - for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Members[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 init() { proto.RegisterFile("regen/group/v1alpha1/query.proto", fileDescriptor_2523b81f3b315123) } + +var fileDescriptor_2523b81f3b315123 = []byte{ + // 1431 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x59, 0xcb, 0x6f, 0x1b, 0xd5, + 0x17, 0xce, 0xed, 0x2f, 0xcd, 0xe3, 0x24, 0xed, 0xaf, 0x5c, 0x42, 0x93, 0x0e, 0xc5, 0x49, 0xa6, + 0x21, 0x29, 0x4d, 0x32, 0x13, 0x3b, 0xcf, 0x26, 0x80, 0xa8, 0x23, 0xb5, 0xca, 0x22, 0x52, 0x71, + 0x25, 0xc4, 0x63, 0x81, 0x26, 0xf1, 0xd4, 0xb5, 0x88, 0x3d, 0xae, 0xc7, 0x89, 0x1a, 0x59, 0xe6, + 0x25, 0x51, 0xb6, 0x48, 0x48, 0x08, 0x10, 0x20, 0xba, 0x82, 0x4d, 0x37, 0x08, 0xd8, 0x20, 0x21, + 0xb1, 0x03, 0x56, 0x15, 0x6c, 0x58, 0x21, 0x94, 0xf0, 0x87, 0xa0, 0xb9, 0xf7, 0xcc, 0xcb, 0xbe, + 0xf3, 0x8a, 0x46, 0x49, 0x57, 0xf5, 0x9d, 0x9e, 0x73, 0xef, 0x77, 0xbe, 0x73, 0xee, 0x99, 0xf3, + 0x4d, 0x60, 0xac, 0xae, 0x97, 0xf4, 0xaa, 0x5a, 0xaa, 0x1b, 0xbb, 0x35, 0x75, 0x2f, 0xab, 0xed, + 0xd4, 0xee, 0x68, 0x59, 0xf5, 0xee, 0xae, 0x5e, 0xdf, 0x57, 0x6a, 0x75, 0xa3, 0x61, 0xd0, 0x21, + 0x66, 0xa1, 0x30, 0x0b, 0xc5, 0xb6, 0x90, 0xc4, 0x7e, 0x8d, 0xfd, 0x9a, 0x6e, 0x72, 0x3f, 0xe9, + 0x62, 0xc9, 0x30, 0x4a, 0x3b, 0xba, 0xaa, 0xd5, 0xca, 0xaa, 0x56, 0xad, 0x1a, 0x0d, 0xad, 0x51, + 0x36, 0xaa, 0xf6, 0xff, 0x0e, 0x95, 0x8c, 0x92, 0xc1, 0x7e, 0xaa, 0xd6, 0x2f, 0x7c, 0x7a, 0x65, + 0xdb, 0x30, 0x2b, 0x86, 0xa9, 0x6e, 0x69, 0xa6, 0xce, 0x41, 0xa8, 0x7b, 0xd9, 0x2d, 0xbd, 0xa1, + 0x65, 0xd5, 0x9a, 0x56, 0x2a, 0x57, 0xd9, 0x16, 0xdc, 0x56, 0xce, 0xc1, 0x53, 0x2f, 0x5b, 0x16, + 0x37, 0x2c, 0x08, 0x1b, 0xd5, 0xdb, 0x46, 0x41, 0xbf, 0xbb, 0xab, 0x9b, 0x0d, 0x7a, 0x01, 0xfa, + 0x18, 0xac, 0x37, 0xcb, 0xc5, 0x11, 0x32, 0x46, 0x2e, 0x77, 0x17, 0x7a, 0xd9, 0x7a, 0xa3, 0x28, + 0x6f, 0xc2, 0xf9, 0x76, 0x1f, 0xb3, 0x66, 0x54, 0x4d, 0x9d, 0xce, 0x43, 0x77, 0xb9, 0x7a, 0xdb, + 0x60, 0x0e, 0x03, 0xb9, 0x51, 0x45, 0x14, 0xb4, 0xe2, 0xba, 0x31, 0x63, 0x79, 0x05, 0x2e, 0xba, + 0xdb, 0x5d, 0xdb, 0xde, 0x36, 0x76, 0xab, 0x0d, 0x2f, 0x92, 0x11, 0xe8, 0xd5, 0x8a, 0xc5, 0xba, + 0x6e, 0x9a, 0x6c, 0xdf, 0xfe, 0x82, 0xbd, 0x94, 0xdf, 0x80, 0x67, 0x02, 0x3c, 0x11, 0xcf, 0xaa, + 0x0f, 0xcf, 0x64, 0x08, 0x1e, 0xaf, 0x37, 0x87, 0xd5, 0x82, 0x11, 0x77, 0xf3, 0x4d, 0xbd, 0xb2, + 0xa5, 0xd7, 0xcd, 0x68, 0x72, 0xe8, 0x75, 0x00, 0x97, 0xe4, 0x91, 0x53, 0x78, 0x30, 0xcf, 0x88, + 0x62, 0x65, 0x44, 0xe1, 0x65, 0x81, 0x19, 0x51, 0x6e, 0x6a, 0x25, 0x1d, 0xb7, 0x2d, 0x78, 0x3c, + 0xe5, 0x07, 0x04, 0x2e, 0x08, 0xce, 0xc7, 0xc0, 0xd6, 0xa0, 0xb7, 0xc2, 0x1f, 0x8d, 0x90, 0xb1, + 0xff, 0x5d, 0x1e, 0xc8, 0x8d, 0x87, 0xc4, 0xc6, 0x9d, 0x0b, 0xb6, 0x07, 0xbd, 0x21, 0x80, 0x38, + 0x15, 0x09, 0x91, 0x9f, 0xec, 0xc3, 0xb8, 0xef, 0x85, 0x68, 0xe6, 0xf7, 0xaf, 0x15, 0x2b, 0xe5, + 0xaa, 0xcd, 0xd1, 0x10, 0x9c, 0xd6, 0xac, 0x35, 0x26, 0x8d, 0x2f, 0x52, 0xa3, 0xe7, 0x2b, 0x02, + 0x92, 0xe8, 0x6c, 0xe4, 0x67, 0x19, 0x7a, 0x18, 0x13, 0x36, 0x3d, 0x91, 0xa5, 0x88, 0xe6, 0xe9, + 0x71, 0xf3, 0x01, 0x81, 0xb1, 0x8e, 0xe2, 0x34, 0xf3, 0x7c, 0x79, 0x8c, 0x75, 0xf4, 0x13, 0x81, + 0xf1, 0x10, 0x1c, 0xc8, 0xd7, 0x26, 0x9c, 0xe5, 0x40, 0x34, 0x34, 0x40, 0xde, 0xe2, 0x5e, 0x99, + 0x33, 0x25, 0xef, 0xee, 0xe9, 0xb1, 0xf8, 0x6e, 0x00, 0x8b, 0xc7, 0x58, 0x69, 0x41, 0x04, 0xfa, + 0x0b, 0xee, 0x71, 0x25, 0x70, 0x19, 0x86, 0x18, 0xf8, 0x9b, 0x75, 0xa3, 0x66, 0x98, 0xda, 0x8e, + 0xcd, 0xd9, 0x28, 0x0c, 0xd4, 0xf0, 0x91, 0x5b, 0x7c, 0x60, 0x3f, 0xda, 0x28, 0xca, 0xb7, 0xf0, + 0xc5, 0xe0, 0x3a, 0x3a, 0x3d, 0xb5, 0xcf, 0x36, 0xc3, 0xbe, 0x9a, 0x11, 0xc7, 0xe8, 0x78, 0x3a, + 0xf6, 0xf2, 0x87, 0x04, 0x2e, 0xf9, 0x76, 0xb5, 0x0b, 0x11, 0x03, 0x8f, 0x6c, 0xf9, 0xa9, 0x65, + 0xf5, 0x21, 0x81, 0x89, 0x70, 0x24, 0x18, 0xee, 0xf3, 0xd0, 0x6f, 0xc3, 0xb7, 0x73, 0x1a, 0x15, + 0xaf, 0xeb, 0x90, 0x5e, 0x1e, 0x5f, 0x85, 0x51, 0x06, 0xf7, 0x15, 0xa3, 0xa1, 0xe7, 0x1d, 0xd0, + 0xd6, 0xaa, 0x1e, 0x37, 0xa5, 0xd6, 0x3d, 0xd9, 0xb3, 0x1c, 0x18, 0x8e, 0xfe, 0x02, 0x5f, 0xc8, + 0x05, 0xbc, 0x61, 0xc2, 0x9d, 0x91, 0x04, 0x05, 0xba, 0x2d, 0x63, 0xcc, 0xb7, 0x24, 0x8e, 0xdf, + 0x72, 0x29, 0x30, 0x3b, 0xf9, 0x3e, 0x81, 0xa7, 0x9d, 0x4d, 0xcd, 0x7c, 0xe2, 0xea, 0x4b, 0x2d, + 0xcd, 0x9f, 0x11, 0x1c, 0x2e, 0x3a, 0x80, 0x60, 0x64, 0x73, 0x9c, 0x13, 0x3b, 0xb5, 0x61, 0xa1, + 0x71, 0xc3, 0xf4, 0x52, 0x7a, 0x0f, 0x07, 0x0c, 0x84, 0xe6, 0xcb, 0xa5, 0x93, 0x2a, 0xe2, 0x49, + 0x55, 0x6a, 0xac, 0x7c, 0x62, 0xcf, 0x16, 0xfe, 0xa3, 0x4f, 0x9e, 0x92, 0x69, 0x38, 0xc7, 0x2f, + 0xa5, 0xb1, 0xe3, 0xd4, 0xca, 0x30, 0xf4, 0xd6, 0x8c, 0x1d, 0x4f, 0x9d, 0xf4, 0x58, 0xcb, 0x8d, + 0xa2, 0xbc, 0x0e, 0x4f, 0x78, 0x8c, 0xdd, 0x4a, 0xb5, 0xfe, 0x3b, 0xbc, 0x52, 0x99, 0x07, 0xb3, + 0x73, 0xa6, 0x3c, 0xeb, 0xd1, 0x09, 0xbc, 0x9d, 0x9d, 0x4c, 0xf8, 0xcf, 0x77, 0x33, 0x61, 0x81, + 0x8c, 0xc8, 0x04, 0x8b, 0x86, 0x1b, 0xa6, 0x97, 0x89, 0xb7, 0x71, 0xbc, 0x42, 0x5c, 0xeb, 0x75, + 0x5d, 0x6b, 0x18, 0x75, 0x4f, 0x7f, 0xde, 0xe6, 0x4f, 0xec, 0xfe, 0x8c, 0xcb, 0xd4, 0x88, 0xf9, + 0xd4, 0xee, 0x20, 0xed, 0x00, 0x4e, 0x9e, 0x9a, 0x5b, 0x20, 0x3b, 0x97, 0xe7, 0xba, 0x51, 0xb7, + 0xce, 0xc8, 0x33, 0x98, 0xbe, 0x1b, 0x1c, 0x54, 0xb6, 0x01, 0x5d, 0xf8, 0x35, 0x7c, 0x31, 0x06, + 0x6d, 0x8a, 0x61, 0xe7, 0x7c, 0x8d, 0x38, 0x13, 0x7c, 0x35, 0x79, 0x89, 0xb3, 0x66, 0xfc, 0x1e, + 0x81, 0x8c, 0x7b, 0xdb, 0x7d, 0x9b, 0x47, 0x82, 0x4d, 0x2b, 0x9d, 0x5f, 0x13, 0xcf, 0xfb, 0xab, + 0x1d, 0x03, 0xc6, 0xb6, 0xe0, 0xef, 0x3b, 0x51, 0xc1, 0xa5, 0xdd, 0x7b, 0xde, 0x11, 0x22, 0x3c, + 0xc6, 0xae, 0xfc, 0x80, 0x78, 0xde, 0xc4, 0x1d, 0x08, 0x1e, 0x0b, 0x92, 0x72, 0x7f, 0x0f, 0xc3, + 0x69, 0x86, 0x91, 0x7e, 0x41, 0xa0, 0xdf, 0x91, 0x4f, 0x74, 0x5a, 0x8c, 0x43, 0xf8, 0x69, 0x41, + 0x9a, 0x89, 0x67, 0xcc, 0x8f, 0x97, 0x17, 0xde, 0xff, 0xf3, 0xdf, 0x8f, 0x4f, 0x29, 0x74, 0x46, + 0x15, 0x7e, 0x2c, 0xe1, 0xba, 0x4d, 0x6d, 0xda, 0x9d, 0xba, 0xa5, 0x5a, 0xea, 0x9d, 0x7e, 0x4f, + 0xe0, 0x5c, 0xfb, 0x90, 0x4d, 0x73, 0x51, 0x07, 0x77, 0x7e, 0x7d, 0x90, 0xe6, 0x13, 0xf9, 0x20, + 0xe6, 0x65, 0x86, 0x39, 0x4b, 0xd5, 0x50, 0xcc, 0xb6, 0x54, 0x50, 0x9b, 0x38, 0xdd, 0xb6, 0xe8, + 0xb7, 0x04, 0x06, 0xbd, 0x82, 0x9f, 0x2a, 0x51, 0xc7, 0xfb, 0xbf, 0x4c, 0x48, 0x6a, 0x6c, 0xfb, + 0x44, 0x50, 0x3d, 0xf4, 0xda, 0x5f, 0x11, 0xbe, 0x21, 0x70, 0xc6, 0x27, 0xbe, 0x69, 0xe4, 0xd9, + 0x6d, 0xc2, 0x4d, 0x9a, 0x8b, 0xef, 0x80, 0x68, 0xe7, 0x19, 0xda, 0x59, 0x3a, 0x1d, 0x4e, 0xac, + 0xe5, 0xc3, 0x68, 0xad, 0x94, 0xab, 0x2d, 0xfa, 0x0b, 0x81, 0x21, 0x91, 0xfa, 0xa5, 0x4b, 0x31, + 0x73, 0xdb, 0x36, 0x18, 0x48, 0xcb, 0x89, 0xfd, 0x10, 0xfe, 0x0a, 0x83, 0x9f, 0xa3, 0x73, 0x71, + 0xc9, 0xb6, 0x4b, 0x84, 0xfe, 0xdc, 0x19, 0x03, 0x27, 0x3d, 0x41, 0x0c, 0x3e, 0xee, 0x97, 0x13, + 0xfb, 0x61, 0x0c, 0x8b, 0x2c, 0x06, 0x95, 0xce, 0x8a, 0x63, 0xf0, 0x73, 0xef, 0x06, 0xf0, 0x39, + 0x81, 0x3e, 0x7b, 0xfa, 0xa6, 0x57, 0x42, 0x0e, 0x6f, 0xd3, 0x0a, 0xd2, 0x74, 0x2c, 0xdb, 0x78, + 0xe0, 0x1c, 0x61, 0xa6, 0x36, 0x3d, 0xfa, 0xa3, 0x45, 0xff, 0x20, 0x30, 0x1c, 0x20, 0x04, 0xe9, + 0xd5, 0x18, 0xe7, 0x8b, 0x65, 0xac, 0xb4, 0x7a, 0x14, 0x57, 0x8c, 0xe4, 0x25, 0x16, 0xc9, 0x2a, + 0x5d, 0x09, 0x29, 0x95, 0xd9, 0xce, 0x0e, 0xe2, 0x86, 0x48, 0x7f, 0x23, 0xf0, 0xa4, 0x40, 0xd4, + 0xd1, 0xc5, 0x10, 0x54, 0xc1, 0xf2, 0x52, 0x5a, 0x4a, 0xea, 0x86, 0x81, 0xac, 0xb3, 0x40, 0x5e, + 0xa0, 0x6b, 0x89, 0x52, 0xa2, 0xb2, 0x17, 0x97, 0xda, 0x64, 0xaf, 0xd8, 0x16, 0xfd, 0x81, 0xc0, + 0xff, 0xdb, 0x24, 0x1c, 0xcd, 0x46, 0x00, 0xea, 0xd4, 0x9d, 0x52, 0x2e, 0x89, 0x0b, 0xe2, 0x5f, + 0x63, 0xf8, 0x17, 0xe9, 0xfc, 0x11, 0xf0, 0xd3, 0x2f, 0x09, 0x0c, 0x7a, 0x45, 0x56, 0x68, 0x3f, + 0x17, 0x08, 0xc1, 0xd0, 0x7e, 0x2e, 0x52, 0x6f, 0xf2, 0x0c, 0x83, 0x3b, 0x49, 0x27, 0xc4, 0x70, + 0x19, 0x9f, 0x2e, 0xaf, 0xf7, 0x09, 0x74, 0x5b, 0x83, 0x02, 0x9d, 0x0c, 0x2b, 0x55, 0x77, 0x52, + 0x94, 0xa6, 0x22, 0xed, 0x10, 0xc7, 0x2c, 0xc3, 0x31, 0x45, 0x9f, 0x0d, 0xa0, 0xcd, 0x9a, 0xc9, + 0xd5, 0x26, 0x4e, 0x9d, 0x2d, 0xab, 0x3d, 0x0c, 0x7a, 0x35, 0x50, 0x28, 0x51, 0x02, 0xb1, 0x16, + 0x4a, 0x94, 0x48, 0x5c, 0xc9, 0xcf, 0x31, 0x80, 0x97, 0xe8, 0x78, 0xc8, 0x05, 0xe3, 0x30, 0xe9, + 0x43, 0x02, 0x67, 0xfd, 0x3a, 0x84, 0xce, 0x45, 0x1f, 0xe7, 0xd7, 0x4c, 0x52, 0x36, 0x81, 0x07, + 0x42, 0x5c, 0x62, 0x10, 0xe7, 0xa8, 0x22, 0x86, 0x88, 0x9a, 0xcb, 0x54, 0x9b, 0xf8, 0xab, 0x85, + 0x78, 0x7f, 0x27, 0x70, 0x5e, 0x2c, 0x24, 0xe8, 0x4a, 0x44, 0x3d, 0x05, 0x0a, 0x1a, 0xe9, 0xea, + 0x11, 0x3c, 0x63, 0x5e, 0x21, 0x7f, 0x2d, 0xb4, 0x5d, 0xfd, 0x1f, 0x09, 0xd0, 0x4e, 0xd5, 0x40, + 0x17, 0xa2, 0x2e, 0x86, 0x48, 0xe8, 0x48, 0x8b, 0x09, 0xbd, 0xe2, 0x8d, 0x1d, 0xc2, 0x00, 0xe8, + 0x77, 0xd8, 0x7f, 0xdb, 0x46, 0x79, 0x1a, 0x1f, 0x43, 0xa2, 0xfe, 0x1b, 0xa0, 0x18, 0x92, 0x35, + 0x84, 0xfc, 0x8b, 0xbf, 0x1e, 0x64, 0xc8, 0xa3, 0x83, 0x0c, 0xf9, 0xe7, 0x20, 0x43, 0x3e, 0x3a, + 0xcc, 0x74, 0x3d, 0x3a, 0xcc, 0x74, 0xfd, 0x75, 0x98, 0xe9, 0x7a, 0x7d, 0xa2, 0x54, 0x6e, 0xdc, + 0xd9, 0xdd, 0x52, 0xb6, 0x8d, 0x8a, 0x8a, 0x7f, 0x60, 0xe4, 0xff, 0xcc, 0x9a, 0xc5, 0xb7, 0xd4, + 0x7b, 0x7c, 0xdf, 0xad, 0x1e, 0xf6, 0x67, 0xc5, 0xf9, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc4, + 0xd7, 0x49, 0x00, 0x12, 0x1d, 0x00, 0x00, } -func (m *QueryGroupsByAdminRequest) 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 +// 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 { + // GroupInfo queries group info based on group id. + GroupInfo(ctx context.Context, in *QueryGroupInfoRequest, opts ...grpc.CallOption) (*QueryGroupInfoResponse, error) + // GroupAccountInfo queries group account info based on group account address. + GroupAccountInfo(ctx context.Context, in *QueryGroupAccountInfoRequest, opts ...grpc.CallOption) (*QueryGroupAccountInfoResponse, error) + // GroupMembers queries members of a group + GroupMembers(ctx context.Context, in *QueryGroupMembersRequest, opts ...grpc.CallOption) (*QueryGroupMembersResponse, error) + // GroupsByAdmin queries groups by admin address. + GroupsByAdmin(ctx context.Context, in *QueryGroupsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupsByAdminResponse, error) + // GroupAccountsByGroup queries group accounts by group id. + GroupAccountsByGroup(ctx context.Context, in *QueryGroupAccountsByGroupRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByGroupResponse, error) + // GroupsByAdmin queries group accounts by admin address. + GroupAccountsByAdmin(ctx context.Context, in *QueryGroupAccountsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByAdminResponse, error) + // Proposal queries a proposal based on proposal id. + Proposal(ctx context.Context, in *QueryProposalRequest, opts ...grpc.CallOption) (*QueryProposalResponse, error) + // ProposalsByGroupAccount queries proposals based on group account address. + ProposalsByGroupAccount(ctx context.Context, in *QueryProposalsByGroupAccountRequest, opts ...grpc.CallOption) (*QueryProposalsByGroupAccountResponse, error) + // VoteByProposalVoter queries a vote by proposal id and voter. + VoteByProposalVoter(ctx context.Context, in *QueryVoteByProposalVoterRequest, opts ...grpc.CallOption) (*QueryVoteByProposalVoterResponse, error) + // VotesByProposal queries a vote by proposal. + VotesByProposal(ctx context.Context, in *QueryVotesByProposalRequest, opts ...grpc.CallOption) (*QueryVotesByProposalResponse, error) + // VotesByVoter queries a vote by voter. + VotesByVoter(ctx context.Context, in *QueryVotesByVoterRequest, opts ...grpc.CallOption) (*QueryVotesByVoterResponse, error) + // Poll queries a poll based on poll id. + Poll(ctx context.Context, in *QueryPollRequest, opts ...grpc.CallOption) (*QueryPollResponse, error) + // PollsByGroup queries polls based on group id. + PollsByGroup(ctx context.Context, in *QueryPollsByGroupRequest, opts ...grpc.CallOption) (*QueryPollsByGroupResponse, error) + // PollsByCreator queries polls by creator address. + PollsByCreator(ctx context.Context, in *QueryPollsByCreatorRequest, opts ...grpc.CallOption) (*QueryPollsByCreatorResponse, error) + // VoteForPollByPollVoter queries a vote by poll id and voter. + VoteForPollByPollVoter(ctx context.Context, in *QueryVoteForPollByPollVoterRequest, opts ...grpc.CallOption) (*QueryVoteForPollByPollVoterResponse, error) + // VotesForPollByPoll queries votes by poll. + VotesForPollByPoll(ctx context.Context, in *QueryVotesForPollByPollRequest, opts ...grpc.CallOption) (*QueryVotesForPollByPollResponse, error) + // VotesForPollByVoter queries votes for poll by voter. + VotesForPollByVoter(ctx context.Context, in *QueryVotesForPollByVoterRequest, opts ...grpc.CallOption) (*QueryVotesForPollByVoterResponse, error) } -func (m *QueryGroupsByAdminRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +type queryClient struct { + cc grpc1.ClientConn } -func (m *QueryGroupsByAdminRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Admin) > 0 { - i -= len(m.Admin) - copy(dAtA[i:], m.Admin) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Admin))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} } -func (m *QueryGroupsByAdminResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) GroupInfo(ctx context.Context, in *QueryGroupInfoRequest, opts ...grpc.CallOption) (*QueryGroupInfoResponse, error) { + out := new(QueryGroupInfoResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupInfo", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *QueryGroupsByAdminResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) GroupAccountInfo(ctx context.Context, in *QueryGroupAccountInfoRequest, opts ...grpc.CallOption) (*QueryGroupAccountInfoResponse, error) { + out := new(QueryGroupAccountInfoResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupAccountInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *QueryGroupsByAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Groups) > 0 { - for iNdEx := len(m.Groups) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Groups[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } +func (c *queryClient) GroupMembers(ctx context.Context, in *QueryGroupMembersRequest, opts ...grpc.CallOption) (*QueryGroupMembersResponse, error) { + out := new(QueryGroupMembersResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupMembers", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryGroupAccountsByGroupRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) GroupsByAdmin(ctx context.Context, in *QueryGroupsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupsByAdminResponse, error) { + out := new(QueryGroupsByAdminResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupsByAdmin", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *QueryGroupAccountsByGroupRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) GroupAccountsByGroup(ctx context.Context, in *QueryGroupAccountsByGroupRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByGroupResponse, error) { + out := new(QueryGroupAccountsByGroupResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupAccountsByGroup", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *QueryGroupAccountsByGroupRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.GroupId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.GroupId)) - i-- - dAtA[i] = 0x8 +func (c *queryClient) GroupAccountsByAdmin(ctx context.Context, in *QueryGroupAccountsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupAccountsByAdminResponse, error) { + out := new(QueryGroupAccountsByAdminResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/GroupAccountsByAdmin", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryGroupAccountsByGroupResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) Proposal(ctx context.Context, in *QueryProposalRequest, opts ...grpc.CallOption) (*QueryProposalResponse, error) { + out := new(QueryProposalResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/Proposal", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *QueryGroupAccountsByGroupResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + return out, nil } -func (m *QueryGroupAccountsByGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.GroupAccounts) > 0 { - for iNdEx := len(m.GroupAccounts) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.GroupAccounts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } +func (c *queryClient) ProposalsByGroupAccount(ctx context.Context, in *QueryProposalsByGroupAccountRequest, opts ...grpc.CallOption) (*QueryProposalsByGroupAccountResponse, error) { + out := new(QueryProposalsByGroupAccountResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/ProposalsByGroupAccount", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryGroupAccountsByAdminRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) VoteByProposalVoter(ctx context.Context, in *QueryVoteByProposalVoterRequest, opts ...grpc.CallOption) (*QueryVoteByProposalVoterResponse, error) { + out := new(QueryVoteByProposalVoterResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VoteByProposalVoter", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *QueryGroupAccountsByAdminRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + return out, nil } -func (m *QueryGroupAccountsByAdminRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Admin) > 0 { - i -= len(m.Admin) - copy(dAtA[i:], m.Admin) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Admin))) - i-- - dAtA[i] = 0xa +func (c *queryClient) VotesByProposal(ctx context.Context, in *QueryVotesByProposalRequest, opts ...grpc.CallOption) (*QueryVotesByProposalResponse, error) { + out := new(QueryVotesByProposalResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VotesByProposal", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryGroupAccountsByAdminResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) VotesByVoter(ctx context.Context, in *QueryVotesByVoterRequest, opts ...grpc.CallOption) (*QueryVotesByVoterResponse, error) { + out := new(QueryVotesByVoterResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VotesByVoter", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *QueryGroupAccountsByAdminResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + return out, nil } -func (m *QueryGroupAccountsByAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.GroupAccounts) > 0 { - for iNdEx := len(m.GroupAccounts) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.GroupAccounts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } +func (c *queryClient) Poll(ctx context.Context, in *QueryPollRequest, opts ...grpc.CallOption) (*QueryPollResponse, error) { + out := new(QueryPollResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/Poll", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryProposalRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) PollsByGroup(ctx context.Context, in *QueryPollsByGroupRequest, opts ...grpc.CallOption) (*QueryPollsByGroupResponse, error) { + out := new(QueryPollsByGroupResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/PollsByGroup", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *QueryProposalRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + return out, nil } -func (m *QueryProposalRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ProposalId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProposalId)) - i-- - dAtA[i] = 0x8 +func (c *queryClient) PollsByCreator(ctx context.Context, in *QueryPollsByCreatorRequest, opts ...grpc.CallOption) (*QueryPollsByCreatorResponse, error) { + out := new(QueryPollsByCreatorResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/PollsByCreator", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryProposalResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) VoteForPollByPollVoter(ctx context.Context, in *QueryVoteForPollByPollVoterRequest, opts ...grpc.CallOption) (*QueryVoteForPollByPollVoterResponse, error) { + out := new(QueryVoteForPollByPollVoterResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VoteForPollByPollVoter", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *QueryProposalResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + return out, nil } -func (m *QueryProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Proposal != nil { - { - size, err := m.Proposal.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa +func (c *queryClient) VotesForPollByPoll(ctx context.Context, in *QueryVotesForPollByPollRequest, opts ...grpc.CallOption) (*QueryVotesForPollByPollResponse, error) { + out := new(QueryVotesForPollByPollResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VotesForPollByPoll", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryProposalsByGroupAccountRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) VotesForPollByVoter(ctx context.Context, in *QueryVotesForPollByVoterRequest, opts ...grpc.CallOption) (*QueryVotesForPollByVoterResponse, error) { + out := new(QueryVotesForPollByVoterResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Query/VotesForPollByVoter", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *QueryProposalsByGroupAccountRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// QueryServer is the server API for Query service. +type QueryServer interface { + // GroupInfo queries group info based on group id. + GroupInfo(context.Context, *QueryGroupInfoRequest) (*QueryGroupInfoResponse, error) + // GroupAccountInfo queries group account info based on group account address. + GroupAccountInfo(context.Context, *QueryGroupAccountInfoRequest) (*QueryGroupAccountInfoResponse, error) + // GroupMembers queries members of a group + GroupMembers(context.Context, *QueryGroupMembersRequest) (*QueryGroupMembersResponse, error) + // GroupsByAdmin queries groups by admin address. + GroupsByAdmin(context.Context, *QueryGroupsByAdminRequest) (*QueryGroupsByAdminResponse, error) + // GroupAccountsByGroup queries group accounts by group id. + GroupAccountsByGroup(context.Context, *QueryGroupAccountsByGroupRequest) (*QueryGroupAccountsByGroupResponse, error) + // GroupsByAdmin queries group accounts by admin address. + GroupAccountsByAdmin(context.Context, *QueryGroupAccountsByAdminRequest) (*QueryGroupAccountsByAdminResponse, error) + // Proposal queries a proposal based on proposal id. + Proposal(context.Context, *QueryProposalRequest) (*QueryProposalResponse, error) + // ProposalsByGroupAccount queries proposals based on group account address. + ProposalsByGroupAccount(context.Context, *QueryProposalsByGroupAccountRequest) (*QueryProposalsByGroupAccountResponse, error) + // VoteByProposalVoter queries a vote by proposal id and voter. + VoteByProposalVoter(context.Context, *QueryVoteByProposalVoterRequest) (*QueryVoteByProposalVoterResponse, error) + // VotesByProposal queries a vote by proposal. + VotesByProposal(context.Context, *QueryVotesByProposalRequest) (*QueryVotesByProposalResponse, error) + // VotesByVoter queries a vote by voter. + VotesByVoter(context.Context, *QueryVotesByVoterRequest) (*QueryVotesByVoterResponse, error) + // Poll queries a poll based on poll id. + Poll(context.Context, *QueryPollRequest) (*QueryPollResponse, error) + // PollsByGroup queries polls based on group id. + PollsByGroup(context.Context, *QueryPollsByGroupRequest) (*QueryPollsByGroupResponse, error) + // PollsByCreator queries polls by creator address. + PollsByCreator(context.Context, *QueryPollsByCreatorRequest) (*QueryPollsByCreatorResponse, error) + // VoteForPollByPollVoter queries a vote by poll id and voter. + VoteForPollByPollVoter(context.Context, *QueryVoteForPollByPollVoterRequest) (*QueryVoteForPollByPollVoterResponse, error) + // VotesForPollByPoll queries votes by poll. + VotesForPollByPoll(context.Context, *QueryVotesForPollByPollRequest) (*QueryVotesForPollByPollResponse, error) + // VotesForPollByVoter queries votes for poll by voter. + VotesForPollByVoter(context.Context, *QueryVotesForPollByVoterRequest) (*QueryVotesForPollByVoterResponse, error) } -func (m *QueryProposalsByGroupAccountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { } -func (m *QueryProposalsByGroupAccountResponse) 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 (*UnimplementedQueryServer) GroupInfo(ctx context.Context, req *QueryGroupInfoRequest) (*QueryGroupInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GroupInfo not implemented") +} +func (*UnimplementedQueryServer) GroupAccountInfo(ctx context.Context, req *QueryGroupAccountInfoRequest) (*QueryGroupAccountInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GroupAccountInfo not implemented") +} +func (*UnimplementedQueryServer) GroupMembers(ctx context.Context, req *QueryGroupMembersRequest) (*QueryGroupMembersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GroupMembers not implemented") +} +func (*UnimplementedQueryServer) GroupsByAdmin(ctx context.Context, req *QueryGroupsByAdminRequest) (*QueryGroupsByAdminResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GroupsByAdmin not implemented") +} +func (*UnimplementedQueryServer) GroupAccountsByGroup(ctx context.Context, req *QueryGroupAccountsByGroupRequest) (*QueryGroupAccountsByGroupResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GroupAccountsByGroup not implemented") +} +func (*UnimplementedQueryServer) GroupAccountsByAdmin(ctx context.Context, req *QueryGroupAccountsByAdminRequest) (*QueryGroupAccountsByAdminResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GroupAccountsByAdmin not implemented") +} +func (*UnimplementedQueryServer) Proposal(ctx context.Context, req *QueryProposalRequest) (*QueryProposalResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Proposal not implemented") +} +func (*UnimplementedQueryServer) ProposalsByGroupAccount(ctx context.Context, req *QueryProposalsByGroupAccountRequest) (*QueryProposalsByGroupAccountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ProposalsByGroupAccount not implemented") +} +func (*UnimplementedQueryServer) VoteByProposalVoter(ctx context.Context, req *QueryVoteByProposalVoterRequest) (*QueryVoteByProposalVoterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VoteByProposalVoter not implemented") +} +func (*UnimplementedQueryServer) VotesByProposal(ctx context.Context, req *QueryVotesByProposalRequest) (*QueryVotesByProposalResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VotesByProposal not implemented") +} +func (*UnimplementedQueryServer) VotesByVoter(ctx context.Context, req *QueryVotesByVoterRequest) (*QueryVotesByVoterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VotesByVoter not implemented") +} +func (*UnimplementedQueryServer) Poll(ctx context.Context, req *QueryPollRequest) (*QueryPollResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Poll not implemented") +} +func (*UnimplementedQueryServer) PollsByGroup(ctx context.Context, req *QueryPollsByGroupRequest) (*QueryPollsByGroupResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PollsByGroup not implemented") +} +func (*UnimplementedQueryServer) PollsByCreator(ctx context.Context, req *QueryPollsByCreatorRequest) (*QueryPollsByCreatorResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PollsByCreator not implemented") +} +func (*UnimplementedQueryServer) VoteForPollByPollVoter(ctx context.Context, req *QueryVoteForPollByPollVoterRequest) (*QueryVoteForPollByPollVoterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VoteForPollByPollVoter not implemented") +} +func (*UnimplementedQueryServer) VotesForPollByPoll(ctx context.Context, req *QueryVotesForPollByPollRequest) (*QueryVotesForPollByPollResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VotesForPollByPoll not implemented") +} +func (*UnimplementedQueryServer) VotesForPollByVoter(ctx context.Context, req *QueryVotesForPollByVoterRequest) (*QueryVotesForPollByVoterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VotesForPollByVoter not implemented") } -func (m *QueryProposalsByGroupAccountResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) } -func (m *QueryProposalsByGroupAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +func _Query_GroupInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupInfoRequest) + if err := dec(in); err != nil { + return nil, err } - if len(m.Proposals) > 0 { - for iNdEx := len(m.Proposals) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Proposals[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + if interceptor == nil { + return srv.(QueryServer).GroupInfo(ctx, in) } - return len(dAtA) - i, nil + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/GroupInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GroupInfo(ctx, req.(*QueryGroupInfoRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVoteByProposalVoterRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Query_GroupAccountInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupAccountInfoRequest) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *QueryVoteByProposalVoterRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryVoteByProposalVoterRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Voter) > 0 { - i -= len(m.Voter) - copy(dAtA[i:], m.Voter) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Voter))) - i-- - dAtA[i] = 0x12 + if interceptor == nil { + return srv.(QueryServer).GroupAccountInfo(ctx, in) } - if m.ProposalId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProposalId)) - i-- - dAtA[i] = 0x8 + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/GroupAccountInfo", } - return len(dAtA) - i, nil + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GroupAccountInfo(ctx, req.(*QueryGroupAccountInfoRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVoteByProposalVoterResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Query_GroupMembers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupMembersRequest) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(QueryServer).GroupMembers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/GroupMembers", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GroupMembers(ctx, req.(*QueryGroupMembersRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVoteByProposalVoterResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func _Query_GroupsByAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupsByAdminRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GroupsByAdmin(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/GroupsByAdmin", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GroupsByAdmin(ctx, req.(*QueryGroupsByAdminRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVoteByProposalVoterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Vote != nil { - { - size, err := m.Vote.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa +func _Query_GroupAccountsByGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupAccountsByGroupRequest) + if err := dec(in); err != nil { + return nil, err } - return len(dAtA) - i, nil + if interceptor == nil { + return srv.(QueryServer).GroupAccountsByGroup(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/GroupAccountsByGroup", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GroupAccountsByGroup(ctx, req.(*QueryGroupAccountsByGroupRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVotesByProposalRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Query_GroupAccountsByAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGroupAccountsByAdminRequest) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(QueryServer).GroupAccountsByAdmin(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/GroupAccountsByAdmin", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GroupAccountsByAdmin(ctx, req.(*QueryGroupAccountsByAdminRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVotesByProposalRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryVotesByProposalRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +func _Query_Proposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryProposalRequest) + if err := dec(in); err != nil { + return nil, err } - if m.ProposalId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProposalId)) - i-- - dAtA[i] = 0x8 + if interceptor == nil { + return srv.(QueryServer).Proposal(ctx, in) } - return len(dAtA) - i, nil + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/Proposal", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Proposal(ctx, req.(*QueryProposalRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVotesByProposalResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Query_ProposalsByGroupAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryProposalsByGroupAccountRequest) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(QueryServer).ProposalsByGroupAccount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/ProposalsByGroupAccount", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ProposalsByGroupAccount(ctx, req.(*QueryProposalsByGroupAccountRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVotesByProposalResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func _Query_VoteByProposalVoter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryVoteByProposalVoterRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).VoteByProposalVoter(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/VoteByProposalVoter", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).VoteByProposalVoter(ctx, req.(*QueryVoteByProposalVoterRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVotesByProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +func _Query_VotesByProposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryVotesByProposalRequest) + if err := dec(in); err != nil { + return nil, err } - if len(m.Votes) > 0 { - for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Votes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + if interceptor == nil { + return srv.(QueryServer).VotesByProposal(ctx, in) } - return len(dAtA) - i, nil + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/VotesByProposal", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).VotesByProposal(ctx, req.(*QueryVotesByProposalRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVotesByVoterRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Query_VotesByVoter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryVotesByVoterRequest) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(QueryServer).VotesByVoter(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/VotesByVoter", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).VotesByVoter(ctx, req.(*QueryVotesByVoterRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVotesByVoterRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func _Query_Poll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPollRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Poll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/Poll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Poll(ctx, req.(*QueryPollRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVotesByVoterRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +func _Query_PollsByGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPollsByGroupRequest) + if err := dec(in); err != nil { + return nil, err } - if len(m.Voter) > 0 { - i -= len(m.Voter) - copy(dAtA[i:], m.Voter) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Voter))) - i-- - dAtA[i] = 0xa + if interceptor == nil { + return srv.(QueryServer).PollsByGroup(ctx, in) } - return len(dAtA) - i, nil + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/PollsByGroup", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PollsByGroup(ctx, req.(*QueryPollsByGroupRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVotesByVoterResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Query_PollsByCreator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPollsByCreatorRequest) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(QueryServer).PollsByCreator(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/PollsByCreator", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PollsByCreator(ctx, req.(*QueryPollsByCreatorRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVotesByVoterResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func _Query_VoteForPollByPollVoter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryVoteForPollByPollVoterRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).VoteForPollByPollVoter(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/VoteForPollByPollVoter", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).VoteForPollByPollVoter(ctx, req.(*QueryVoteForPollByPollVoterRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryVotesByVoterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +func _Query_VotesForPollByPoll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryVotesForPollByPollRequest) + if err := dec(in); err != nil { + return nil, err } - if len(m.Votes) > 0 { - for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Votes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + if interceptor == nil { + return srv.(QueryServer).VotesForPollByPoll(ctx, in) } - return len(dAtA) - i, nil + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/VotesForPollByPoll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).VotesForPollByPoll(ctx, req.(*QueryVotesForPollByPollRequest)) + } + return interceptor(ctx, in, info, handler) } -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++ +func _Query_VotesForPollByVoter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryVotesForPollByVoterRequest) + if err := dec(in); err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base -} -func (m *QueryGroupInfoRequest) Size() (n int) { - if m == nil { - return 0 + if interceptor == nil { + return srv.(QueryServer).VotesForPollByVoter(ctx, in) } - var l int - _ = l - if m.GroupId != 0 { - n += 1 + sovQuery(uint64(m.GroupId)) + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Query/VotesForPollByVoter", } - return n + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).VotesForPollByVoter(ctx, req.(*QueryVotesForPollByVoterRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryGroupInfoResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Info != nil { - l = m.Info.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "regen.group.v1alpha1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GroupInfo", + Handler: _Query_GroupInfo_Handler, + }, + { + MethodName: "GroupAccountInfo", + Handler: _Query_GroupAccountInfo_Handler, + }, + { + MethodName: "GroupMembers", + Handler: _Query_GroupMembers_Handler, + }, + { + MethodName: "GroupsByAdmin", + Handler: _Query_GroupsByAdmin_Handler, + }, + { + MethodName: "GroupAccountsByGroup", + Handler: _Query_GroupAccountsByGroup_Handler, + }, + { + MethodName: "GroupAccountsByAdmin", + Handler: _Query_GroupAccountsByAdmin_Handler, + }, + { + MethodName: "Proposal", + Handler: _Query_Proposal_Handler, + }, + { + MethodName: "ProposalsByGroupAccount", + Handler: _Query_ProposalsByGroupAccount_Handler, + }, + { + MethodName: "VoteByProposalVoter", + Handler: _Query_VoteByProposalVoter_Handler, + }, + { + MethodName: "VotesByProposal", + Handler: _Query_VotesByProposal_Handler, + }, + { + MethodName: "VotesByVoter", + Handler: _Query_VotesByVoter_Handler, + }, + { + MethodName: "Poll", + Handler: _Query_Poll_Handler, + }, + { + MethodName: "PollsByGroup", + Handler: _Query_PollsByGroup_Handler, + }, + { + MethodName: "PollsByCreator", + Handler: _Query_PollsByCreator_Handler, + }, + { + MethodName: "VoteForPollByPollVoter", + Handler: _Query_VoteForPollByPollVoter_Handler, + }, + { + MethodName: "VotesForPollByPoll", + Handler: _Query_VotesForPollByPoll_Handler, + }, + { + MethodName: "VotesForPollByVoter", + Handler: _Query_VotesForPollByVoter_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "regen/group/v1alpha1/query.proto", } -func (m *QueryGroupAccountInfoRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) +func (m *QueryGroupInfoRequest) 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 n + return dAtA[:n], nil } -func (m *QueryGroupAccountInfoResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Info != nil { - l = m.Info.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n +func (m *QueryGroupInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryGroupMembersRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGroupInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l if m.GroupId != 0 { - n += 1 + sovQuery(uint64(m.GroupId)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + i = encodeVarintQuery(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *QueryGroupMembersResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Members) > 0 { - for _, e := range m.Members { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) +func (m *QueryGroupInfoResponse) 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 n + return dAtA[:n], nil } -func (m *QueryGroupsByAdminRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n +func (m *QueryGroupInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryGroupsByAdminResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGroupInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.Groups) > 0 { - for _, e := range m.Groups { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Info != nil { + { + size, err := m.Info.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n + return len(dAtA) - i, nil } -func (m *QueryGroupAccountsByGroupRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryGroupAccountInfoRequest) 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 *QueryGroupAccountInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupAccountInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.GroupId != 0 { - n += 1 + sovQuery(uint64(m.GroupId)) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + return len(dAtA) - i, nil +} + +func (m *QueryGroupAccountInfoResponse) 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 n + return dAtA[:n], nil } -func (m *QueryGroupAccountsByGroupResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGroupAccountInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupAccountInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.GroupAccounts) > 0 { - for _, e := range m.GroupAccounts { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Info != nil { + { + size, err := m.Info.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n + return len(dAtA) - i, nil } -func (m *QueryGroupAccountsByAdminRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) +func (m *QueryGroupMembersRequest) 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 n + return dAtA[:n], nil } -func (m *QueryGroupAccountsByAdminResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGroupMembersRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupMembersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.GroupAccounts) > 0 { - for _, e := range m.GroupAccounts { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.GroupId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *QueryProposalRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ProposalId != 0 { - n += 1 + sovQuery(uint64(m.ProposalId)) +func (m *QueryGroupMembersResponse) 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 n + return dAtA[:n], nil } -func (m *QueryProposalResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Proposal != nil { - l = m.Proposal.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n +func (m *QueryGroupMembersResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryProposalsByGroupAccountRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGroupMembersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - return n + if len(m.Members) > 0 { + for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Members[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 (m *QueryProposalsByGroupAccountResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryGroupsByAdminRequest) 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 *QueryGroupsByAdminRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupsByAdminRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.Proposals) > 0 { - for _, e := range m.Proposals { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *QueryVoteByProposalVoterRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ProposalId != 0 { - n += 1 + sovQuery(uint64(m.ProposalId)) - } - l = len(m.Voter) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) +func (m *QueryGroupsByAdminResponse) 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 n + return dAtA[:n], nil } -func (m *QueryVoteByProposalVoterResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Vote != nil { - l = m.Vote.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n +func (m *QueryGroupsByAdminResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryVotesByProposalRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGroupsByAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.ProposalId != 0 { - n += 1 + sovQuery(uint64(m.ProposalId)) - } if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryVotesByProposalResponse) Size() (n int) { - if m == nil { - return 0 - } + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Groups) > 0 { + for iNdEx := len(m.Groups) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Groups[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 (m *QueryGroupAccountsByGroupRequest) 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 *QueryGroupAccountsByGroupRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupAccountsByGroupRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.Votes) > 0 { - for _, e := range m.Votes { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 + } + if m.GroupId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryGroupAccountsByGroupResponse) 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 *QueryGroupAccountsByGroupResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupAccountsByGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - return n + if len(m.GroupAccounts) > 0 { + for iNdEx := len(m.GroupAccounts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.GroupAccounts[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 (m *QueryVotesByVoterRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryGroupAccountsByAdminRequest) 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 *QueryGroupAccountsByAdminRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupAccountsByAdminRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Voter) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGroupAccountsByAdminResponse) 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 *QueryGroupAccountsByAdminResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGroupAccountsByAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - return n + if len(m.GroupAccounts) > 0 { + for iNdEx := len(m.GroupAccounts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.GroupAccounts[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 (m *QueryVotesByVoterResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryProposalRequest) 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 *QueryProposalRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryProposalRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.Votes) > 0 { - for _, e := range m.Votes { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.ProposalId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryProposalResponse) 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 *QueryProposalResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Proposal != nil { + { + size, err := m.Proposal.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 *QueryProposalsByGroupAccountRequest) 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 *QueryProposalsByGroupAccountRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryProposalsByGroupAccountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryProposalsByGroupAccountResponse) 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 *QueryProposalsByGroupAccountResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryProposalsByGroupAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Proposals) > 0 { + for iNdEx := len(m.Proposals) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Proposals[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 (m *QueryVoteByProposalVoterRequest) 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 *QueryVoteByProposalVoterRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVoteByProposalVoterRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x12 + } + if m.ProposalId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryVoteByProposalVoterResponse) 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 *QueryVoteByProposalVoterResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVoteByProposalVoterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Vote != nil { + { + size, err := m.Vote.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 *QueryVotesByProposalRequest) 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 *QueryVotesByProposalRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesByProposalRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.ProposalId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryVotesByProposalResponse) 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 *QueryVotesByProposalResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesByProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Votes) > 0 { + for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Votes[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 (m *QueryVotesByVoterRequest) 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 *QueryVotesByVoterRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesByVoterRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryVotesByVoterResponse) 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 *QueryVotesByVoterResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesByVoterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Votes) > 0 { + for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Votes[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 (m *QueryPollRequest) 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 *QueryPollRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPollRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PollId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryPollResponse) 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 *QueryPollResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPollResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Poll != nil { + { + size, err := m.Poll.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 *QueryPollsByGroupRequest) 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 *QueryPollsByGroupRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPollsByGroupRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.GroupId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryPollsByGroupResponse) 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 *QueryPollsByGroupResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPollsByGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Polls) > 0 { + for iNdEx := len(m.Polls) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Polls[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 (m *QueryPollsByCreatorRequest) 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 *QueryPollsByCreatorRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPollsByCreatorRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryPollsByCreatorResponse) 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 *QueryPollsByCreatorResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPollsByCreatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Polls) > 0 { + for iNdEx := len(m.Polls) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Polls[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 (m *QueryVoteForPollByPollVoterRequest) 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 *QueryVoteForPollByPollVoterRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVoteForPollByPollVoterRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x12 + } + if m.PollId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryVoteForPollByPollVoterResponse) 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 *QueryVoteForPollByPollVoterResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVoteForPollByPollVoterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Vote != nil { + { + size, err := m.Vote.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 *QueryVotesForPollByPollRequest) 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 *QueryVotesForPollByPollRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesForPollByPollRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.PollId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryVotesForPollByPollResponse) 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 *QueryVotesForPollByPollResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesForPollByPollResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Votes) > 0 { + for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Votes[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 (m *QueryVotesForPollByVoterRequest) 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 *QueryVotesForPollByVoterRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesForPollByVoterRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryVotesForPollByVoterResponse) 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 *QueryVotesForPollByVoterResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesForPollByVoterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Votes) > 0 { + for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Votes[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 *QueryGroupInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovQuery(uint64(m.GroupId)) + } + return n +} + +func (m *QueryGroupInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Info != nil { + l = m.Info.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupAccountInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupAccountInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Info != nil { + l = m.Info.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupMembersRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovQuery(uint64(m.GroupId)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupMembersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Members) > 0 { + for _, e := range m.Members { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupsByAdminRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupsByAdminResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Groups) > 0 { + for _, e := range m.Groups { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupAccountsByGroupRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovQuery(uint64(m.GroupId)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupAccountsByGroupResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.GroupAccounts) > 0 { + for _, e := range m.GroupAccounts { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupAccountsByAdminRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGroupAccountsByAdminResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.GroupAccounts) > 0 { + for _, e := range m.GroupAccounts { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryProposalRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovQuery(uint64(m.ProposalId)) + } + return n +} + +func (m *QueryProposalResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Proposal != nil { + l = m.Proposal.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryProposalsByGroupAccountRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryProposalsByGroupAccountResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Proposals) > 0 { + for _, e := range m.Proposals { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVoteByProposalVoterRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovQuery(uint64(m.ProposalId)) + } + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVoteByProposalVoterResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Vote != nil { + l = m.Vote.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVotesByProposalRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovQuery(uint64(m.ProposalId)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVotesByProposalResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Votes) > 0 { + for _, e := range m.Votes { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVotesByVoterRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVotesByVoterResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Votes) > 0 { + for _, e := range m.Votes { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPollRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovQuery(uint64(m.PollId)) + } + return n +} + +func (m *QueryPollResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Poll != nil { + l = m.Poll.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPollsByGroupRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovQuery(uint64(m.GroupId)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPollsByGroupResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Polls) > 0 { + for _, e := range m.Polls { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPollsByCreatorRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPollsByCreatorResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Polls) > 0 { + for _, e := range m.Polls { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVoteForPollByPollVoterRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovQuery(uint64(m.PollId)) + } + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVoteForPollByPollVoterResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Vote != nil { + l = m.Vote.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVotesForPollByPollRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovQuery(uint64(m.PollId)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVotesForPollByPollResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Votes) > 0 { + for _, e := range m.Votes { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVotesForPollByVoterRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVotesForPollByVoterResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Votes) > 0 { + for _, e := range m.Votes { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.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 *QueryGroupInfoRequest) 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: QueryGroupInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *QueryGroupInfoResponse) 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: QueryGroupInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", 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 m.Info == nil { + m.Info = &GroupInfo{} + } + if err := m.Info.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 *QueryGroupAccountInfoRequest) 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: QueryGroupAccountInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupAccountInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + 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 *QueryGroupAccountInfoResponse) 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: QueryGroupAccountInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupAccountInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", 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 m.Info == nil { + m.Info = &GroupAccountInfo{} + } + if err := m.Info.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 *QueryGroupMembersRequest) 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: QueryGroupMembersRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupMembersRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 *QueryGroupMembersResponse) 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: QueryGroupMembersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupMembersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Members", 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.Members = append(m.Members, &GroupMember{}) + if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 *QueryGroupsByAdminRequest) 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: QueryGroupsByAdminRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupsByAdminRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 *QueryGroupsByAdminResponse) 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: QueryGroupsByAdminResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupsByAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Groups", 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.Groups = append(m.Groups, &GroupInfo{}) + if err := m.Groups[len(m.Groups)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 *QueryGroupAccountsByGroupRequest) 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: QueryGroupAccountsByGroupRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupAccountsByGroupRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 *QueryGroupAccountsByGroupResponse) 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: QueryGroupAccountsByGroupResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupAccountsByGroupResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupAccounts", 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.GroupAccounts = append(m.GroupAccounts, &GroupAccountInfo{}) + if err := m.GroupAccounts[len(m.GroupAccounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 *QueryGroupAccountsByAdminRequest) 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: QueryGroupAccountsByAdminRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupAccountsByAdminRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 *QueryGroupAccountsByAdminResponse) 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: QueryGroupAccountsByAdminResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGroupAccountsByAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupAccounts", 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.GroupAccounts = append(m.GroupAccounts, &GroupAccountInfo{}) + if err := m.GroupAccounts[len(m.GroupAccounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 m.Pagination != nil { - l = m.Pagination.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)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } -func (m *QueryGroupInfoRequest) Unmarshal(dAtA []byte) error { +func (m *QueryProposalRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3024,17 +5857,17 @@ func (m *QueryGroupInfoRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGroupInfoRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryProposalRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGroupInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryProposalRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) } - m.GroupId = 0 + m.ProposalId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3044,7 +5877,7 @@ func (m *QueryGroupInfoRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GroupId |= uint64(b&0x7F) << shift + m.ProposalId |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -3070,7 +5903,7 @@ func (m *QueryGroupInfoRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGroupInfoResponse) Unmarshal(dAtA []byte) error { +func (m *QueryProposalResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3093,15 +5926,15 @@ func (m *QueryGroupInfoResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGroupInfoResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryProposalResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGroupInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryProposalResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Proposal", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3128,10 +5961,10 @@ func (m *QueryGroupInfoResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Info == nil { - m.Info = &GroupInfo{} + if m.Proposal == nil { + m.Proposal = &Proposal{} } - if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Proposal.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3156,7 +5989,7 @@ func (m *QueryGroupInfoResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGroupAccountInfoRequest) Unmarshal(dAtA []byte) error { +func (m *QueryProposalsByGroupAccountRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3179,10 +6012,10 @@ func (m *QueryGroupAccountInfoRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGroupAccountInfoRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryProposalsByGroupAccountRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGroupAccountInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryProposalsByGroupAccountRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3217,6 +6050,42 @@ func (m *QueryGroupAccountInfoRequest) Unmarshal(dAtA []byte) error { } m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3238,7 +6107,7 @@ func (m *QueryGroupAccountInfoRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGroupAccountInfoResponse) Unmarshal(dAtA []byte) error { +func (m *QueryProposalsByGroupAccountResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3261,15 +6130,15 @@ func (m *QueryGroupAccountInfoResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGroupAccountInfoResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryProposalsByGroupAccountResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGroupAccountInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryProposalsByGroupAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Proposals", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3296,10 +6165,44 @@ func (m *QueryGroupAccountInfoResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Info == nil { - m.Info = &GroupAccountInfo{} + m.Proposals = append(m.Proposals, &Proposal{}) + if err := m.Proposals[len(m.Proposals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3324,7 +6227,7 @@ func (m *QueryGroupAccountInfoResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGroupMembersRequest) Unmarshal(dAtA []byte) error { +func (m *QueryVoteByProposalVoterRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3347,17 +6250,17 @@ func (m *QueryGroupMembersRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGroupMembersRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVoteByProposalVoterRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGroupMembersRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVoteByProposalVoterRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) } - m.GroupId = 0 + m.ProposalId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3367,16 +6270,16 @@ func (m *QueryGroupMembersRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GroupId |= uint64(b&0x7F) << shift + m.ProposalId |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3386,27 +6289,23 @@ func (m *QueryGroupMembersRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Voter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3429,7 +6328,7 @@ func (m *QueryGroupMembersRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGroupMembersResponse) Unmarshal(dAtA []byte) error { +func (m *QueryVoteByProposalVoterResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3452,49 +6351,15 @@ func (m *QueryGroupMembersResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGroupMembersResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVoteByProposalVoterResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGroupMembersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVoteByProposalVoterResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Members", 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.Members = append(m.Members, &GroupMember{}) - if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Vote", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3521,10 +6386,10 @@ func (m *QueryGroupMembersResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} + if m.Vote == nil { + m.Vote = &Vote{} } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Vote.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3549,7 +6414,7 @@ func (m *QueryGroupMembersResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGroupsByAdminRequest) Unmarshal(dAtA []byte) error { +func (m *QueryVotesByProposalRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3572,17 +6437,17 @@ func (m *QueryGroupsByAdminRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGroupsByAdminRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVotesByProposalRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGroupsByAdminRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVotesByProposalRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) } - var stringLen uint64 + m.ProposalId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3592,24 +6457,11 @@ func (m *QueryGroupsByAdminRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ProposalId |= uint64(b&0x7F) << shift if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF + break + } } - m.Admin = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) @@ -3667,7 +6519,7 @@ func (m *QueryGroupsByAdminRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGroupsByAdminResponse) Unmarshal(dAtA []byte) error { +func (m *QueryVotesByProposalResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3690,15 +6542,15 @@ func (m *QueryGroupsByAdminResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGroupsByAdminResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVotesByProposalResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGroupsByAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVotesByProposalResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Groups", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Votes", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3725,8 +6577,8 @@ func (m *QueryGroupsByAdminResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Groups = append(m.Groups, &GroupInfo{}) - if err := m.Groups[len(m.Groups)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Votes = append(m.Votes, &Vote{}) + if err := m.Votes[len(m.Votes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3787,7 +6639,7 @@ func (m *QueryGroupsByAdminResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGroupAccountsByGroupRequest) Unmarshal(dAtA []byte) error { +func (m *QueryVotesByVoterRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3810,17 +6662,17 @@ func (m *QueryGroupAccountsByGroupRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGroupAccountsByGroupRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVotesByVoterRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGroupAccountsByGroupRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVotesByVoterRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) } - m.GroupId = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3830,11 +6682,24 @@ func (m *QueryGroupAccountsByGroupRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GroupId |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Voter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) @@ -3892,7 +6757,7 @@ func (m *QueryGroupAccountsByGroupRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGroupAccountsByGroupResponse) Unmarshal(dAtA []byte) error { +func (m *QueryVotesByVoterResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3915,15 +6780,15 @@ func (m *QueryGroupAccountsByGroupResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGroupAccountsByGroupResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVotesByVoterResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGroupAccountsByGroupResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVotesByVoterResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupAccounts", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Votes", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3950,8 +6815,8 @@ func (m *QueryGroupAccountsByGroupResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.GroupAccounts = append(m.GroupAccounts, &GroupAccountInfo{}) - if err := m.GroupAccounts[len(m.GroupAccounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Votes = append(m.Votes, &Vote{}) + if err := m.Votes[len(m.Votes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4012,7 +6877,7 @@ func (m *QueryGroupAccountsByGroupResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGroupAccountsByAdminRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPollRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4035,17 +6900,17 @@ func (m *QueryGroupAccountsByAdminRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGroupAccountsByAdminRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPollRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGroupAccountsByAdminRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPollRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) } - var stringLen uint64 + m.PollId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4055,27 +6920,64 @@ func (m *QueryGroupAccountsByAdminRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.PollId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err } - postIndex := iNdEx + intStringLen - if postIndex < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } - if postIndex > l { + if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } - m.Admin = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPollResponse) 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: QueryPollResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPollResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Poll", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4102,10 +7004,10 @@ func (m *QueryGroupAccountsByAdminRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} + if m.Poll == nil { + m.Poll = &Poll{} } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Poll.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4130,7 +7032,7 @@ func (m *QueryGroupAccountsByAdminRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGroupAccountsByAdminResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPollsByGroupRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4153,17 +7055,17 @@ func (m *QueryGroupAccountsByAdminResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGroupAccountsByAdminResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPollsByGroupRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGroupAccountsByAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPollsByGroupRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupAccounts", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) } - var msglen int + m.GroupId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4173,26 +7075,11 @@ func (m *QueryGroupAccountsByAdminResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.GroupId |= uint64(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.GroupAccounts = append(m.GroupAccounts, &GroupAccountInfo{}) - if err := m.GroupAccounts[len(m.GroupAccounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) @@ -4223,7 +7110,7 @@ func (m *QueryGroupAccountsByAdminResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Pagination == nil { - m.Pagination = &query.PageResponse{} + m.Pagination = &query.PageRequest{} } if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -4250,7 +7137,7 @@ func (m *QueryGroupAccountsByAdminResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryProposalRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPollsByGroupResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4273,17 +7160,17 @@ func (m *QueryProposalRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryProposalRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPollsByGroupResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryProposalRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPollsByGroupResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Polls", wireType) } - m.ProposalId = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4293,64 +7180,29 @@ func (m *QueryProposalRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProposalId |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryProposalResponse) 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 + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.Polls = append(m.Polls, &Poll{}) + if err := m.Polls[len(m.Polls)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryProposalResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryProposalResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proposal", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4377,10 +7229,10 @@ func (m *QueryProposalResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Proposal == nil { - m.Proposal = &Proposal{} + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} } - if err := m.Proposal.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4405,7 +7257,7 @@ func (m *QueryProposalResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryProposalsByGroupAccountRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPollsByCreatorRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4428,15 +7280,15 @@ func (m *QueryProposalsByGroupAccountRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryProposalsByGroupAccountRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPollsByCreatorRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryProposalsByGroupAccountRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPollsByCreatorRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4464,7 +7316,7 @@ func (m *QueryProposalsByGroupAccountRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -4523,7 +7375,7 @@ func (m *QueryProposalsByGroupAccountRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryProposalsByGroupAccountResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPollsByCreatorResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4546,15 +7398,15 @@ func (m *QueryProposalsByGroupAccountResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryProposalsByGroupAccountResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPollsByCreatorResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryProposalsByGroupAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPollsByCreatorResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proposals", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Polls", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4581,8 +7433,8 @@ func (m *QueryProposalsByGroupAccountResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Proposals = append(m.Proposals, &Proposal{}) - if err := m.Proposals[len(m.Proposals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Polls = append(m.Polls, &Poll{}) + if err := m.Polls[len(m.Polls)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4643,7 +7495,7 @@ func (m *QueryProposalsByGroupAccountResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryVoteByProposalVoterRequest) Unmarshal(dAtA []byte) error { +func (m *QueryVoteForPollByPollVoterRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4666,17 +7518,17 @@ func (m *QueryVoteByProposalVoterRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryVoteByProposalVoterRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVoteForPollByPollVoterRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryVoteByProposalVoterRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVoteForPollByPollVoterRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) } - m.ProposalId = 0 + m.PollId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4686,7 +7538,7 @@ func (m *QueryVoteByProposalVoterRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProposalId |= uint64(b&0x7F) << shift + m.PollId |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -4744,7 +7596,7 @@ func (m *QueryVoteByProposalVoterRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryVoteByProposalVoterResponse) Unmarshal(dAtA []byte) error { +func (m *QueryVoteForPollByPollVoterResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4767,10 +7619,10 @@ func (m *QueryVoteByProposalVoterResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryVoteByProposalVoterResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVoteForPollByPollVoterResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryVoteByProposalVoterResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVoteForPollByPollVoterResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -4803,7 +7655,7 @@ func (m *QueryVoteByProposalVoterResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Vote == nil { - m.Vote = &Vote{} + m.Vote = &VotePoll{} } if err := m.Vote.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -4830,7 +7682,7 @@ func (m *QueryVoteByProposalVoterResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryVotesByProposalRequest) Unmarshal(dAtA []byte) error { +func (m *QueryVotesForPollByPollRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4853,17 +7705,17 @@ func (m *QueryVotesByProposalRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryVotesByProposalRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVotesForPollByPollRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryVotesByProposalRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVotesForPollByPollRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) } - m.ProposalId = 0 + m.PollId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4873,7 +7725,7 @@ func (m *QueryVotesByProposalRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProposalId |= uint64(b&0x7F) << shift + m.PollId |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -4935,7 +7787,7 @@ func (m *QueryVotesByProposalRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryVotesByProposalResponse) Unmarshal(dAtA []byte) error { +func (m *QueryVotesForPollByPollResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4958,10 +7810,10 @@ func (m *QueryVotesByProposalResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryVotesByProposalResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVotesForPollByPollResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryVotesByProposalResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVotesForPollByPollResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -4993,7 +7845,7 @@ func (m *QueryVotesByProposalResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Votes = append(m.Votes, &Vote{}) + m.Votes = append(m.Votes, &VotePoll{}) if err := m.Votes[len(m.Votes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5055,7 +7907,7 @@ func (m *QueryVotesByProposalResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryVotesByVoterRequest) Unmarshal(dAtA []byte) error { +func (m *QueryVotesForPollByVoterRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5078,10 +7930,10 @@ func (m *QueryVotesByVoterRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryVotesByVoterRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVotesForPollByVoterRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryVotesByVoterRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVotesForPollByVoterRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -5173,7 +8025,7 @@ func (m *QueryVotesByVoterRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryVotesByVoterResponse) Unmarshal(dAtA []byte) error { +func (m *QueryVotesForPollByVoterResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5196,10 +8048,10 @@ func (m *QueryVotesByVoterResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryVotesByVoterResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVotesForPollByVoterResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryVotesByVoterResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVotesForPollByVoterResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -5231,7 +8083,7 @@ func (m *QueryVotesByVoterResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Votes = append(m.Votes, &Vote{}) + m.Votes = append(m.Votes, &VotePoll{}) if err := m.Votes[len(m.Votes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/group/query.pb.gw.go b/x/group/query.pb.gw.go index cf68aee623..ec070b66d1 100644 --- a/x/group/query.pb.gw.go +++ b/x/group/query.pb.gw.go @@ -775,6 +775,388 @@ func local_request_Query_VotesByVoter_0(ctx context.Context, marshaler runtime.M } +func request_Query_Poll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPollRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["poll_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "poll_id") + } + + protoReq.PollId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "poll_id", err) + } + + msg, err := client.Poll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Poll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPollRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["poll_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "poll_id") + } + + protoReq.PollId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "poll_id", err) + } + + msg, err := server.Poll(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_PollsByGroup_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_PollsByGroup_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPollsByGroupRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PollsByGroup_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.PollsByGroup(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PollsByGroup_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPollsByGroupRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PollsByGroup_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.PollsByGroup(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_PollsByCreator_0 = &utilities.DoubleArray{Encoding: map[string]int{"creator": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_PollsByCreator_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPollsByCreatorRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["creator"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "creator") + } + + protoReq.Creator, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "creator", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PollsByCreator_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.PollsByCreator(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PollsByCreator_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPollsByCreatorRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["creator"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "creator") + } + + protoReq.Creator, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "creator", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PollsByCreator_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.PollsByCreator(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_VoteForPollByPollVoter_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryVoteForPollByPollVoterRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["poll_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "poll_id") + } + + protoReq.PollId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "poll_id", err) + } + + val, ok = pathParams["voter"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "voter") + } + + protoReq.Voter, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "voter", err) + } + + msg, err := client.VoteForPollByPollVoter(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_VoteForPollByPollVoter_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryVoteForPollByPollVoterRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["poll_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "poll_id") + } + + protoReq.PollId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "poll_id", err) + } + + val, ok = pathParams["voter"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "voter") + } + + protoReq.Voter, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "voter", err) + } + + msg, err := server.VoteForPollByPollVoter(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_VotesForPollByPoll_0 = &utilities.DoubleArray{Encoding: map[string]int{"poll_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_VotesForPollByPoll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryVotesForPollByPollRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["poll_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "poll_id") + } + + protoReq.PollId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "poll_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_VotesForPollByPoll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.VotesForPollByPoll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_VotesForPollByPoll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryVotesForPollByPollRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["poll_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "poll_id") + } + + protoReq.PollId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "poll_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_VotesForPollByPoll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.VotesForPollByPoll(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_VotesForPollByVoter_0 = &utilities.DoubleArray{Encoding: map[string]int{"voter": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_VotesForPollByVoter_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryVotesForPollByVoterRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["voter"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "voter") + } + + protoReq.Voter, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "voter", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_VotesForPollByVoter_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.VotesForPollByVoter(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_VotesForPollByVoter_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryVotesForPollByVoterRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["voter"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "voter") + } + + protoReq.Voter, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "voter", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_VotesForPollByVoter_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.VotesForPollByVoter(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. @@ -1034,6 +1416,144 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_Poll_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_Poll_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_Poll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PollsByGroup_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_PollsByGroup_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_PollsByGroup_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PollsByCreator_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_PollsByCreator_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_PollsByCreator_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_VoteForPollByPollVoter_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_VoteForPollByPollVoter_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_VoteForPollByPollVoter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_VotesForPollByPoll_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_VotesForPollByPoll_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_VotesForPollByPoll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_VotesForPollByVoter_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_VotesForPollByVoter_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_VotesForPollByVoter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1295,6 +1815,126 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_Poll_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_Poll_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_Poll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PollsByGroup_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_PollsByGroup_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_PollsByGroup_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PollsByCreator_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_PollsByCreator_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_PollsByCreator_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_VoteForPollByPollVoter_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_VoteForPollByPollVoter_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_VoteForPollByPollVoter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_VotesForPollByPoll_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_VotesForPollByPoll_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_VotesForPollByPoll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_VotesForPollByVoter_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_VotesForPollByVoter_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_VotesForPollByVoter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1320,6 +1960,18 @@ var ( pattern_Query_VotesByProposal_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"regen", "group", "v1alpha1", "proposals", "proposal_id", "votes"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_VotesByVoter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"regen", "group", "v1alpha1", "voters", "voter"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Poll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"regen", "group", "v1alpha1", "polls", "poll_id"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_PollsByGroup_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1, 2, 3}, []string{"regen", "group", "v1alpha1", "polls"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_PollsByCreator_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"regen", "group", "v1alpha1", "creators", "creator", "polls"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_VoteForPollByPollVoter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"regen", "group", "v1alpha1", "polls", "poll_id", "votes", "voter"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_VotesForPollByPoll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"regen", "group", "v1alpha1", "polls", "poll_id", "votes"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_VotesForPollByVoter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"regen", "group", "v1alpha1", "voters", "voter"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -1344,4 +1996,16 @@ var ( forward_Query_VotesByProposal_0 = runtime.ForwardResponseMessage forward_Query_VotesByVoter_0 = runtime.ForwardResponseMessage + + forward_Query_Poll_0 = runtime.ForwardResponseMessage + + forward_Query_PollsByGroup_0 = runtime.ForwardResponseMessage + + forward_Query_PollsByCreator_0 = runtime.ForwardResponseMessage + + forward_Query_VoteForPollByPollVoter_0 = runtime.ForwardResponseMessage + + forward_Query_VotesForPollByPoll_0 = runtime.ForwardResponseMessage + + forward_Query_VotesForPollByVoter_0 = runtime.ForwardResponseMessage ) diff --git a/x/group/server/genesis.go b/x/group/server/genesis.go index e6081fb153..d244896a03 100644 --- a/x/group/server/genesis.go +++ b/x/group/server/genesis.go @@ -39,6 +39,14 @@ func (s serverImpl) InitGenesis(ctx types.Context, cdc codec.Codec, data json.Ra return nil, errors.Wrap(err, "votes") } + if err := orm.ImportTableData(ctx, s.pollTable, genesisState.Polls, genesisState.PollSeq); err != nil { + return nil, errors.Wrap(err, "polls") + } + + if err := orm.ImportTableData(ctx, s.votePollTable, genesisState.VotesForPoll, 0); err != nil { + return nil, errors.Wrap(err, "votes") + } + return []abci.ValidatorUpdate{}, nil } @@ -83,6 +91,21 @@ func (s serverImpl) ExportGenesis(ctx types.Context, cdc codec.Codec) (json.RawM } genesisState.Votes = votes + var polls []*group.Poll + pollSeq, err := orm.ExportTableData(ctx, s.pollTable, &polls) + if err != nil { + return nil, errors.Wrap(err, "polls") + } + genesisState.Polls = polls + genesisState.PollSeq = pollSeq + + var votesForPoll []*group.VotePoll + _, err = orm.ExportTableData(ctx, s.votePollTable, &votesForPoll) + if err != nil { + return nil, errors.Wrap(err, "votes for poll") + } + genesisState.VotesForPoll = votesForPoll + genesisBytes := cdc.MustMarshalJSON(genesisState) return genesisBytes, nil } diff --git a/x/group/server/msg_server.go b/x/group/server/msg_server.go index 7b7b46a721..23599daa00 100644 --- a/x/group/server/msg_server.go +++ b/x/group/server/msg_server.go @@ -37,7 +37,7 @@ func (s serverImpl) validateBlsMember(ctx types.Context, mem group.Member) error return fmt.Errorf("account public key not set yet") } - if pk.Type() != bls12381.KeyType { + if _, ok := pk.(*bls12381.PubKey); !ok { return fmt.Errorf("member account %s is not a bls account", mem.Address) } @@ -63,14 +63,10 @@ func (s serverImpl) CreateGroup(goCtx context.Context, req *group.MsgCreateGroup return nil, err } - if err := assertMetadataLength(metadata, "group metadata"); err != nil { - return nil, err - } - if bls { for _, mem := range members.Members { if err := s.validateBlsMember(ctx, mem); err != nil { - return nil, err + return nil, sdkerrors.Wrapf(err, "member %s failed bls validation", mem.Address) } } } @@ -78,9 +74,6 @@ func (s serverImpl) CreateGroup(goCtx context.Context, req *group.MsgCreateGroup totalWeight := apd.New(0, 0) for i := range members.Members { m := members.Members[i] - if err := assertMetadataLength(m.Metadata, "member metadata"); err != nil { - return nil, err - } // Members of a group must have a positive weight. weight, err := math.ParsePositiveDecimal(m.Weight) @@ -150,9 +143,6 @@ func (s serverImpl) UpdateGroupMembers(goCtx context.Context, req *group.MsgUpda } for i := range req.MemberUpdates { - if err := assertMetadataLength(req.MemberUpdates[i].Metadata, "group member metadata"); err != nil { - return err - } groupMember := group.GroupMember{GroupId: req.GroupId, Member: &group.Member{ Address: req.MemberUpdates[i].Address, @@ -266,10 +256,6 @@ func (s serverImpl) UpdateGroupMetadata(goCtx context.Context, req *group.MsgUpd return s.groupTable.Save(ctx, g.GroupId, g) } - if err := assertMetadataLength(req.Metadata, "group metadata"); err != nil { - return nil, err - } - err := s.doUpdateGroup(ctx, req, action, "metadata updated") if err != nil { return nil, err @@ -288,10 +274,6 @@ func (s serverImpl) CreateGroupAccount(goCtx context.Context, req *group.MsgCrea groupID := req.GetGroupID() metadata := req.GetMetadata() - if err := assertMetadataLength(metadata, "group account metadata"); err != nil { - return nil, err - } - g, err := s.getGroupInfo(ctx, groupID) if err != nil { return nil, err @@ -410,10 +392,6 @@ func (s serverImpl) UpdateGroupAccountMetadata(goCtx context.Context, req *group return s.groupAccountTable.Save(ctx, groupAccount) } - if err := assertMetadataLength(metadata, "group account metadata"); err != nil { - return nil, err - } - err := s.doUpdateGroupAccount(ctx, req.Address, req.Admin, action, "group account metadata updated") if err != nil { return nil, err @@ -432,10 +410,6 @@ func (s serverImpl) CreateProposal(goCtx context.Context, req *group.MsgCreatePr proposers := req.Proposers msgs := req.GetMsgs() - if err := assertMetadataLength(metadata, "metadata"); err != nil { - return nil, err - } - account, err := s.getGroupAccountInfo(ctx, accountAddress.Bytes()) if err != nil { return nil, sdkerrors.Wrap(err, "load group account") @@ -554,10 +528,6 @@ func (s serverImpl) Vote(goCtx context.Context, req *group.MsgVote) (*group.MsgV choice := req.Choice metadata := req.Metadata - if err := assertMetadataLength(metadata, "metadata"); err != nil { - return nil, err - } - blockTime, err := gogotypes.TimestampProto(ctx.BlockTime()) if err != nil { return nil, err @@ -676,11 +646,7 @@ func (s serverImpl) VoteAgg(goCtx context.Context, req *group.MsgVoteAgg) (*grou id := req.ProposalId choices := req.Votes metadata := req.Metadata - votesExpire := req.Timeout - - if err := assertMetadataLength(metadata, "metadata"); err != nil { - return nil, err - } + votesExpire := req.Expiry blockTime, err := gogotypes.TimestampProto(ctx.BlockTime()) if err != nil { @@ -699,7 +665,7 @@ func (s serverImpl) VoteAgg(goCtx context.Context, req *group.MsgVoteAgg) (*grou if proposal.Status != group.ProposalStatusSubmitted { return nil, sdkerrors.Wrap(group.ErrInvalid, "proposal not open for voting") } - if proposal.Timeout.Compare(ctx.BlockTime()) <= 0 { + if proposal.Timeout.Compare(blockTime) <= 0 { return nil, sdkerrors.Wrap(group.ErrExpired, "voting period has ended already") } @@ -766,13 +732,12 @@ func (s serverImpl) VoteAgg(goCtx context.Context, req *group.MsgVoteAgg) (*grou return nil, sdkerrors.Wrapf(group.ErrInvalid, "public key for account %s not set yet", memAddr.String()) } - meta := fmt.Sprintf("submitted through aggregated vote by %s", req.Sender) if choices[i] != group.Choice_CHOICE_UNSPECIFIED { vote := group.Vote{ ProposalId: id, Voter: mem.Member.Address, Choice: choices[i], - Metadata: []byte(meta), + Metadata: metadata, SubmittedAt: *blockTime, } votes = append(votes, vote) @@ -784,7 +749,7 @@ func (s serverImpl) VoteAgg(goCtx context.Context, req *group.MsgVoteAgg) (*grou msg := group.MsgVoteBasic{ ProposalId: id, Choice: choices[i], - Timeout: votesExpire, + Expiry: votesExpire, } msgMap[choices[i]] = msg.GetSignBytes() } @@ -808,25 +773,24 @@ func (s serverImpl) VoteAgg(goCtx context.Context, req *group.MsgVoteAgg) (*grou pkss = append(pkss, pkMap[c]) } - if err = VerifyAggSignature(msgBytes, false, req.AggSig, pkss); err != nil { + if err = group.VerifyAggregateSignature(msgBytes, false, req.AggSig, pkss); err != nil { return nil, err } // Count and store votes. for i := range votes { - if err := proposal.VoteState.Add(votes[i], weights[i]); err != nil { - return nil, sdkerrors.Wrap(err, "add new vote") - } - - // If the vote already exists, skip the new vote - if err := s.voteTable.Create(ctx, &votes[i]); err != nil { - if orm.ErrUniqueConstraint.Is(err) { - if err := proposal.VoteState.Sub(votes[i], weights[i]); err != nil { - return nil, sdkerrors.Wrap(err, "sub new vote") + err := proposal.VoteState.Add(votes[i], weights[i]) + if err == nil { + // If the vote already exists, skip the new vote + if err := s.voteTable.Create(ctx, &votes[i]); err != nil { + if orm.ErrUniqueConstraint.Is(err) { + if err := proposal.VoteState.Sub(votes[i], weights[i]); err != nil { + return nil, sdkerrors.Wrap(err, "sub new vote") + } + continue } - continue + return nil, err } - return nil, err } } @@ -942,6 +906,320 @@ func (s serverImpl) Exec(goCtx context.Context, req *group.MsgExec) (*group.MsgE return res, nil } +func (s serverImpl) CreatePoll(goCtx context.Context, req *group.MsgCreatePoll) (*group.MsgCreatePollResponse, error) { + ctx := types.UnwrapSDKContext(goCtx) + creator := req.Creator + groupId := req.GroupId + endTime := req.Timeout + metadata := req.Metadata + title := req.Title + options := req.Options + limit := req.VoteLimit + + g, err := s.getGroupInfo(ctx, groupId) + if err != nil { + return nil, sdkerrors.Wrap(err, "get group by account") + } + + // Only members of the group can submit a new poll. + if !s.groupMemberTable.Has(ctx, orm.PrimaryKey(&group.GroupMember{GroupId: g.GroupId, Member: &group.Member{Address: creator}})) { + return nil, sdkerrors.Wrapf(group.ErrUnauthorized, "not in group: %s", creator) + } + + blockTime, err := gogotypes.TimestampProto(ctx.BlockTime()) + if err != nil { + return nil, sdkerrors.Wrap(err, "block time conversion") + } + + if endTime.Compare(blockTime) <= 0 { + return nil, sdkerrors.Wrap(group.ErrExpired, "poll already expired") + } + + m := &group.Poll{ + PollId: s.pollTable.Sequence().PeekNextVal(ctx), + GroupId: groupId, + Title: title, + Options: options, + Creator: creator, + VoteLimit: limit, + Metadata: metadata, + SubmittedAt: *blockTime, + GroupVersion: g.Version, + Status: group.PollStatusSubmitted, + Timeout: endTime, + } + + id, err := s.pollTable.Create(ctx, m) + if err != nil { + return nil, sdkerrors.Wrap(err, "create poll") + } + + err = ctx.EventManager().EmitTypedEvent(&group.EventCreatePoll{PollId: id}) + if err != nil { + return nil, err + } + + return &group.MsgCreatePollResponse{PollId: id}, nil +} + +func (s serverImpl) VotePoll(goCtx context.Context, req *group.MsgVotePoll) (*group.MsgVotePollResponse, error) { + ctx := types.UnwrapSDKContext(goCtx) + id := req.PollId + options := req.Options + metadata := req.Metadata + + blockTime, err := gogotypes.TimestampProto(ctx.BlockTime()) + if err != nil { + return nil, err + } + poll, err := s.getPoll(ctx, id) + if err != nil { + return nil, err + } + // Ensure that we can still accept votes for this poll. + if poll.Status != group.PollStatusSubmitted { + return nil, sdkerrors.Wrap(group.ErrInvalid, "poll not open for voting") + } + if poll.Timeout.Compare(blockTime) <= 0 { + poll.Status = group.PollStatusClosed + if err = s.pollTable.Save(ctx, id, &poll); err != nil { + return nil, err + } + return nil, sdkerrors.Wrap(group.ErrExpired, "voting period for the poll has ended") + } + + if err := assertOptionsSubset(options, poll.Options, "options"); err != nil { + return nil, err + } + + if len(options.Titles) > int(poll.VoteLimit) { + return nil, sdkerrors.Wrap(group.ErrInvalid, "voter options exceed limit") + } + + // Ensure that group hasn't been modified since the proposal submission. + electorate, err := s.getGroupInfo(ctx, poll.GroupId) + if err != nil { + return nil, err + } + if electorate.Version != poll.GroupVersion { + return nil, sdkerrors.Wrap(group.ErrModified, "group was modified") + } + + // Count and store votes. + voterAddr := req.Voter + voter := group.GroupMember{GroupId: electorate.GroupId, Member: &group.Member{Address: voterAddr}} + if err := s.groupMemberTable.GetOne(ctx, orm.PrimaryKey(&voter), &voter); err != nil { + return nil, sdkerrors.Wrapf(err, "address: %s", voterAddr) + } + + newVote := group.VotePoll{ + PollId: id, + Voter: voterAddr, + Options: options, + Metadata: metadata, + SubmittedAt: *blockTime, + } + if len(poll.VoteState.Counts) == 0 { + poll.VoteState.Counts = make(map[string]string) + } + + if err := poll.VoteState.Add(newVote, voter.Member.Weight); err != nil { + return nil, sdkerrors.Wrap(err, "add new vote") + } + + // The ORM will return an error if the vote already exists, + // making sure than a voter hasn't already voted. + if err := s.votePollTable.Create(ctx, &newVote); err != nil { + return nil, sdkerrors.Wrap(err, "store vote") + } + + if err = s.pollTable.Save(ctx, id, &poll); err != nil { + return nil, err + } + + err = ctx.EventManager().EmitTypedEvent(&group.EventVotePoll{PollId: id}) + if err != nil { + return nil, err + } + + return &group.MsgVotePollResponse{}, nil +} + +// VotePollAgg processes an aggregated votes for poll. The votes are signed and aggregated +// on an option-basis instead of voter-basis, which means the verification time of the +// aggregated signature is linear of the number of options instead of the number of voters. +// The total number of options should be kept small so the verification of the aggregated signature can be more efficient. +func (s serverImpl) VotePollAgg(goCtx context.Context, req *group.MsgVotePollAgg) (*group.MsgVotePollAggResponse, error) { + ctx := types.UnwrapSDKContext(goCtx) + id := req.PollId + votes := req.Votes + metadata := req.Metadata + votesExpire := req.Expiry + + blockTime, err := gogotypes.TimestampProto(ctx.BlockTime()) + if err != nil { + return nil, err + } + + if votesExpire.Compare(blockTime) <= 0 { + return nil, sdkerrors.Wrap(group.ErrExpired, "the aggregated votes have expired") + } + + poll, err := s.getPoll(ctx, id) + if err != nil { + return nil, err + } + // Ensure that we can still accept votes for this poll. + if poll.Status != group.PollStatusSubmitted { + return nil, sdkerrors.Wrap(group.ErrInvalid, "poll not open for voting") + } + if poll.Timeout.Compare(blockTime) <= 0 { + poll.Status = group.PollStatusClosed + if err = s.pollTable.Save(ctx, id, &poll); err != nil { + return nil, err + } + return nil, sdkerrors.Wrap(group.ErrExpired, "voting period for the poll has ended") + } + + // Ensure that group hasn't been modified since the proposal submission. + electorate, err := s.getGroupInfo(ctx, poll.GroupId) + if err != nil { + return nil, err + } + if electorate.Version != poll.GroupVersion { + return nil, sdkerrors.Wrap(group.ErrModified, "group was modified") + } + + for _, v := range votes { + if err = assertOptionsSubset(v, poll.Options, "aggregated vote for poll"); err != nil { + return nil, sdkerrors.Wrap(group.ErrInvalid, err.Error()) + } + if len(v.Titles) > int(poll.VoteLimit) { + return nil, sdkerrors.Wrap(group.ErrInvalid, "voter options exceed limit") + } + } + + membersIter, err := s.groupMemberByGroupIndex.Get(ctx, electorate.GroupId) + if err != nil { + return nil, err + } + + // Count and store votes. + var weights []string + pkMap := make(map[string][]cryptotypes.PubKey, len(poll.Options.Titles)) + msgMap := make(map[string][]byte, len(poll.Options.Titles)) + var votesStore []group.VotePoll + numPk := uint64(0) + for i := 0; ; i++ { + var mem group.GroupMember + _, err := membersIter.LoadNext(&mem) + if err != nil { + if orm.ErrIteratorDone.Is(err) { + if i < len(votes) { + return nil, sdkerrors.Wrap(group.ErrInvalid, "too many votes") + } + break + } + return nil, err + } + + memAddr, err := sdk.AccAddressFromBech32(mem.Member.Address) + if err != nil { + return nil, err + } + + if i >= len(votes) { + return nil, sdkerrors.Wrap(group.ErrInvalid, "not enough votes") + } + + acc := s.accKeeper.GetAccount(ctx.Context, memAddr) + if acc == nil { + return nil, sdkerrors.Wrapf(group.ErrInvalid, "account %s does not exist", memAddr.String()) + } + pk := acc.GetPubKey() + if pk == nil { + return nil, sdkerrors.Wrapf(group.ErrInvalid, "public key for account %s not set yet", memAddr.String()) + } + + if len(votes[i].Titles) != 0 { + vote := group.VotePoll{ + PollId: id, + Voter: mem.Member.Address, + Options: votes[i], + Metadata: metadata, + SubmittedAt: *blockTime, + } + votesStore = append(votesStore, vote) + weights = append(weights, mem.Member.Weight) + for _, ot := range votes[i].Titles { + if _, ok := msgMap[ot]; !ok { + msg := group.MsgVotePollBasic{ + PollId: id, + Option: ot, + Expiry: votesExpire, + } + msgMap[ot] = msg.GetSignBytes() + } + pkMap[ot] = append(pkMap[ot], pk) + numPk++ + } + } + } + + // calculate and consume gas before the verification of the aggregated signature + numVotedOption := uint64(len(msgMap)) + params := s.accKeeper.GetParams(ctx.Context) + err = DefaultAggSigVerifyGasConsumer(ctx.GasMeter(), numPk, numVotedOption, params) + if err != nil { + return nil, sdkerrors.Wrap(err, "gas consumption for verifying aggregated signature") + } + + msgBytes := make([][]byte, 0, numVotedOption) + pkss := make([][]cryptotypes.PubKey, 0, numVotedOption) + for c := range msgMap { + msgBytes = append(msgBytes, msgMap[c]) + pkss = append(pkss, pkMap[c]) + } + + if err = group.VerifyAggregateSignature(msgBytes, false, req.AggSig, pkss); err != nil { + return nil, err + } + + // Count and store votes. + if len(poll.VoteState.Counts) == 0 { + poll.VoteState.Counts = make(map[string]string, len(votesStore)) + } + + for i := range votesStore { + // skip the vote if error + err := poll.VoteState.Add(votesStore[i], weights[i]) + if err != nil { + continue + } + // If the vote already exists, skip the new vote + if err := s.votePollTable.Create(ctx, &votesStore[i]); err != nil { + if orm.ErrUniqueConstraint.Is(err) { + if err := poll.VoteState.Sub(votesStore[i], weights[i]); err != nil { + return nil, sdkerrors.Wrap(err, "sub new vote") + } + continue + } + return nil, err + } + } + + if err = s.pollTable.Save(ctx, id, &poll); err != nil { + return nil, err + } + + err = ctx.EventManager().EmitTypedEvent(&group.EventVotePoll{PollId: id}) + if err != nil { + return nil, err + } + + return &group.MsgVotePollAggResponse{}, nil +} + type authNGroupReq interface { GetGroupID() uint64 GetAdmin() string @@ -1025,11 +1303,18 @@ func (s serverImpl) doAuthenticated(ctx types.Context, req authNGroupReq, action return nil } -// assertMetadataLength returns an error if given metadata length -// is greater than a fixed maxMetadataLength. -func assertMetadataLength(metadata []byte, description string) error { - if len(metadata) > group.MaxMetadataLength { - return sdkerrors.Wrap(group.ErrMaxLimit, description) +func assertOptionsSubset(a group.Options, b group.Options, description string) error { + for _, x := range a.Titles { + foundX := false + for _, y := range b.Titles { + if x == y { + foundX = true + break + } + } + if !foundX { + return sdkerrors.Wrap(group.ErrInvalid, description) + } } return nil } diff --git a/x/group/server/query_server.go b/x/group/server/query_server.go index e04b200701..8ee510de86 100644 --- a/x/group/server/query_server.go +++ b/x/group/server/query_server.go @@ -270,3 +270,145 @@ func (s serverImpl) getVotesByProposal(ctx types.Context, proposalID uint64, pag func (s serverImpl) getVotesByVoter(ctx types.Context, voter sdk.AccAddress, pageRequest *query.PageRequest) (orm.Iterator, error) { return s.voteByVoterIndex.GetPaginated(ctx, voter.Bytes(), pageRequest) } + +func (s serverImpl) Poll(goCtx context.Context, request *group.QueryPollRequest) (*group.QueryPollResponse, error) { + ctx := types.UnwrapSDKContext(goCtx) + pollID := request.PollId + poll, err := s.getPoll(ctx, pollID) + if err != nil { + return nil, err + } + + return &group.QueryPollResponse{Poll: &poll}, nil +} + +func (s serverImpl) getPoll(ctx types.Context, pollID uint64) (group.Poll, error) { + var p group.Poll + if _, err := s.pollTable.GetOne(ctx, pollID, &p); err != nil { + return group.Poll{}, sdkerrors.Wrap(err, "load poll") + } + return p, nil +} + +func (s serverImpl) PollsByGroup(goCtx context.Context, request *group.QueryPollsByGroupRequest) (*group.QueryPollsByGroupResponse, error) { + ctx := types.UnwrapSDKContext(goCtx) + groupID := request.GroupId + it, err := s.getPollsByGroup(ctx, groupID, request.Pagination) + if err != nil { + return nil, err + } + + var polls []*group.Poll + pageRes, err := orm.Paginate(it, request.Pagination, &polls) + if err != nil { + return nil, err + } + + return &group.QueryPollsByGroupResponse{ + Polls: polls, + Pagination: pageRes, + }, nil +} + +func (s serverImpl) getPollsByGroup(ctx types.Context, id uint64, pageRequest *query.PageRequest) (orm.Iterator, error) { + return s.pollByGroupIndex.GetPaginated(ctx, id, pageRequest) +} + +func (s serverImpl) PollsByCreator(goCtx context.Context, request *group.QueryPollsByCreatorRequest) (*group.QueryPollsByCreatorResponse, error) { + ctx := types.UnwrapSDKContext(goCtx) + addr, err := sdk.AccAddressFromBech32(request.Creator) + if err != nil { + return nil, err + } + it, err := s.getPollsByCreator(ctx, addr, request.Pagination) + if err != nil { + return nil, err + } + + var polls []*group.Poll + pageRes, err := orm.Paginate(it, request.Pagination, &polls) + if err != nil { + return nil, err + } + + return &group.QueryPollsByCreatorResponse{ + Polls: polls, + Pagination: pageRes, + }, nil +} + +func (s serverImpl) getPollsByCreator(ctx types.Context, account sdk.AccAddress, pageRequest *query.PageRequest) (orm.Iterator, error) { + return s.pollByCreatorIndex.GetPaginated(ctx, account.Bytes(), pageRequest) +} + +func (s serverImpl) VoteForPollByPollVoter(goCtx context.Context, request *group.QueryVoteForPollByPollVoterRequest) (*group.QueryVoteForPollByPollVoterResponse, error) { + ctx := types.UnwrapSDKContext(goCtx) + addr, err := sdk.AccAddressFromBech32(request.Voter) + if err != nil { + return nil, err + } + pollID := request.PollId + vote, err := s.getVoteForPoll(ctx, pollID, addr) + if err != nil { + return nil, err + } + return &group.QueryVoteForPollByPollVoterResponse{ + Vote: &vote, + }, nil +} + +func (s serverImpl) VotesForPollByPoll(goCtx context.Context, request *group.QueryVotesForPollByPollRequest) (*group.QueryVotesForPollByPollResponse, error) { + ctx := types.UnwrapSDKContext(goCtx) + pollID := request.PollId + it, err := s.getVotesForPollByPoll(ctx, pollID, request.Pagination) + if err != nil { + return nil, err + } + + var votes []*group.VotePoll + pageRes, err := orm.Paginate(it, request.Pagination, &votes) + if err != nil { + return nil, err + } + + return &group.QueryVotesForPollByPollResponse{ + Votes: votes, + Pagination: pageRes, + }, nil +} + +func (s serverImpl) VotesForPollByVoter(goCtx context.Context, request *group.QueryVotesForPollByVoterRequest) (*group.QueryVotesForPollByVoterResponse, error) { + ctx := types.UnwrapSDKContext(goCtx) + addr, err := sdk.AccAddressFromBech32(request.Voter) + if err != nil { + return nil, err + } + it, err := s.getVotesForPollByVoter(ctx, addr, request.Pagination) + if err != nil { + return nil, err + } + + var votes []*group.VotePoll + pageRes, err := orm.Paginate(it, request.Pagination, &votes) + if err != nil { + return nil, err + } + + return &group.QueryVotesForPollByVoterResponse{ + Votes: votes, + Pagination: pageRes, + }, nil +} + +func (s serverImpl) getVoteForPoll(ctx types.Context, pollID uint64, voter sdk.AccAddress) (group.VotePoll, error) { + var v group.VotePoll + return v, s.votePollTable.GetOne(ctx, orm.PrimaryKey(&group.VotePoll{PollId: pollID, Voter: voter.String()}), &v) +} + +func (s serverImpl) getVotesForPollByPoll(ctx types.Context, pollID uint64, pageRequest *query.PageRequest) (orm.Iterator, error) { + return s.votePollByPollIndex.GetPaginated(ctx, pollID, pageRequest) +} + +func (s serverImpl) getVotesForPollByVoter(ctx types.Context, voter sdk.AccAddress, pageRequest *query.PageRequest) (orm.Iterator, error) { + return s.votePollByVoterIndex.GetPaginated(ctx, voter.Bytes(), pageRequest) +} \ No newline at end of file diff --git a/x/group/server/server.go b/x/group/server/server.go index 80323a5a13..5c38385f22 100644 --- a/x/group/server/server.go +++ b/x/group/server/server.go @@ -37,6 +37,17 @@ const ( VoteTablePrefix byte = 0x40 VoteByProposalIndexPrefix byte = 0x41 VoteByVoterIndexPrefix byte = 0x42 + + // Poll Table + PollTablePrefix byte = 0x90 + PollTableSeqPrefix byte = 0x91 + PollByGroupIndexPrefix byte = 0x92 + PollByCreatorIndexPrefix byte = 0x93 + + // VotePoll Table + VotePollTablePrefix byte = 0xa0 + VotePollByPollIndexPrefix byte = 0xa1 + VotePollByVoterIndexPrefix byte = 0xa2 ) type serverImpl struct { @@ -69,6 +80,16 @@ type serverImpl struct { voteTable orm.PrimaryKeyTable voteByProposalIndex orm.UInt64Index voteByVoterIndex orm.Index + + // Poll Table + pollTable orm.AutoUInt64Table + pollByGroupIndex orm.UInt64Index + pollByCreatorIndex orm.Index + + // VotePoll Table + votePollTable orm.PrimaryKeyTable + votePollByPollIndex orm.UInt64Index + votePollByVoterIndex orm.Index } func newServer(storeKey servermodule.RootModuleKey, accKeeper exported.AccountKeeper, bankKeeper exported.BankKeeper, cdc codec.Codec) serverImpl { @@ -156,6 +177,36 @@ func newServer(storeKey servermodule.RootModuleKey, accKeeper exported.AccountKe }) s.voteTable = voteTableBuilder.Build() + // Poll Table + pollTableBuilder := orm.NewAutoUInt64TableBuilder(PollTablePrefix, PollTableSeqPrefix, storeKey, &group.Poll{}, cdc) + s.pollByGroupIndex = orm.NewUInt64Index(pollTableBuilder, PollByGroupIndexPrefix, func(value interface{}) ([]uint64, error) { + group := value.(*group.Poll).GroupId + return []uint64{group}, nil + }) + s.pollByCreatorIndex = orm.NewIndex(pollTableBuilder, PollByCreatorIndexPrefix, func(value interface{}) ([]orm.RowID, error) { + creator := value.(*group.Poll).Creator + addr, err := sdk.AccAddressFromBech32(creator) + if err != nil { + return nil, err + } + return []orm.RowID{addr.Bytes()}, nil + }) + s.pollTable = pollTableBuilder.Build() + + // VotePoll Table + votePollTableBuilder := orm.NewPrimaryKeyTableBuilder(VotePollTablePrefix, storeKey, &group.VotePoll{}, orm.Max255DynamicLengthIndexKeyCodec{}, cdc) + s.votePollByPollIndex = orm.NewUInt64Index(votePollTableBuilder, VotePollByPollIndexPrefix, func(value interface{}) ([]uint64, error) { + return []uint64{value.(*group.VotePoll).PollId}, nil + }) + s.votePollByVoterIndex = orm.NewIndex(votePollTableBuilder, VotePollByVoterIndexPrefix, func(value interface{}) ([]orm.RowID, error) { + addr, err := sdk.AccAddressFromBech32(value.(*group.VotePoll).Voter) + if err != nil { + return nil, err + } + return []orm.RowID{addr.Bytes()}, nil + }) + s.votePollTable = votePollTableBuilder.Build() + return s } diff --git a/x/group/server/testsuite/suite.go b/x/group/server/testsuite/suite.go index 5d8f6da06c..31d582f140 100644 --- a/x/group/server/testsuite/suite.go +++ b/x/group/server/testsuite/suite.go @@ -1,8 +1,8 @@ package testsuite import ( - "bytes" "context" + "fmt" "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" @@ -313,7 +313,7 @@ func (s *IntegrationTestSuite) TestCreateGroup() { }, mems: blsMembers, }, - "all good with mixed memebers": { + "all good with mixed members": { req: &group.MsgCreateGroup{ Admin: s.addr1.String(), Members: mixedMembers, @@ -326,7 +326,7 @@ func (s *IntegrationTestSuite) TestCreateGroup() { }, mems: mixedMembers, }, - "mixed memebers not allowed when bls only": { + "mixed members not allowed when bls only": { req: &group.MsgCreateGroup{ Admin: s.addr1.String(), Members: mixedMembers, @@ -336,26 +336,6 @@ func (s *IntegrationTestSuite) TestCreateGroup() { expErr: true, mems: mixedMembers, }, - "group metadata too long": { - req: &group.MsgCreateGroup{ - Admin: s.addr1.String(), - Members: members, - Metadata: bytes.Repeat([]byte{1}, 256), - }, - expErr: true, - }, - "member metadata too long": { - req: &group.MsgCreateGroup{ - Admin: s.addr1.String(), - Members: []group.Member{{ - Address: s.addr3.String(), - Weight: "1", - Metadata: bytes.Repeat([]byte{1}, 256), - }}, - Metadata: nil, - }, - expErr: true, - }, "zero member weight": { req: &group.MsgCreateGroup{ Admin: s.addr1.String(), @@ -1056,18 +1036,6 @@ func (s *IntegrationTestSuite) TestCreateGroupAccount() { ), expErr: true, }, - "metadata too long": { - req: &group.MsgCreateGroupAccount{ - Admin: s.addr1.String(), - Metadata: []byte(strings.Repeat("a", 256)), - GroupId: myGroupID, - }, - policy: group.NewThresholdDecisionPolicy( - "1", - gogotypes.Duration{Seconds: 1}, - ), - expErr: true, - }, } for msg, spec := range specs { @@ -1481,15 +1449,6 @@ func (s *IntegrationTestSuite) TestCreateProposal() { expProposal: defaultProposal, postRun: func(sdkCtx sdk.Context) {}, }, - "metadata too long": { - req: &group.MsgCreateProposal{ - Address: accountAddr.String(), - Metadata: bytes.Repeat([]byte{1}, 256), - Proposers: []string{s.addr2.String()}, - }, - expErr: true, - postRun: func(sdkCtx sdk.Context) {}, - }, "group account required": { req: &group.MsgCreateProposal{ Metadata: nil, @@ -1882,16 +1841,6 @@ func (s *IntegrationTestSuite) TestVote() { expErr: true, postRun: func(sdkCtx sdk.Context) {}, }, - "metadata too long": { - req: &group.MsgVote{ - ProposalId: myProposalID, - Voter: s.addr4.String(), - Metadata: bytes.Repeat([]byte{1}, 256), - Choice: group.Choice_CHOICE_NO, - }, - expErr: true, - postRun: func(sdkCtx sdk.Context) {}, - }, "existing proposal required": { req: &group.MsgVote{ ProposalId: 999, @@ -2122,6 +2071,7 @@ func (s *IntegrationTestSuite) TestVote() { } } +// todo: add test for timeout func (s *IntegrationTestSuite) TestVoteAgg() { members := []group.Member{ {Address: s.addrBls1.String(), Weight: "1"}, @@ -2248,28 +2198,28 @@ func (s *IntegrationTestSuite) TestVoteAgg() { msgNo := &group.MsgVoteBasic{ ProposalId: myProposalID, Choice: group.Choice_CHOICE_NO, - Timeout: *voteAggTimeout, + Expiry: *voteAggTimeout, } signBytesNo := msgNo.GetSignBytes() msgYes := &group.MsgVoteBasic{ ProposalId: myProposalID, Choice: group.Choice_CHOICE_YES, - Timeout: *voteAggTimeout, + Expiry: *voteAggTimeout, } signBytesYes := msgYes.GetSignBytes() msgAbstain := &group.MsgVoteBasic{ ProposalId: myProposalID, Choice: group.Choice_CHOICE_ABSTAIN, - Timeout: *voteAggTimeout, + Expiry: *voteAggTimeout, } signBytesAbstain := msgAbstain.GetSignBytes() msgVeto := &group.MsgVoteBasic{ ProposalId: myProposalID, Choice: group.Choice_CHOICE_VETO, - Timeout: *voteAggTimeout, + Expiry: *voteAggTimeout, } signBytesVeto := msgVeto.GetSignBytes() @@ -2312,7 +2262,7 @@ func (s *IntegrationTestSuite) TestVoteAgg() { Sender: s.addr1.String(), ProposalId: myProposalID, Votes: sortedVotesAcc, - Timeout: *voteAggTimeout, + Expiry: *voteAggTimeout, AggSig: sigmaAcc, Exec: group.Exec_EXEC_TRY, }, @@ -2338,7 +2288,7 @@ func (s *IntegrationTestSuite) TestVoteAgg() { Sender: s.addr1.String(), ProposalId: myProposalID, Votes: sortedVotesRej, - Timeout: *voteAggTimeout, + Expiry: *voteAggTimeout, AggSig: sigmaRej, Exec: group.Exec_EXEC_TRY, }, @@ -2359,6 +2309,17 @@ func (s *IntegrationTestSuite) TestVoteAgg() { s.Require().Equal(sdk.Coins{}, toBalances) }, }, + "invalid signature": { + req: &group.MsgVoteAgg{ + Sender: s.addr1.String(), + ProposalId: myProposalID, + Votes: sortedVotesAcc, + Expiry: *voteAggTimeout, + AggSig: sigmaRej, + Exec: group.Exec_EXEC_TRY, + }, + expErr: true, + }, } for msg, spec := range specs { @@ -2639,6 +2600,750 @@ func (s *IntegrationTestSuite) TestExecProposal() { } } +func (s *IntegrationTestSuite) TestCreatePoll() { + myGroupID := s.groupID + now := s.blockTime + endTime, err := gogotypes.TimestampProto(now.Add(time.Second * 100)) + s.Require().NoError(err) + past := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC) + oldTime, err := gogotypes.TimestampProto(past) + + defaultPoll := group.Poll{ + Status: group.PollStatusSubmitted, + } + + specs := map[string]struct { + req *group.MsgCreatePoll + expPoll group.Poll + expErr bool + }{ + "all good": { + req: &group.MsgCreatePoll{ + GroupId: myGroupID, + Title: "2021 Election", + Options: group.Options{Titles: []string{"alice", "bob", "charlie"}}, + Creator: s.addr2.String(), + VoteLimit: 2, + Timeout: *endTime, + }, + expPoll: defaultPoll, + }, + "only group members can create a poll": { + req: &group.MsgCreatePoll{ + GroupId: myGroupID, + Title: "2021 Election", + Options: group.Options{Titles: []string{"alice", "bob", "charlie"}}, + Creator: s.addr4.String(), + VoteLimit: 2, + Timeout: *endTime, + }, + expErr: true, + }, + "admin that is not a group member can not create poll": { + req: &group.MsgCreatePoll{ + GroupId: myGroupID, + Title: "2021 Election", + Options: group.Options{Titles: []string{"alice", "bob", "charlie"}}, + Creator: s.addr1.String(), + VoteLimit: 2, + Timeout: *endTime, + }, + expErr: true, + }, + "poll expired": { + req: &group.MsgCreatePoll{ + GroupId: myGroupID, + Title: "2021 Election", + Options: group.Options{Titles: []string{"alice", "bob", "charlie"}}, + Creator: s.addr2.String(), + VoteLimit: 2, + Timeout: *oldTime, + }, + expErr: true, + }, + } + for msg, spec := range specs { + spec := spec + s.Run(msg, func() { + res, err := s.msgClient.CreatePoll(s.ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + id := res.PollId + + // then all data persisted + pollRes, err := s.queryClient.Poll(s.ctx, &group.QueryPollRequest{PollId: id}) + s.Require().NoError(err) + poll := pollRes.Poll + + s.Assert().Equal(spec.req.GroupId, poll.GroupId) + s.Assert().Equal(spec.req.Title, poll.Title) + s.Assert().Equal(spec.req.Options, poll.Options) + s.Assert().Equal(spec.req.Creator, poll.Creator) + s.Assert().Equal(spec.req.VoteLimit, poll.VoteLimit) + s.Assert().Equal(spec.req.Metadata, poll.Metadata) + s.Assert().Equal(spec.req.Timeout, poll.Timeout) + + submittedAt, err := gogotypes.TimestampFromProto(&poll.SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + + s.Assert().Equal(uint64(1), poll.GroupVersion) + s.Assert().Equal(spec.expPoll.Status, poll.Status) + }) + } +} + +func (s *IntegrationTestSuite) TestVotePoll() { + members := []group.Member{ + {Address: s.addr4.String(), Weight: "1"}, + {Address: s.addr3.String(), Weight: "2"}, + } + groupRes, err := s.msgClient.CreateGroup(s.ctx, &group.MsgCreateGroup{ + Admin: s.addr1.String(), + Members: members, + Metadata: nil, + }) + s.Require().NoError(err) + myGroupID := groupRes.GroupId + + now := s.blockTime + endTime, err := gogotypes.TimestampProto(now.Add(time.Second * 100)) + req := &group.MsgCreatePoll{ + GroupId: myGroupID, + Title: "2021 Election", + Options: group.Options{Titles: []string{"alice", "bob", "charlie", "linda", "tom"}}, + Creator: s.addr3.String(), + VoteLimit: 2, + Timeout: *endTime, + } + + pollRes, err := s.msgClient.CreatePoll(s.ctx, req) + s.Require().NoError(err) + myPollID := pollRes.PollId + + _, err = s.queryClient.Poll(s.ctx, &group.QueryPollRequest{PollId: myPollID}) + s.Require().NoError(err) + + specs := map[string]struct { + srcCtx sdk.Context + expVoteState group.TallyPoll + req *group.MsgVotePoll + doBefore func(ctx context.Context) + expPollStatus group.Poll_Status + expErr bool + }{ + "all good": { + req: &group.MsgVotePoll{ + PollId: myPollID, + Voter: s.addr4.String(), + Options: group.Options{Titles: []string{"alice", "bob"}}, + }, + expVoteState: group.TallyPoll{ + Counts: map[string]string{ + "alice": "1", + "bob": "1", + }, + }, + expPollStatus: group.PollStatusSubmitted, + }, + "invalid option": { + req: &group.MsgVotePoll{ + PollId: myPollID, + Voter: s.addr4.String(), + Options: group.Options{Titles: []string{"eva"}}, + }, + expErr: true, + }, + "on vote limit": { + req: &group.MsgVotePoll{ + PollId: myPollID, + Voter: s.addr4.String(), + Options: group.Options{Titles: []string{"alice", "bob", "charlie"}}, + }, + expErr: true, + }, + "voter must be in group": { + req: &group.MsgVotePoll{ + PollId: myPollID, + Voter: s.addr2.String(), + Options: group.Options{Titles: []string{"alice"}}, + }, + expErr: true, + }, + "voter must not be empty": { + req: &group.MsgVotePoll{ + PollId: myPollID, + Voter: "", + Options: group.Options{Titles: []string{"alice"}}, + }, + expErr: true, + }, + "voters must not be nil": { + req: &group.MsgVotePoll{ + PollId: myPollID, + Options: group.Options{Titles: []string{"alice"}}, + }, + expErr: true, + }, + "admin that is not a group member can not vote": { + req: &group.MsgVotePoll{ + PollId: myPollID, + Voter: s.addr1.String(), + Options: group.Options{Titles: []string{"alice"}}, + }, + expErr: true, + }, + "on timeout": { + req: &group.MsgVotePoll{ + PollId: myPollID, + Voter: s.addr4.String(), + Options: group.Options{Titles: []string{"alice"}}, + }, + srcCtx: s.sdkCtx.WithBlockTime(s.blockTime.Add(time.Second * 101)), + expErr: true, + }, + "multiple votes": { + req: &group.MsgVotePoll{ + PollId: myPollID, + Voter: s.addr3.String(), + Options: group.Options{Titles: []string{"alice", "bob"}}, + }, + doBefore: func(ctx context.Context) { + _, err := s.msgClient.VotePoll(ctx, &group.MsgVotePoll{ + PollId: myPollID, + Voter: s.addr4.String(), + Options: group.Options{Titles: []string{"bob"}}, + }) + s.Require().NoError(err) + }, + expVoteState: group.TallyPoll{ + Counts: map[string]string{ + "alice": "2", + "bob": "3", + }, + }, + expPollStatus: group.PollStatusSubmitted, + }, + "voted already": { + req: &group.MsgVotePoll{ + PollId: myPollID, + Voter: s.addr4.String(), + Options: group.Options{Titles: []string{"alice"}}, + }, + doBefore: func(ctx context.Context) { + _, err := s.msgClient.VotePoll(ctx, &group.MsgVotePoll{ + PollId: myPollID, + Voter: s.addr4.String(), + Options: group.Options{Titles: []string{"bob"}}, + }) + s.Require().NoError(err) + }, + expErr: true, + }, + "with group modified": { + req: &group.MsgVotePoll{ + PollId: myPollID, + Voter: s.addr4.String(), + Options: group.Options{Titles: []string{"alice"}}, + }, + doBefore: func(ctx context.Context) { + _, err = s.msgClient.UpdateGroupMetadata(ctx, &group.MsgUpdateGroupMetadata{ + GroupId: myGroupID, + Admin: s.addr1.String(), + Metadata: []byte{1, 2, 3}, + }) + s.Require().NoError(err) + }, + expErr: true, + }, + } + for msg, spec := range specs { + spec := spec + s.Run(msg, func() { + sdkCtx := s.sdkCtx + if !spec.srcCtx.IsZero() { + sdkCtx = spec.srcCtx + } + sdkCtx, _ = sdkCtx.CacheContext() + ctx := types.Context{Context: sdkCtx} + + if spec.doBefore != nil { + spec.doBefore(ctx) + } + _, err := s.msgClient.VotePoll(ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + + // vote is stored and all data persisted + res, err := s.queryClient.VoteForPollByPollVoter(ctx, &group.QueryVoteForPollByPollVoterRequest{ + PollId: spec.req.PollId, + Voter: spec.req.Voter, + }) + s.Require().NoError(err) + loaded := res.Vote + s.Assert().Equal(spec.req.PollId, loaded.PollId) + s.Assert().Equal(spec.req.Voter, loaded.Voter) + s.Assert().Equal(spec.req.Options, loaded.Options) + s.Assert().Equal(spec.req.Metadata, loaded.Metadata) + submittedAt, err := gogotypes.TimestampFromProto(&loaded.SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + + // query votes by proposal + votesForPollByPollRes, err := s.queryClient.VotesForPollByPoll(ctx, &group.QueryVotesForPollByPollRequest{ + PollId: spec.req.PollId, + }) + s.Require().NoError(err) + votesByPoll := votesForPollByPollRes.Votes + //s.Require().Equal(1, len(votesByPoll)) + foundVoter := false + for _, vote := range votesByPoll { + if vote.Voter == spec.req.Voter { + foundVoter = true + s.Assert().Equal(spec.req.PollId, vote.PollId) + s.Assert().Equal(spec.req.Voter, vote.Voter) + s.Assert().Equal(spec.req.Options, vote.Options) + s.Assert().Equal(spec.req.Metadata, vote.Metadata) + submittedAt, err = gogotypes.TimestampFromProto(&vote.SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + } + } + s.Require().True(foundVoter) + + // query votes by voter + voter := spec.req.Voter + votesByVoterRes, err := s.queryClient.VotesForPollByVoter(ctx, &group.QueryVotesForPollByVoterRequest{ + Voter: voter, + }) + s.Require().NoError(err) + votesByVoter := votesByVoterRes.Votes + s.Require().Equal(1, len(votesByVoter)) + s.Assert().Equal(spec.req.PollId, votesByVoter[0].PollId) + s.Assert().Equal(voter, votesByVoter[0].Voter) + s.Assert().Equal(spec.req.Options, votesByVoter[0].Options) + s.Assert().Equal(spec.req.Metadata, votesByVoter[0].Metadata) + submittedAt, err = gogotypes.TimestampFromProto(&votesByVoter[0].SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + + // and poll is updated + pollRes, err := s.queryClient.Poll(ctx, &group.QueryPollRequest{ + PollId: spec.req.PollId, + }) + s.Require().NoError(err) + poll := pollRes.Poll + s.Assert().Equal(spec.expVoteState, poll.VoteState) + }) + } +} + +func (s *IntegrationTestSuite) TestVotePollAgg() { + members := []group.Member{ + {Address: s.addrBls1.String(), Weight: "1"}, + {Address: s.addrBls2.String(), Weight: "2"}, + {Address: s.addrBls3.String(), Weight: "3"}, + {Address: s.addrBls4.String(), Weight: "4"}, + {Address: s.addrBls5.String(), Weight: "5"}, + } + + groupRes, err := s.msgClient.CreateGroup(s.ctx, &group.MsgCreateGroup{ + Admin: s.addrBls6.String(), + Members: members, + Metadata: nil, + BlsOnly: true, + }) + s.Require().NoError(err) + myGroupID := groupRes.GroupId + + now := s.blockTime + endTime, err := gogotypes.TimestampProto(now.Add(time.Second * 20)) + req := &group.MsgCreatePoll{ + GroupId: myGroupID, + Title: "2021 Election", + Options: group.Options{Titles: []string{"alice", "bob", "charlie", "linda", "tom"}}, + Creator: s.addrBls5.String(), + VoteLimit: 2, + Timeout: *endTime, + } + + pollRes, err := s.msgClient.CreatePoll(s.ctx, req) + s.Require().NoError(err) + myPollID := pollRes.PollId + + pollQuery, err := s.queryClient.Poll(s.ctx, &group.QueryPollRequest{PollId: myPollID}) + s.Require().NoError(err) + submittedAt, err := gogotypes.TimestampFromProto(&pollQuery.Poll.SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + + s.Assert().Equal(uint64(1), pollQuery.Poll.GroupVersion) + s.Assert().Equal(group.PollStatusSubmitted, pollQuery.Poll.Status) + + type fullVote struct { + Address string + Options group.Options + } + + // valid votes + rawVotes := []fullVote{ + {Address: s.addrBls1.String(), Options: group.Options{Titles: []string{"alice", "bob"}}}, + {Address: s.addrBls2.String()}, + {Address: s.addrBls3.String(), Options: group.Options{Titles: []string{"alice"}}}, + {Address: s.addrBls4.String()}, + {Address: s.addrBls5.String()}, + } + sort.Slice(rawVotes, func(i, j int) bool { return rawVotes[i].Address < rawVotes[j].Address }) + sortedVotes := make([]group.Options, len(rawVotes)) + validVotes := make([]fullVote, 0, len(rawVotes)) + for i, v := range rawVotes { + sortedVotes[i] = v.Options + if len(v.Options.Titles) != 0 { + validVotes = append(validVotes, v) + } + } + + voteExpiry, err := gogotypes.TimestampProto(submittedAt.Add(time.Second * 10)) + s.Require().NoError(err) + + msgs := make(map[string][]byte, len(req.Options.Titles)) + for _, opt := range req.Options.Titles { + x := group.MsgVotePollBasic{ + PollId: myPollID, + Option: opt, + Expiry: *voteExpiry, + } + msgs[opt] = x.GetSignBytes() + } + + sig11, err := s.skBls1.Sign(msgs["alice"]) + s.Require().NoError(err) + sig12, err := s.skBls1.Sign(msgs["bob"]) + s.Require().NoError(err) + sig1, err := bls12381.AggregateSignature([][]byte{sig11, sig12}) + s.Require().NoError(err) + + sig3, err := s.skBls3.Sign(msgs["alice"]) + s.Require().NoError(err) + + sigma, err := bls12381.AggregateSignature([][]byte{sig1, sig3}) + s.Require().NoError(err) + + // vote too late + rawVotesLate := []fullVote{ + {Address: s.addrBls1.String(), Options: group.Options{Titles: []string{"alice", "bob"}}}, + {Address: s.addrBls2.String()}, + {Address: s.addrBls3.String(), Options: group.Options{Titles: []string{"alice"}}}, + {Address: s.addrBls4.String()}, + {Address: s.addrBls5.String()}, + } + sort.Slice(rawVotesLate, func(i, j int) bool { return rawVotesLate[i].Address < rawVotesLate[j].Address }) + sortedVotesLate := make([]group.Options, len(rawVotesLate)) + for i, v := range rawVotesLate { + sortedVotesLate[i] = v.Options + } + + voteExpiryLate, err := gogotypes.TimestampProto(submittedAt.Add(time.Second * 30)) + s.Require().NoError(err) + + msgsLate := make(map[string][]byte, len(req.Options.Titles)) + for _, opt := range req.Options.Titles { + x := group.MsgVotePollBasic{ + PollId: myPollID, + Option: opt, + Expiry: *voteExpiryLate, + } + msgsLate[opt] = x.GetSignBytes() + } + + sigLate11, err := s.skBls1.Sign(msgsLate["alice"]) + s.Require().NoError(err) + sigLate12, err := s.skBls1.Sign(msgsLate["bob"]) + s.Require().NoError(err) + sigLate1, err := bls12381.AggregateSignature([][]byte{sigLate11, sigLate12}) + s.Require().NoError(err) + + sigLate3, err := s.skBls3.Sign(msgsLate["alice"]) + s.Require().NoError(err) + + sigmaLate, err := bls12381.AggregateSignature([][]byte{sigLate1, sigLate3}) + s.Require().NoError(err) + + // vote limit + rawVotesLong := []fullVote{ + {Address: s.addrBls1.String(), Options: group.Options{Titles: []string{"alice", "bob", "linda"}}}, + {Address: s.addrBls2.String()}, + {Address: s.addrBls3.String(), Options: group.Options{Titles: []string{"alice"}}}, + {Address: s.addrBls4.String()}, + {Address: s.addrBls5.String()}, + } + sort.Slice(rawVotesLong, func(i, j int) bool { return rawVotesLong[i].Address < rawVotesLong[j].Address }) + sortedVotesLong := make([]group.Options, len(rawVotesLong)) + for i, v := range rawVotesLong { + sortedVotesLong[i] = v.Options + } + + msgsLong := make(map[string][]byte, len(req.Options.Titles)) + for _, opt := range req.Options.Titles { + x := group.MsgVotePollBasic{ + PollId: myPollID, + Option: opt, + Expiry: *voteExpiry, + } + msgsLong[opt] = x.GetSignBytes() + } + + sigLong11, err := s.skBls1.Sign(msgsLong["alice"]) + s.Require().NoError(err) + sigLong12, err := s.skBls1.Sign(msgsLong["bob"]) + s.Require().NoError(err) + sigLong13, err := s.skBls1.Sign(msgsLong["linda"]) + s.Require().NoError(err) + sigLong1, err := bls12381.AggregateSignature([][]byte{sigLong11, sigLong12, sigLong13}) + s.Require().NoError(err) + + sigLong3, err := s.skBls3.Sign(msgsLong["alice"]) + s.Require().NoError(err) + + sigmaLong, err := bls12381.AggregateSignature([][]byte{sigLong1, sigLong3}) + s.Require().NoError(err) + + // vote invalid option + rawVotesInvalid := []fullVote{ + {Address: s.addrBls1.String(), Options: group.Options{Titles: []string{"alice", "eva"}}}, + {Address: s.addrBls2.String()}, + {Address: s.addrBls3.String(), Options: group.Options{Titles: []string{"alice"}}}, + {Address: s.addrBls4.String()}, + {Address: s.addrBls5.String()}, + } + sort.Slice(rawVotesInvalid, func(i, j int) bool { return rawVotesInvalid[i].Address < rawVotesInvalid[j].Address }) + sortedVotesInvalid := make([]group.Options, len(rawVotesInvalid)) + for i, v := range rawVotesInvalid { + sortedVotesInvalid[i] = v.Options + } + + msgsInvalid := make(map[string][]byte, len(req.Options.Titles)) + for _, opt := range req.Options.Titles { + x := group.MsgVotePollBasic{ + PollId: myPollID, + Option: opt, + Expiry: *voteExpiry, + } + msgsInvalid[opt] = x.GetSignBytes() + } + + y := group.MsgVotePollBasic{ + PollId: myPollID, + Option: "eva", + Expiry: *voteExpiry, + } + msgsInvalid["eva"] = y.GetSignBytes() + + sigInvalid11, err := s.skBls1.Sign(msgsInvalid["alice"]) + s.Require().NoError(err) + sigInvalid12, err := s.skBls1.Sign(msgsInvalid["eva"]) + s.Require().NoError(err) + sigInvalid1, err := bls12381.AggregateSignature([][]byte{sigInvalid11, sigInvalid12}) + s.Require().NoError(err) + + sigInvalid3, err := s.skBls3.Sign(msgsInvalid["alice"]) + s.Require().NoError(err) + + sigmaInvalid, err := bls12381.AggregateSignature([][]byte{sigInvalid1, sigInvalid3}) + s.Require().NoError(err) + + // skip already voted + validVotesSkip := []fullVote{ + {Address: s.addrBls1.String(), Options: group.Options{Titles: []string{"charlie"}}}, + {Address: s.addrBls3.String(), Options: group.Options{Titles: []string{"alice"}}}, + } + sort.Slice(validVotesSkip, func(i, j int) bool { return validVotesSkip[i].Address < validVotesSkip[j].Address }) + + specs := map[string]struct { + srcCtx sdk.Context + expVoteState group.TallyPoll + req *group.MsgVotePollAgg + votes []fullVote + doBefore func(ctx context.Context) + expPollStatus group.Poll_Status + expErr bool + }{ + "all good": { + req: &group.MsgVotePollAgg{ + Sender: s.addr1.String(), + PollId: myPollID, + Votes: sortedVotes, + Expiry: *voteExpiry, + AggSig: sigma, + Metadata: []byte(fmt.Sprintf("aggregated votes submitted by %s", s.addr1.String())), + }, + votes: validVotes, + expVoteState: group.TallyPoll{ + Counts: map[string]string{ + "alice": "4", + "bob": "1", + }, + }, + expPollStatus: group.PollStatusSubmitted, + }, + "skip already voted": { + req: &group.MsgVotePollAgg{ + Sender: s.addr1.String(), + PollId: myPollID, + Votes: sortedVotes, + Expiry: *voteExpiry, + AggSig: sigma, + Metadata: []byte(fmt.Sprintf("aggregated votes submitted by %s", s.addr1.String())), + }, + votes: validVotesSkip, + doBefore: func(ctx context.Context) { + _, err := s.msgClient.VotePoll(ctx, &group.MsgVotePoll{ + PollId: myPollID, + Voter: s.addrBls1.String(), + Options: group.Options{Titles: []string{"charlie"}}, + }) + s.Require().NoError(err) + }, + expVoteState: group.TallyPoll{ + Counts: map[string]string{ + "alice": "3", + "bob": "0", + "charlie": "1", + }, + }, + expPollStatus: group.PollStatusSubmitted, + }, + "on vote expiry": { + req: &group.MsgVotePollAgg{ + Sender: s.addr1.String(), + PollId: myPollID, + Votes: sortedVotes, + Expiry: *voteExpiry, + AggSig: sigma, + Metadata: []byte(fmt.Sprintf("aggregated votes submitted by %s", s.addr1.String())), + }, + srcCtx: s.sdkCtx.WithBlockTime(s.blockTime.Add(time.Second * 15)), + expErr: true, + }, + "on vote late": { + req: &group.MsgVotePollAgg{ + Sender: s.addr1.String(), + PollId: myPollID, + Votes: sortedVotesLate, + Expiry: *voteExpiryLate, + AggSig: sigmaLate, + Metadata: []byte(fmt.Sprintf("aggregated votes submitted by %s", s.addr1.String())), + }, + srcCtx: s.sdkCtx.WithBlockTime(s.blockTime.Add(time.Second * 35)), + expErr: true, + }, + "on vote limit": { + req: &group.MsgVotePollAgg{ + Sender: s.addr1.String(), + PollId: myPollID, + Votes: sortedVotesLong, + Expiry: *voteExpiry, + AggSig: sigmaLong, + Metadata: []byte(fmt.Sprintf("aggregated votes submitted by %s", s.addr1.String())), + }, + expErr: true, + }, + "on vote option": { + req: &group.MsgVotePollAgg{ + Sender: s.addr1.String(), + PollId: myPollID, + Votes: sortedVotesInvalid, + Expiry: *voteExpiry, + AggSig: sigmaInvalid, + Metadata: []byte(fmt.Sprintf("aggregated votes submitted by %s", s.addr1.String())), + }, + expErr: true, + }, + "on poll expiry": { + req: &group.MsgVotePollAgg{ + Sender: s.addr1.String(), + PollId: myPollID, + Votes: sortedVotesLate, + Expiry: *voteExpiryLate, + AggSig: sigmaLate, + Metadata: []byte(fmt.Sprintf("aggregated votes submitted by %s", s.addr1.String())), + }, + srcCtx: s.sdkCtx.WithBlockTime(s.blockTime.Add(time.Second * 25)), + expErr: true, + }, + } + + for msg, spec := range specs { + spec := spec + s.Run(msg, func() { + sdkCtx := s.sdkCtx + if !spec.srcCtx.IsZero() { + sdkCtx = spec.srcCtx + } + sdkCtx, _ = sdkCtx.CacheContext() + ctx := types.Context{Context: sdkCtx} + + if spec.doBefore != nil { + spec.doBefore(ctx) + } + _, err := s.msgClient.VotePollAgg(ctx, spec.req) + if spec.expErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + + // query votes by poll + votesByPollRes, err := s.queryClient.VotesForPollByPoll(ctx, &group.QueryVotesForPollByPollRequest{ + PollId: myPollID, + }) + s.Require().NoError(err) + votesByPoll := votesByPollRes.Votes + s.Require().Equal(len(spec.votes), len(votesByPoll)) + + for i, vote := range votesByPoll { + s.Assert().Equal(spec.req.PollId, vote.PollId) + s.Assert().Equal(spec.votes[i].Address, vote.Voter) + s.Assert().Equal(spec.votes[i].Options.Titles, vote.Options.Titles) + submittedAt, err = gogotypes.TimestampFromProto(&vote.SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + } + + // query votes by voter + for _, vote := range spec.votes { + votesByVoterRes, err := s.queryClient.VotesForPollByVoter(ctx, &group.QueryVotesForPollByVoterRequest{ + Voter: vote.Address, + }) + s.Require().NoError(err) + votesByVoter := votesByVoterRes.Votes + s.Require().Equal(1, len(votesByVoter)) + s.Assert().Equal(spec.req.PollId, votesByVoter[0].PollId) + s.Assert().Equal(vote.Address, votesByVoter[0].Voter) + s.Assert().Equal(vote.Options.Titles, votesByVoter[0].Options.Titles) + submittedAt, err = gogotypes.TimestampFromProto(&votesByVoter[0].SubmittedAt) + s.Require().NoError(err) + s.Assert().Equal(s.blockTime, submittedAt) + } + + // and poll is updated + pollRes, err := s.queryClient.Poll(ctx, &group.QueryPollRequest{ + PollId: spec.req.PollId, + }) + s.Require().NoError(err) + poll := pollRes.Poll + s.Assert().Equal(spec.expVoteState, poll.VoteState) + s.Assert().Equal(spec.expPollStatus, poll.Status) + }) + } +} + func createProposal( ctx context.Context, s *IntegrationTestSuite, msgs []sdk.Msg, proposers []string) uint64 { diff --git a/x/group/server/sigverify.go b/x/group/sigverify.go similarity index 60% rename from x/group/server/sigverify.go rename to x/group/sigverify.go index 0c6d16f2d2..2efcbcc211 100644 --- a/x/group/server/sigverify.go +++ b/x/group/sigverify.go @@ -1,18 +1,18 @@ -package server +package group import ( - "fmt" "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -func VerifyAggSignature(msgs [][]byte, msgCheck bool, sig []byte, pkss [][]cryptotypes.PubKey) error { +func VerifyAggregateSignature(msgs [][]byte, msgCheck bool, sig []byte, pkss [][]cryptotypes.PubKey) error { pkssBls := make([][]*bls12381.PubKey, len(pkss)) for i, pks := range pkss { for _, pk := range pks { pkBls, ok := pk.(*bls12381.PubKey) if !ok { - return fmt.Errorf("only support bls public key") + return sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, "only support bls public key") } pkssBls[i] = append(pkssBls[i], pkBls) } diff --git a/x/group/tx.pb.go b/x/group/tx.pb.go index 8cccaa59af..47a1f58f50 100644 --- a/x/group/tx.pb.go +++ b/x/group/tx.pb.go @@ -1085,8 +1085,8 @@ type MsgVoteBasic struct { ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` // choice is the voter's choice on the proposal. Choice Choice `protobuf:"varint,2,opt,name=choice,proto3,enum=regen.group.v1alpha1.Choice" json:"choice,omitempty"` - // timeout is the unique timestamp before which all the basic votes need to aggregated and submitted. - Timeout types1.Timestamp `protobuf:"bytes,3,opt,name=timeout,proto3" json:"timeout"` + // expiry is the timestamp after which the basic vote expires. + Expiry types1.Timestamp `protobuf:"bytes,3,opt,name=expiry,proto3" json:"expiry"` } func (m *MsgVoteBasic) Reset() { *m = MsgVoteBasic{} } @@ -1136,9 +1136,9 @@ func (m *MsgVoteBasic) GetChoice() Choice { return Choice_CHOICE_UNSPECIFIED } -func (m *MsgVoteBasic) GetTimeout() types1.Timestamp { +func (m *MsgVoteBasic) GetExpiry() types1.Timestamp { if m != nil { - return m.Timeout + return m.Expiry } return types1.Timestamp{} } @@ -1149,8 +1149,8 @@ type MsgVoteBasicResponse struct { ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` // choice is the voter's choice on the proposal. Choice Choice `protobuf:"varint,2,opt,name=choice,proto3,enum=regen.group.v1alpha1.Choice" json:"choice,omitempty"` - // timeout is the unique timestamp before which the aggregated vote needs to submitted. - Timeout types1.Timestamp `protobuf:"bytes,3,opt,name=timeout,proto3" json:"timeout"` + // expiry is the timestamp after which the basic vote expires. + Expiry types1.Timestamp `protobuf:"bytes,3,opt,name=expiry,proto3" json:"expiry"` // voter is the account address of the voter. Voter string `protobuf:"bytes,4,opt,name=voter,proto3" json:"voter,omitempty"` // pub_key is the voter's public key @@ -1206,9 +1206,9 @@ func (m *MsgVoteBasicResponse) GetChoice() Choice { return Choice_CHOICE_UNSPECIFIED } -func (m *MsgVoteBasicResponse) GetTimeout() types1.Timestamp { +func (m *MsgVoteBasicResponse) GetExpiry() types1.Timestamp { if m != nil { - return m.Timeout + return m.Expiry } return types1.Timestamp{} } @@ -1234,7 +1234,7 @@ func (m *MsgVoteBasicResponse) GetSig() []byte { return nil } -// MsgVoteRequest is the Msg/Vote request type. +// MsgVoteAgg is the Msg/VoteAgg request type. type MsgVoteAgg struct { // sender is the person who submits the votes Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` @@ -1242,8 +1242,12 @@ type MsgVoteAgg struct { ProposalId uint64 `protobuf:"varint,2,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` // votes are the list of voters' choices on the proposal. Votes []Choice `protobuf:"varint,3,rep,packed,name=votes,proto3,enum=regen.group.v1alpha1.Choice" json:"votes,omitempty"` - // timeout is the unique timestamp before which all the basic votes need to aggregated and submitted. - Timeout types1.Timestamp `protobuf:"bytes,4,opt,name=timeout,proto3" json:"timeout"` + // expiry is the timestamp after which the basic vote expires. + // All the basic votes to be aggregated must have the same expiry. + // Expiry should be set to be before the proposal timeout in order to + // prevent replay attacks and also prevent the aggregator from removing + // some basic votes. + Expiry types1.Timestamp `protobuf:"bytes,4,opt,name=expiry,proto3" json:"expiry"` // agg_sig is the bls aggregated signature for all the votes AggSig []byte `protobuf:"bytes,5,opt,name=agg_sig,json=aggSig,proto3" json:"agg_sig,omitempty"` // metadata is any arbitrary metadata to attached to the vote. @@ -1307,9 +1311,9 @@ func (m *MsgVoteAgg) GetVotes() []Choice { return nil } -func (m *MsgVoteAgg) GetTimeout() types1.Timestamp { +func (m *MsgVoteAgg) GetExpiry() types1.Timestamp { if m != nil { - return m.Timeout + return m.Expiry } return types1.Timestamp{} } @@ -1464,910 +1468,1249 @@ func (m *MsgExecResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgExecResponse proto.InternalMessageInfo -func init() { - proto.RegisterEnum("regen.group.v1alpha1.Exec", Exec_name, Exec_value) - proto.RegisterType((*MsgCreateGroup)(nil), "regen.group.v1alpha1.MsgCreateGroup") - proto.RegisterType((*MsgCreateGroupResponse)(nil), "regen.group.v1alpha1.MsgCreateGroupResponse") - proto.RegisterType((*MsgUpdateGroupMembers)(nil), "regen.group.v1alpha1.MsgUpdateGroupMembers") - proto.RegisterType((*MsgUpdateGroupMembersResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupMembersResponse") - proto.RegisterType((*MsgUpdateGroupAdmin)(nil), "regen.group.v1alpha1.MsgUpdateGroupAdmin") - proto.RegisterType((*MsgUpdateGroupAdminResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupAdminResponse") - proto.RegisterType((*MsgUpdateGroupMetadata)(nil), "regen.group.v1alpha1.MsgUpdateGroupMetadata") - proto.RegisterType((*MsgUpdateGroupMetadataResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupMetadataResponse") - proto.RegisterType((*MsgCreateGroupAccount)(nil), "regen.group.v1alpha1.MsgCreateGroupAccount") - proto.RegisterType((*MsgCreateGroupAccountResponse)(nil), "regen.group.v1alpha1.MsgCreateGroupAccountResponse") - proto.RegisterType((*MsgUpdateGroupAccountAdmin)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountAdmin") - proto.RegisterType((*MsgUpdateGroupAccountAdminResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountAdminResponse") - proto.RegisterType((*MsgUpdateGroupAccountDecisionPolicy)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountDecisionPolicy") - proto.RegisterType((*MsgUpdateGroupAccountDecisionPolicyResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountDecisionPolicyResponse") - proto.RegisterType((*MsgUpdateGroupAccountMetadata)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountMetadata") - proto.RegisterType((*MsgUpdateGroupAccountMetadataResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountMetadataResponse") - proto.RegisterType((*MsgCreateProposal)(nil), "regen.group.v1alpha1.MsgCreateProposal") - proto.RegisterType((*MsgCreateProposalResponse)(nil), "regen.group.v1alpha1.MsgCreateProposalResponse") - proto.RegisterType((*MsgVote)(nil), "regen.group.v1alpha1.MsgVote") - proto.RegisterType((*MsgVoteResponse)(nil), "regen.group.v1alpha1.MsgVoteResponse") - proto.RegisterType((*MsgVoteBasic)(nil), "regen.group.v1alpha1.MsgVoteBasic") - proto.RegisterType((*MsgVoteBasicResponse)(nil), "regen.group.v1alpha1.MsgVoteBasicResponse") - proto.RegisterType((*MsgVoteAgg)(nil), "regen.group.v1alpha1.MsgVoteAgg") - proto.RegisterType((*MsgVoteAggResponse)(nil), "regen.group.v1alpha1.MsgVoteAggResponse") - proto.RegisterType((*MsgExec)(nil), "regen.group.v1alpha1.MsgExec") - proto.RegisterType((*MsgExecResponse)(nil), "regen.group.v1alpha1.MsgExecResponse") +// MsgCreateProposal is the Msg/CreateProposal request type. +type MsgCreatePoll struct { + // group_id is the unique ID of the group. + GroupId uint64 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` + Options Options `protobuf:"bytes,3,opt,name=options,proto3" json:"options"` + Creator string `protobuf:"bytes,4,opt,name=creator,proto3" json:"creator,omitempty"` + // vote_limit is the number of options each voter can choose. + VoteLimit int32 `protobuf:"varint,5,opt,name=vote_limit,json=voteLimit,proto3" json:"vote_limit,omitempty"` + // metadata is any arbitrary metadata to attached to the proposal. + Metadata []byte `protobuf:"bytes,6,opt,name=metadata,proto3" json:"metadata,omitempty"` + // timeout is the deadline of the poll. + Timeout types1.Timestamp `protobuf:"bytes,7,opt,name=timeout,proto3" json:"timeout"` } -func init() { proto.RegisterFile("regen/group/v1alpha1/tx.proto", fileDescriptor_b4673626e7797578) } - -var fileDescriptor_b4673626e7797578 = []byte{ - // 1212 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0xda, 0x5b, 0x3b, 0x79, 0x09, 0x6e, 0xba, 0x35, 0xad, 0xbb, 0x6d, 0x6c, 0x6b, 0x49, - 0x55, 0xd3, 0x24, 0x36, 0x49, 0x7a, 0xa0, 0xa1, 0x42, 0x72, 0xd2, 0x80, 0x22, 0x30, 0x84, 0x6d, - 0x83, 0x00, 0x21, 0x59, 0xeb, 0xdd, 0x61, 0xb2, 0xc4, 0xbb, 0xb3, 0xf2, 0xac, 0xd3, 0xf8, 0x03, - 0x20, 0x71, 0x42, 0x48, 0xdc, 0xe0, 0x52, 0xbe, 0x00, 0x5c, 0xb8, 0x72, 0xe1, 0x42, 0xc5, 0xa9, - 0x47, 0x4e, 0x51, 0x95, 0xdc, 0x38, 0xf2, 0x09, 0xd0, 0xce, 0xce, 0xae, 0xff, 0xad, 0xd7, 0x76, - 0x55, 0x71, 0x4a, 0xde, 0xcc, 0xef, 0xbd, 0xf7, 0x7b, 0xff, 0x66, 0x9f, 0x0c, 0xcb, 0x6d, 0x84, - 0x91, 0x5d, 0xc5, 0x6d, 0xd2, 0x71, 0xaa, 0x27, 0x1b, 0x5a, 0xcb, 0x39, 0xd2, 0x36, 0xaa, 0xee, - 0x69, 0xc5, 0x69, 0x13, 0x97, 0x48, 0x39, 0x76, 0x5d, 0x61, 0xd7, 0x95, 0xe0, 0x5a, 0xce, 0x61, - 0x82, 0x09, 0x03, 0x54, 0xbd, 0xff, 0x7c, 0xac, 0xbc, 0xa8, 0x13, 0x6a, 0x11, 0xca, 0xa5, 0x1b, - 0x98, 0x10, 0xdc, 0x42, 0x55, 0x26, 0x35, 0x3b, 0x5f, 0x55, 0x35, 0xbb, 0xcb, 0xaf, 0x8a, 0xc3, - 0x57, 0xae, 0x69, 0x21, 0xea, 0x6a, 0x96, 0xc3, 0x01, 0xa5, 0x68, 0x52, 0x5d, 0x07, 0x71, 0xeb, - 0xca, 0x4f, 0x02, 0x64, 0xeb, 0x14, 0xef, 0xb6, 0x91, 0xe6, 0xa2, 0xf7, 0x3d, 0x9c, 0x94, 0x83, - 0x4b, 0x9a, 0x61, 0x99, 0x76, 0x5e, 0x28, 0x09, 0xe5, 0x79, 0xd5, 0x17, 0xa4, 0x07, 0x90, 0xb1, - 0x90, 0xd5, 0x44, 0x6d, 0x9a, 0x4f, 0x96, 0x52, 0xe5, 0x85, 0xcd, 0x5b, 0x95, 0xa8, 0x90, 0x2a, - 0x75, 0x06, 0xda, 0x11, 0x9f, 0x9d, 0x15, 0x13, 0x6a, 0xa0, 0x22, 0xc9, 0x30, 0x67, 0x21, 0x57, - 0x33, 0x34, 0x57, 0xcb, 0xa7, 0x4a, 0x42, 0x79, 0x51, 0x0d, 0x65, 0xe9, 0x06, 0xcc, 0x35, 0x5b, - 0xb4, 0x41, 0xec, 0x56, 0x37, 0x2f, 0x96, 0x84, 0xf2, 0x9c, 0x9a, 0x69, 0xb6, 0xe8, 0xc7, 0x76, - 0xab, 0xab, 0x6c, 0xc1, 0xb5, 0x41, 0x72, 0x2a, 0xa2, 0x0e, 0xb1, 0x29, 0xf2, 0x94, 0x98, 0xe3, - 0x86, 0x69, 0x30, 0x9e, 0xa2, 0x9a, 0x61, 0xf2, 0xbe, 0xa1, 0xfc, 0x20, 0xc0, 0xeb, 0x75, 0x8a, - 0x0f, 0x1d, 0x23, 0xd0, 0xaa, 0x73, 0x16, 0xd1, 0x91, 0xf5, 0x9b, 0x4a, 0x0e, 0x98, 0x92, 0xf6, - 0x21, 0xeb, 0x47, 0xd0, 0xe8, 0x30, 0x6b, 0x34, 0x9f, 0x9a, 0x3a, 0xf6, 0xd7, 0x7c, 0x4d, 0x9f, - 0x06, 0x55, 0x8a, 0xb0, 0x1c, 0x49, 0x2a, 0x88, 0x48, 0xd1, 0xe1, 0xea, 0x20, 0xa0, 0xc6, 0xd8, - 0xcd, 0xcc, 0xf9, 0x26, 0xcc, 0xdb, 0xe8, 0x49, 0xc3, 0x57, 0x4a, 0x31, 0xa5, 0x39, 0x1b, 0x3d, - 0x61, 0xd6, 0x94, 0x65, 0xb8, 0x19, 0xe1, 0x24, 0xe4, 0x80, 0x58, 0xbe, 0x07, 0x48, 0xf2, 0x22, - 0xcd, 0x4c, 0x23, 0xa6, 0xe2, 0x4a, 0x09, 0x0a, 0xd1, 0x6e, 0x42, 0x22, 0xbf, 0xfb, 0x35, 0xec, - 0xab, 0x7c, 0x4d, 0xd7, 0x49, 0xc7, 0x76, 0x5f, 0x29, 0x11, 0xe9, 0x13, 0xb8, 0x6c, 0x20, 0xdd, - 0xa4, 0x26, 0xb1, 0x1b, 0x0e, 0x69, 0x99, 0xba, 0xdf, 0x81, 0x0b, 0x9b, 0xb9, 0x8a, 0x3f, 0x5a, - 0x95, 0x60, 0xb4, 0x2a, 0x35, 0xbb, 0xbb, 0x23, 0xfd, 0xf5, 0xdb, 0x7a, 0xf6, 0x21, 0x57, 0x38, - 0x60, 0x78, 0x35, 0x6b, 0x0c, 0xc8, 0xdb, 0xe2, 0xb7, 0x4f, 0x8b, 0x09, 0xe5, 0x3e, 0xab, 0xf6, - 0x28, 0xfd, 0xb0, 0x7f, 0xf3, 0x90, 0xd1, 0x0c, 0xa3, 0x8d, 0x28, 0xe5, 0x81, 0x04, 0xa2, 0x62, - 0x82, 0x3c, 0x54, 0x22, 0x5f, 0x35, 0xae, 0x1d, 0xfa, 0xac, 0x25, 0x07, 0xac, 0xc5, 0x77, 0xc3, - 0x0a, 0x28, 0xe3, 0x5d, 0x85, 0xb5, 0xf8, 0x45, 0x80, 0x37, 0x22, 0x61, 0x83, 0x99, 0x98, 0x99, - 0x5a, 0x44, 0xf2, 0x53, 0xaf, 0x24, 0xf9, 0xeb, 0xb0, 0x3a, 0x05, 0xdf, 0x30, 0xbe, 0xe3, 0xe1, - 0xc9, 0xe4, 0xf0, 0x09, 0xbd, 0x3f, 0x3e, 0xb0, 0xb8, 0xd6, 0xbf, 0x03, 0xb7, 0x63, 0x9d, 0x85, - 0xac, 0xfe, 0x14, 0xe0, 0x4a, 0xd8, 0x42, 0x07, 0x6d, 0xe2, 0x10, 0xaa, 0xb5, 0xc6, 0xb7, 0x8d, - 0x74, 0x0b, 0xe6, 0x1d, 0x86, 0x0a, 0x5e, 0xe8, 0x79, 0xb5, 0x77, 0x10, 0x3b, 0x04, 0x65, 0x10, - 0x2d, 0x8a, 0x69, 0x5e, 0x64, 0x4f, 0x5b, 0x64, 0xf2, 0x55, 0x86, 0x90, 0x2a, 0x20, 0xa2, 0x53, - 0xa4, 0xe7, 0x2f, 0x95, 0x84, 0x72, 0x76, 0x53, 0x8e, 0x7e, 0x04, 0xf7, 0x4e, 0x91, 0xae, 0x32, - 0x1c, 0x2f, 0xc7, 0x03, 0xb8, 0x31, 0x12, 0x48, 0x38, 0x07, 0x45, 0x58, 0x70, 0xf8, 0x59, 0xef, - 0x29, 0x87, 0xe0, 0x68, 0xdf, 0x50, 0xfe, 0x10, 0x20, 0x53, 0xa7, 0xf8, 0x53, 0xe2, 0x4e, 0x06, - 0x7b, 0x95, 0x3a, 0x21, 0x2e, 0x6a, 0xf3, 0x8a, 0xf8, 0x82, 0x74, 0x0f, 0xd2, 0xfa, 0x11, 0x31, - 0x75, 0xc4, 0x42, 0xcf, 0x8e, 0x7b, 0xbd, 0x77, 0x19, 0x46, 0xe5, 0xd8, 0x81, 0x94, 0x89, 0x43, - 0x29, 0x9b, 0x31, 0x11, 0xca, 0x15, 0xb8, 0xcc, 0x63, 0x08, 0xeb, 0xfb, 0xb3, 0x00, 0x8b, 0xfc, - 0x6c, 0x47, 0xa3, 0xa6, 0x3e, 0x39, 0xb8, 0x5e, 0x18, 0xc9, 0x19, 0xc2, 0xd8, 0x86, 0x8c, 0xb7, - 0x15, 0x90, 0x8e, 0xcb, 0xa7, 0x4b, 0x1e, 0x29, 0xf0, 0xe3, 0x60, 0x6b, 0x08, 0xbe, 0xda, 0x5c, - 0x41, 0xf9, 0x35, 0x09, 0xb9, 0x7e, 0x8e, 0x53, 0x57, 0xed, 0xff, 0xe7, 0xda, 0x2b, 0xbd, 0xd8, - 0x5f, 0xfa, 0x2f, 0x21, 0xe3, 0x74, 0x9a, 0x8d, 0x63, 0xd4, 0x65, 0xb5, 0x1a, 0xf7, 0xb6, 0xac, - 0xff, 0x73, 0x56, 0xcc, 0x39, 0x9d, 0x66, 0xcb, 0xd4, 0x3d, 0xec, 0x1a, 0xb1, 0x4c, 0x17, 0x59, - 0x8e, 0xdb, 0xfd, 0xf7, 0xac, 0x78, 0xa5, 0xab, 0x59, 0xad, 0x6d, 0xa5, 0x77, 0xab, 0xa8, 0x69, - 0xa7, 0xd3, 0xfc, 0x00, 0x75, 0xa5, 0x25, 0x48, 0x51, 0x13, 0xe7, 0xd3, 0xac, 0x3b, 0xbc, 0x7f, - 0x95, 0x1f, 0x93, 0x00, 0x3c, 0x63, 0x35, 0x8c, 0xa5, 0x6b, 0x90, 0xa6, 0xc8, 0x36, 0x50, 0x9b, - 0x4f, 0x2b, 0x97, 0x86, 0xf3, 0x97, 0x1c, 0xc9, 0xdf, 0xa6, 0x1f, 0x8d, 0xbf, 0x6f, 0x4c, 0x4a, - 0x9f, 0x0f, 0xed, 0xcf, 0x9e, 0x38, 0x6b, 0xf6, 0xae, 0x43, 0x46, 0xc3, 0xb8, 0xe1, 0x45, 0x73, - 0x89, 0x45, 0x93, 0xd6, 0x30, 0x7e, 0x64, 0xe2, 0x81, 0x29, 0x48, 0x8f, 0x99, 0x82, 0xcc, 0x94, - 0x53, 0x90, 0x03, 0xa9, 0x97, 0x9b, 0x70, 0x10, 0x76, 0xd8, 0x7c, 0x7b, 0xb0, 0xc9, 0x6d, 0xe5, - 0xe5, 0xd3, 0xc4, 0x76, 0x38, 0xe0, 0x5c, 0xe2, 0xf3, 0xc5, 0x5c, 0x71, 0xb3, 0x77, 0xef, 0x82, - 0xc8, 0x6c, 0xe6, 0x60, 0x69, 0xef, 0xb3, 0xbd, 0xdd, 0xc6, 0xe1, 0x47, 0x8f, 0x0e, 0xf6, 0x76, - 0xf7, 0xdf, 0xdb, 0xdf, 0x7b, 0xb8, 0x94, 0x90, 0x16, 0x61, 0x8e, 0x9d, 0x3e, 0x56, 0x3f, 0x5f, - 0x12, 0x36, 0x5f, 0x00, 0xa4, 0xea, 0x14, 0x4b, 0x1a, 0x2c, 0xf4, 0x2f, 0xc2, 0x2b, 0x63, 0xb6, - 0xbc, 0x81, 0x0f, 0xbb, 0xbc, 0x36, 0x0d, 0x2a, 0x9c, 0x9c, 0x13, 0x90, 0x22, 0x16, 0xd3, 0xd5, - 0xb1, 0x36, 0x46, 0xc1, 0xf2, 0xd6, 0x0c, 0xe0, 0xd0, 0xaf, 0x03, 0x4b, 0x23, 0xab, 0xe5, 0x9b, - 0xd3, 0x18, 0x62, 0x50, 0x79, 0x63, 0x6a, 0x68, 0xe8, 0xb1, 0x0b, 0x57, 0xa3, 0x16, 0xc9, 0xb5, - 0xe9, 0xd8, 0xfb, 0x68, 0xf9, 0xde, 0x2c, 0xe8, 0xfe, 0x24, 0x47, 0x6c, 0x8e, 0xab, 0xd3, 0x14, - 0x8a, 0x83, 0x63, 0x92, 0x1c, 0xb3, 0xd4, 0x7d, 0x23, 0xc0, 0xf5, 0x71, 0x8b, 0xdb, 0x5b, 0x53, - 0x65, 0xb0, 0x4f, 0x43, 0x7e, 0x7b, 0x56, 0x8d, 0x90, 0xc7, 0x53, 0x01, 0x4a, 0x13, 0xd7, 0xb5, - 0xfb, 0x33, 0x98, 0x1f, 0x54, 0x95, 0x6b, 0x2f, 0xad, 0x1a, 0x52, 0xfc, 0x4e, 0x00, 0x39, 0x66, - 0xe5, 0xda, 0x9a, 0xc1, 0x43, 0xd8, 0x2c, 0xef, 0xbc, 0x84, 0x52, 0x48, 0xe8, 0x6b, 0xc8, 0x0e, - 0xed, 0x5a, 0x77, 0x26, 0xb4, 0x40, 0x00, 0x94, 0xab, 0x53, 0x02, 0x43, 0x5f, 0x1f, 0x82, 0xc8, - 0xf6, 0x99, 0xe5, 0xb1, 0x8a, 0xde, 0xb5, 0x7c, 0x3b, 0xf6, 0x3a, 0xb4, 0x76, 0x08, 0x99, 0xe0, - 0x7b, 0x53, 0x8a, 0xd5, 0xa8, 0x61, 0x2c, 0x97, 0x27, 0x21, 0xfa, 0x49, 0xb2, 0x07, 0x74, 0x3c, - 0x49, 0xef, 0x3a, 0x86, 0x64, 0xff, 0x73, 0xbc, 0xf3, 0xee, 0xb3, 0xf3, 0x82, 0xf0, 0xfc, 0xbc, - 0x20, 0xbc, 0x38, 0x2f, 0x08, 0xdf, 0x5f, 0x14, 0x12, 0xcf, 0x2f, 0x0a, 0x89, 0xbf, 0x2f, 0x0a, - 0x89, 0x2f, 0x56, 0xb0, 0xe9, 0x1e, 0x75, 0x9a, 0x15, 0x9d, 0x58, 0x55, 0xff, 0x87, 0x0f, 0xfe, - 0x67, 0x9d, 0x1a, 0xc7, 0xd5, 0x53, 0xff, 0xc7, 0x8b, 0x66, 0x9a, 0x7d, 0xc3, 0xb6, 0xfe, 0x0b, - 0x00, 0x00, 0xff, 0xff, 0xab, 0x37, 0x66, 0xeb, 0x67, 0x11, 0x00, 0x00, +func (m *MsgCreatePoll) Reset() { *m = MsgCreatePoll{} } +func (m *MsgCreatePoll) String() string { return proto.CompactTextString(m) } +func (*MsgCreatePoll) ProtoMessage() {} +func (*MsgCreatePoll) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{26} +} +func (m *MsgCreatePoll) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreatePoll) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreatePoll.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 *MsgCreatePoll) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreatePoll.Merge(m, src) +} +func (m *MsgCreatePoll) XXX_Size() int { + return m.Size() +} +func (m *MsgCreatePoll) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreatePoll.DiscardUnknown(m) } -// 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 +var xxx_messageInfo_MsgCreatePoll proto.InternalMessageInfo -// MsgClient is the client API for Msg service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MsgClient interface { - // CreateGroup creates a new group with an admin account address, a list of members and some optional metadata. - CreateGroup(ctx context.Context, in *MsgCreateGroup, opts ...grpc.CallOption) (*MsgCreateGroupResponse, error) - // UpdateGroupMembers updates the group members with given group id and admin address. - UpdateGroupMembers(ctx context.Context, in *MsgUpdateGroupMembers, opts ...grpc.CallOption) (*MsgUpdateGroupMembersResponse, error) - // UpdateGroupAdmin updates the group admin with given group id and previous admin address. - UpdateGroupAdmin(ctx context.Context, in *MsgUpdateGroupAdmin, opts ...grpc.CallOption) (*MsgUpdateGroupAdminResponse, error) - // UpdateGroupMetadata updates the group metadata with given group id and admin address. - UpdateGroupMetadata(ctx context.Context, in *MsgUpdateGroupMetadata, opts ...grpc.CallOption) (*MsgUpdateGroupMetadataResponse, error) - // CreateGroupAccount creates a new group account using given DecisionPolicy. - CreateGroupAccount(ctx context.Context, in *MsgCreateGroupAccount, opts ...grpc.CallOption) (*MsgCreateGroupAccountResponse, error) - // UpdateGroupAccountAdmin updates a group account admin. - UpdateGroupAccountAdmin(ctx context.Context, in *MsgUpdateGroupAccountAdmin, opts ...grpc.CallOption) (*MsgUpdateGroupAccountAdminResponse, error) - // UpdateGroupAccountDecisionPolicy allows a group account decision policy to be updated. - UpdateGroupAccountDecisionPolicy(ctx context.Context, in *MsgUpdateGroupAccountDecisionPolicy, opts ...grpc.CallOption) (*MsgUpdateGroupAccountDecisionPolicyResponse, error) - // UpdateGroupAccountMetadata updates a group account metadata. - UpdateGroupAccountMetadata(ctx context.Context, in *MsgUpdateGroupAccountMetadata, opts ...grpc.CallOption) (*MsgUpdateGroupAccountMetadataResponse, error) - // CreateProposal submits a new proposal. - CreateProposal(ctx context.Context, in *MsgCreateProposal, opts ...grpc.CallOption) (*MsgCreateProposalResponse, error) - // Vote allows a voter to vote on a proposal. - Vote(ctx context.Context, in *MsgVote, opts ...grpc.CallOption) (*MsgVoteResponse, error) - // VoteAgg allows a sender to submit a set of votes - VoteAgg(ctx context.Context, in *MsgVoteAgg, opts ...grpc.CallOption) (*MsgVoteAggResponse, error) - // Exec executes a proposal. - Exec(ctx context.Context, in *MsgExec, opts ...grpc.CallOption) (*MsgExecResponse, error) +// MsgCreateProposalResponse is the Msg/CreateProposal response type. +type MsgCreatePollResponse struct { + // poll_id is the unique ID of the poll. + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` } -type msgClient struct { - cc grpc1.ClientConn +func (m *MsgCreatePollResponse) Reset() { *m = MsgCreatePollResponse{} } +func (m *MsgCreatePollResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreatePollResponse) ProtoMessage() {} +func (*MsgCreatePollResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{27} } - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} +func (m *MsgCreatePollResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } - -func (c *msgClient) CreateGroup(ctx context.Context, in *MsgCreateGroup, opts ...grpc.CallOption) (*MsgCreateGroupResponse, error) { - out := new(MsgCreateGroupResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/CreateGroup", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgCreatePollResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreatePollResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil +} +func (m *MsgCreatePollResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreatePollResponse.Merge(m, src) +} +func (m *MsgCreatePollResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreatePollResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreatePollResponse.DiscardUnknown(m) } -func (c *msgClient) UpdateGroupMembers(ctx context.Context, in *MsgUpdateGroupMembers, opts ...grpc.CallOption) (*MsgUpdateGroupMembersResponse, error) { - out := new(MsgUpdateGroupMembersResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupMembers", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_MsgCreatePollResponse proto.InternalMessageInfo + +func (m *MsgCreatePollResponse) GetPollId() uint64 { + if m != nil { + return m.PollId } - return out, nil + return 0 } -func (c *msgClient) UpdateGroupAdmin(ctx context.Context, in *MsgUpdateGroupAdmin, opts ...grpc.CallOption) (*MsgUpdateGroupAdminResponse, error) { - out := new(MsgUpdateGroupAdminResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAdmin", in, out, opts...) - if err != nil { - return nil, err +// MsgVotePoll is the Msg/VotePoll request type. +type MsgVotePoll struct { + // poll_id is the unique ID of the poll. + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` + // voter is the voter account address. + Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"` + // options are the voter's choices on the poll. + Options Options `protobuf:"bytes,3,opt,name=options,proto3" json:"options"` + // metadata is any arbitrary metadata to attached to the vote. + Metadata []byte `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (m *MsgVotePoll) Reset() { *m = MsgVotePoll{} } +func (m *MsgVotePoll) String() string { return proto.CompactTextString(m) } +func (*MsgVotePoll) ProtoMessage() {} +func (*MsgVotePoll) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{28} +} +func (m *MsgVotePoll) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVotePoll) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVotePoll.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil +} +func (m *MsgVotePoll) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVotePoll.Merge(m, src) +} +func (m *MsgVotePoll) XXX_Size() int { + return m.Size() +} +func (m *MsgVotePoll) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVotePoll.DiscardUnknown(m) } -func (c *msgClient) UpdateGroupMetadata(ctx context.Context, in *MsgUpdateGroupMetadata, opts ...grpc.CallOption) (*MsgUpdateGroupMetadataResponse, error) { - out := new(MsgUpdateGroupMetadataResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupMetadata", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_MsgVotePoll proto.InternalMessageInfo + +func (m *MsgVotePoll) GetPollId() uint64 { + if m != nil { + return m.PollId } - return out, nil + return 0 } -func (c *msgClient) CreateGroupAccount(ctx context.Context, in *MsgCreateGroupAccount, opts ...grpc.CallOption) (*MsgCreateGroupAccountResponse, error) { - out := new(MsgCreateGroupAccountResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/CreateGroupAccount", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgVotePoll) GetVoter() string { + if m != nil { + return m.Voter } - return out, nil + return "" } -func (c *msgClient) UpdateGroupAccountAdmin(ctx context.Context, in *MsgUpdateGroupAccountAdmin, opts ...grpc.CallOption) (*MsgUpdateGroupAccountAdminResponse, error) { - out := new(MsgUpdateGroupAccountAdminResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAccountAdmin", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgVotePoll) GetOptions() Options { + if m != nil { + return m.Options } - return out, nil + return Options{} } -func (c *msgClient) UpdateGroupAccountDecisionPolicy(ctx context.Context, in *MsgUpdateGroupAccountDecisionPolicy, opts ...grpc.CallOption) (*MsgUpdateGroupAccountDecisionPolicyResponse, error) { - out := new(MsgUpdateGroupAccountDecisionPolicyResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAccountDecisionPolicy", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgVotePoll) GetMetadata() []byte { + if m != nil { + return m.Metadata } - return out, nil + return nil } -func (c *msgClient) UpdateGroupAccountMetadata(ctx context.Context, in *MsgUpdateGroupAccountMetadata, opts ...grpc.CallOption) (*MsgUpdateGroupAccountMetadataResponse, error) { - out := new(MsgUpdateGroupAccountMetadataResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAccountMetadata", in, out, opts...) - if err != nil { - return nil, err +// MsgVotePollResponse is the Msg/VotePoll response type. +type MsgVotePollResponse struct { +} + +func (m *MsgVotePollResponse) Reset() { *m = MsgVotePollResponse{} } +func (m *MsgVotePollResponse) String() string { return proto.CompactTextString(m) } +func (*MsgVotePollResponse) ProtoMessage() {} +func (*MsgVotePollResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{29} +} +func (m *MsgVotePollResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVotePollResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVotePollResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil +} +func (m *MsgVotePollResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVotePollResponse.Merge(m, src) +} +func (m *MsgVotePollResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgVotePollResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVotePollResponse.DiscardUnknown(m) } -func (c *msgClient) CreateProposal(ctx context.Context, in *MsgCreateProposal, opts ...grpc.CallOption) (*MsgCreateProposalResponse, error) { - out := new(MsgCreateProposalResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/CreateProposal", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_MsgVotePollResponse proto.InternalMessageInfo + +// MsgVoteBasicRequest is the Msg/Vote request type. +type MsgVotePollBasic struct { + // poll_id is the unique ID of the poll. + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` + // option is one of the voter's choices on the poll. + Option string `protobuf:"bytes,2,opt,name=option,proto3" json:"option,omitempty"` + // expiry is the unique timestamp after which the basic vote expires. + Expiry types1.Timestamp `protobuf:"bytes,3,opt,name=expiry,proto3" json:"expiry"` +} + +func (m *MsgVotePollBasic) Reset() { *m = MsgVotePollBasic{} } +func (m *MsgVotePollBasic) String() string { return proto.CompactTextString(m) } +func (*MsgVotePollBasic) ProtoMessage() {} +func (*MsgVotePollBasic) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{30} +} +func (m *MsgVotePollBasic) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVotePollBasic) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVotePollBasic.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil +} +func (m *MsgVotePollBasic) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVotePollBasic.Merge(m, src) +} +func (m *MsgVotePollBasic) XXX_Size() int { + return m.Size() +} +func (m *MsgVotePollBasic) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVotePollBasic.DiscardUnknown(m) } -func (c *msgClient) Vote(ctx context.Context, in *MsgVote, opts ...grpc.CallOption) (*MsgVoteResponse, error) { - out := new(MsgVoteResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/Vote", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_MsgVotePollBasic proto.InternalMessageInfo + +func (m *MsgVotePollBasic) GetPollId() uint64 { + if m != nil { + return m.PollId } - return out, nil + return 0 } -func (c *msgClient) VoteAgg(ctx context.Context, in *MsgVoteAgg, opts ...grpc.CallOption) (*MsgVoteAggResponse, error) { - out := new(MsgVoteAggResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/VoteAgg", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgVotePollBasic) GetOption() string { + if m != nil { + return m.Option } - return out, nil + return "" } -func (c *msgClient) Exec(ctx context.Context, in *MsgExec, opts ...grpc.CallOption) (*MsgExecResponse, error) { - out := new(MsgExecResponse) - err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/Exec", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgVotePollBasic) GetExpiry() types1.Timestamp { + if m != nil { + return m.Expiry } - return out, nil + return types1.Timestamp{} } -// MsgServer is the server API for Msg service. -type MsgServer interface { - // CreateGroup creates a new group with an admin account address, a list of members and some optional metadata. - CreateGroup(context.Context, *MsgCreateGroup) (*MsgCreateGroupResponse, error) - // UpdateGroupMembers updates the group members with given group id and admin address. - UpdateGroupMembers(context.Context, *MsgUpdateGroupMembers) (*MsgUpdateGroupMembersResponse, error) - // UpdateGroupAdmin updates the group admin with given group id and previous admin address. - UpdateGroupAdmin(context.Context, *MsgUpdateGroupAdmin) (*MsgUpdateGroupAdminResponse, error) - // UpdateGroupMetadata updates the group metadata with given group id and admin address. - UpdateGroupMetadata(context.Context, *MsgUpdateGroupMetadata) (*MsgUpdateGroupMetadataResponse, error) - // CreateGroupAccount creates a new group account using given DecisionPolicy. - CreateGroupAccount(context.Context, *MsgCreateGroupAccount) (*MsgCreateGroupAccountResponse, error) - // UpdateGroupAccountAdmin updates a group account admin. - UpdateGroupAccountAdmin(context.Context, *MsgUpdateGroupAccountAdmin) (*MsgUpdateGroupAccountAdminResponse, error) - // UpdateGroupAccountDecisionPolicy allows a group account decision policy to be updated. - UpdateGroupAccountDecisionPolicy(context.Context, *MsgUpdateGroupAccountDecisionPolicy) (*MsgUpdateGroupAccountDecisionPolicyResponse, error) - // UpdateGroupAccountMetadata updates a group account metadata. - UpdateGroupAccountMetadata(context.Context, *MsgUpdateGroupAccountMetadata) (*MsgUpdateGroupAccountMetadataResponse, error) - // CreateProposal submits a new proposal. - CreateProposal(context.Context, *MsgCreateProposal) (*MsgCreateProposalResponse, error) - // Vote allows a voter to vote on a proposal. - Vote(context.Context, *MsgVote) (*MsgVoteResponse, error) - // VoteAgg allows a sender to submit a set of votes - VoteAgg(context.Context, *MsgVoteAgg) (*MsgVoteAggResponse, error) - // Exec executes a proposal. - Exec(context.Context, *MsgExec) (*MsgExecResponse, error) -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { +// MsgVoteResponse is the basic vote that can be aggregated together +type MsgVotePollBasicResponse struct { + // proposal is the unique ID of the proposal. + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` + // options are the voter's choices on the poll. + Options Options `protobuf:"bytes,2,opt,name=options,proto3" json:"options"` + // expiry is the timestamp after which the basic vote expires. + Expiry types1.Timestamp `protobuf:"bytes,3,opt,name=expiry,proto3" json:"expiry"` + // voter is the account address of the voter. + Voter string `protobuf:"bytes,4,opt,name=voter,proto3" json:"voter,omitempty"` + // pub_key is the voter's public key + PubKey *types.Any `protobuf:"bytes,5,opt,name=pub_key,json=pubKey,proto3" json:"public_key,omitempty" yaml:"public_key"` + // sig is the individual signature which will be aggregated with other voters' signatures + Sig []byte `protobuf:"bytes,6,opt,name=sig,proto3" json:"sig,omitempty"` } -func (*UnimplementedMsgServer) CreateGroup(ctx context.Context, req *MsgCreateGroup) (*MsgCreateGroupResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateGroup not implemented") -} -func (*UnimplementedMsgServer) UpdateGroupMembers(ctx context.Context, req *MsgUpdateGroupMembers) (*MsgUpdateGroupMembersResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateGroupMembers not implemented") -} -func (*UnimplementedMsgServer) UpdateGroupAdmin(ctx context.Context, req *MsgUpdateGroupAdmin) (*MsgUpdateGroupAdminResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateGroupAdmin not implemented") -} -func (*UnimplementedMsgServer) UpdateGroupMetadata(ctx context.Context, req *MsgUpdateGroupMetadata) (*MsgUpdateGroupMetadataResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateGroupMetadata not implemented") -} -func (*UnimplementedMsgServer) CreateGroupAccount(ctx context.Context, req *MsgCreateGroupAccount) (*MsgCreateGroupAccountResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateGroupAccount not implemented") -} -func (*UnimplementedMsgServer) UpdateGroupAccountAdmin(ctx context.Context, req *MsgUpdateGroupAccountAdmin) (*MsgUpdateGroupAccountAdminResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateGroupAccountAdmin not implemented") -} -func (*UnimplementedMsgServer) UpdateGroupAccountDecisionPolicy(ctx context.Context, req *MsgUpdateGroupAccountDecisionPolicy) (*MsgUpdateGroupAccountDecisionPolicyResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateGroupAccountDecisionPolicy not implemented") +func (m *MsgVotePollBasicResponse) Reset() { *m = MsgVotePollBasicResponse{} } +func (m *MsgVotePollBasicResponse) String() string { return proto.CompactTextString(m) } +func (*MsgVotePollBasicResponse) ProtoMessage() {} +func (*MsgVotePollBasicResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{31} } -func (*UnimplementedMsgServer) UpdateGroupAccountMetadata(ctx context.Context, req *MsgUpdateGroupAccountMetadata) (*MsgUpdateGroupAccountMetadataResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateGroupAccountMetadata not implemented") +func (m *MsgVotePollBasicResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } -func (*UnimplementedMsgServer) CreateProposal(ctx context.Context, req *MsgCreateProposal) (*MsgCreateProposalResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateProposal not implemented") +func (m *MsgVotePollBasicResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVotePollBasicResponse.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 (*UnimplementedMsgServer) Vote(ctx context.Context, req *MsgVote) (*MsgVoteResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Vote not implemented") +func (m *MsgVotePollBasicResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVotePollBasicResponse.Merge(m, src) } -func (*UnimplementedMsgServer) VoteAgg(ctx context.Context, req *MsgVoteAgg) (*MsgVoteAggResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method VoteAgg not implemented") +func (m *MsgVotePollBasicResponse) XXX_Size() int { + return m.Size() } -func (*UnimplementedMsgServer) Exec(ctx context.Context, req *MsgExec) (*MsgExecResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Exec not implemented") +func (m *MsgVotePollBasicResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVotePollBasicResponse.DiscardUnknown(m) } -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} +var xxx_messageInfo_MsgVotePollBasicResponse proto.InternalMessageInfo -func _Msg_CreateGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreateGroup) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).CreateGroup(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/CreateGroup", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CreateGroup(ctx, req.(*MsgCreateGroup)) +func (m *MsgVotePollBasicResponse) GetPollId() uint64 { + if m != nil { + return m.PollId } - return interceptor(ctx, in, info, handler) + return 0 } -func _Msg_UpdateGroupMembers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateGroupMembers) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateGroupMembers(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupMembers", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateGroupMembers(ctx, req.(*MsgUpdateGroupMembers)) +func (m *MsgVotePollBasicResponse) GetOptions() Options { + if m != nil { + return m.Options } - return interceptor(ctx, in, info, handler) + return Options{} } -func _Msg_UpdateGroupAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateGroupAdmin) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateGroupAdmin(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAdmin", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateGroupAdmin(ctx, req.(*MsgUpdateGroupAdmin)) +func (m *MsgVotePollBasicResponse) GetExpiry() types1.Timestamp { + if m != nil { + return m.Expiry } - return interceptor(ctx, in, info, handler) + return types1.Timestamp{} } -func _Msg_UpdateGroupMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateGroupMetadata) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateGroupMetadata(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupMetadata", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateGroupMetadata(ctx, req.(*MsgUpdateGroupMetadata)) +func (m *MsgVotePollBasicResponse) GetVoter() string { + if m != nil { + return m.Voter } - return interceptor(ctx, in, info, handler) + return "" } -func _Msg_CreateGroupAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreateGroupAccount) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).CreateGroupAccount(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/CreateGroupAccount", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CreateGroupAccount(ctx, req.(*MsgCreateGroupAccount)) +func (m *MsgVotePollBasicResponse) GetPubKey() *types.Any { + if m != nil { + return m.PubKey } - return interceptor(ctx, in, info, handler) + return nil } -func _Msg_UpdateGroupAccountAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateGroupAccountAdmin) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateGroupAccountAdmin(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAccountAdmin", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateGroupAccountAdmin(ctx, req.(*MsgUpdateGroupAccountAdmin)) +func (m *MsgVotePollBasicResponse) GetSig() []byte { + if m != nil { + return m.Sig } - return interceptor(ctx, in, info, handler) + return nil } -func _Msg_UpdateGroupAccountDecisionPolicy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateGroupAccountDecisionPolicy) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateGroupAccountDecisionPolicy(ctx, in) +// MsgVoteAgg is the Msg/VoteAgg request type. +type MsgVotePollAgg struct { + // sender is the person who submits the votes + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // poll_id is the unique ID of the poll. + PollId uint64 `protobuf:"varint,2,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` + // votes are the full list of voters' choices on the proposal. + Votes []Options `protobuf:"bytes,3,rep,name=votes,proto3" json:"votes"` + // expiry is the timestamp after which the basic vote expires. + // All the basic votes to be aggregated must have the same expiry. + // Expiry should be set to be before the poll timeout in order to + // prevent replay attacks and also prevent the aggregator from removing + // some basic votes. + Expiry types1.Timestamp `protobuf:"bytes,4,opt,name=expiry,proto3" json:"expiry"` + // agg_sig is the bls aggregated signature for all the votes + AggSig []byte `protobuf:"bytes,5,opt,name=agg_sig,json=aggSig,proto3" json:"agg_sig,omitempty"` + // metadata is any arbitrary metadata to attached to the vote. + Metadata []byte `protobuf:"bytes,6,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (m *MsgVotePollAgg) Reset() { *m = MsgVotePollAgg{} } +func (m *MsgVotePollAgg) String() string { return proto.CompactTextString(m) } +func (*MsgVotePollAgg) ProtoMessage() {} +func (*MsgVotePollAgg) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{32} +} +func (m *MsgVotePollAgg) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVotePollAgg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVotePollAgg.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAccountDecisionPolicy", +} +func (m *MsgVotePollAgg) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVotePollAgg.Merge(m, src) +} +func (m *MsgVotePollAgg) XXX_Size() int { + return m.Size() +} +func (m *MsgVotePollAgg) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVotePollAgg.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgVotePollAgg proto.InternalMessageInfo + +func (m *MsgVotePollAgg) GetSender() string { + if m != nil { + return m.Sender } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateGroupAccountDecisionPolicy(ctx, req.(*MsgUpdateGroupAccountDecisionPolicy)) + return "" +} + +func (m *MsgVotePollAgg) GetPollId() uint64 { + if m != nil { + return m.PollId } - return interceptor(ctx, in, info, handler) + return 0 } -func _Msg_UpdateGroupAccountMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateGroupAccountMetadata) - if err := dec(in); err != nil { - return nil, err +func (m *MsgVotePollAgg) GetVotes() []Options { + if m != nil { + return m.Votes } - if interceptor == nil { - return srv.(MsgServer).UpdateGroupAccountMetadata(ctx, in) + return nil +} + +func (m *MsgVotePollAgg) GetExpiry() types1.Timestamp { + if m != nil { + return m.Expiry } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAccountMetadata", + return types1.Timestamp{} +} + +func (m *MsgVotePollAgg) GetAggSig() []byte { + if m != nil { + return m.AggSig } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateGroupAccountMetadata(ctx, req.(*MsgUpdateGroupAccountMetadata)) + return nil +} + +func (m *MsgVotePollAgg) GetMetadata() []byte { + if m != nil { + return m.Metadata } - return interceptor(ctx, in, info, handler) + return nil } -func _Msg_CreateProposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreateProposal) - if err := dec(in); err != nil { - return nil, err +// MsgVoteResponse is the Msg/Vote response type. +type MsgVotePollAggResponse struct { +} + +func (m *MsgVotePollAggResponse) Reset() { *m = MsgVotePollAggResponse{} } +func (m *MsgVotePollAggResponse) String() string { return proto.CompactTextString(m) } +func (*MsgVotePollAggResponse) ProtoMessage() {} +func (*MsgVotePollAggResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b4673626e7797578, []int{33} +} +func (m *MsgVotePollAggResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVotePollAggResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVotePollAggResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - if interceptor == nil { - return srv.(MsgServer).CreateProposal(ctx, in) +} +func (m *MsgVotePollAggResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVotePollAggResponse.Merge(m, src) +} +func (m *MsgVotePollAggResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgVotePollAggResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVotePollAggResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgVotePollAggResponse proto.InternalMessageInfo + +func init() { + proto.RegisterEnum("regen.group.v1alpha1.Exec", Exec_name, Exec_value) + proto.RegisterType((*MsgCreateGroup)(nil), "regen.group.v1alpha1.MsgCreateGroup") + proto.RegisterType((*MsgCreateGroupResponse)(nil), "regen.group.v1alpha1.MsgCreateGroupResponse") + proto.RegisterType((*MsgUpdateGroupMembers)(nil), "regen.group.v1alpha1.MsgUpdateGroupMembers") + proto.RegisterType((*MsgUpdateGroupMembersResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupMembersResponse") + proto.RegisterType((*MsgUpdateGroupAdmin)(nil), "regen.group.v1alpha1.MsgUpdateGroupAdmin") + proto.RegisterType((*MsgUpdateGroupAdminResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupAdminResponse") + proto.RegisterType((*MsgUpdateGroupMetadata)(nil), "regen.group.v1alpha1.MsgUpdateGroupMetadata") + proto.RegisterType((*MsgUpdateGroupMetadataResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupMetadataResponse") + proto.RegisterType((*MsgCreateGroupAccount)(nil), "regen.group.v1alpha1.MsgCreateGroupAccount") + proto.RegisterType((*MsgCreateGroupAccountResponse)(nil), "regen.group.v1alpha1.MsgCreateGroupAccountResponse") + proto.RegisterType((*MsgUpdateGroupAccountAdmin)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountAdmin") + proto.RegisterType((*MsgUpdateGroupAccountAdminResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountAdminResponse") + proto.RegisterType((*MsgUpdateGroupAccountDecisionPolicy)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountDecisionPolicy") + proto.RegisterType((*MsgUpdateGroupAccountDecisionPolicyResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountDecisionPolicyResponse") + proto.RegisterType((*MsgUpdateGroupAccountMetadata)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountMetadata") + proto.RegisterType((*MsgUpdateGroupAccountMetadataResponse)(nil), "regen.group.v1alpha1.MsgUpdateGroupAccountMetadataResponse") + proto.RegisterType((*MsgCreateProposal)(nil), "regen.group.v1alpha1.MsgCreateProposal") + proto.RegisterType((*MsgCreateProposalResponse)(nil), "regen.group.v1alpha1.MsgCreateProposalResponse") + proto.RegisterType((*MsgVote)(nil), "regen.group.v1alpha1.MsgVote") + proto.RegisterType((*MsgVoteResponse)(nil), "regen.group.v1alpha1.MsgVoteResponse") + proto.RegisterType((*MsgVoteBasic)(nil), "regen.group.v1alpha1.MsgVoteBasic") + proto.RegisterType((*MsgVoteBasicResponse)(nil), "regen.group.v1alpha1.MsgVoteBasicResponse") + proto.RegisterType((*MsgVoteAgg)(nil), "regen.group.v1alpha1.MsgVoteAgg") + proto.RegisterType((*MsgVoteAggResponse)(nil), "regen.group.v1alpha1.MsgVoteAggResponse") + proto.RegisterType((*MsgExec)(nil), "regen.group.v1alpha1.MsgExec") + proto.RegisterType((*MsgExecResponse)(nil), "regen.group.v1alpha1.MsgExecResponse") + proto.RegisterType((*MsgCreatePoll)(nil), "regen.group.v1alpha1.MsgCreatePoll") + proto.RegisterType((*MsgCreatePollResponse)(nil), "regen.group.v1alpha1.MsgCreatePollResponse") + proto.RegisterType((*MsgVotePoll)(nil), "regen.group.v1alpha1.MsgVotePoll") + proto.RegisterType((*MsgVotePollResponse)(nil), "regen.group.v1alpha1.MsgVotePollResponse") + proto.RegisterType((*MsgVotePollBasic)(nil), "regen.group.v1alpha1.MsgVotePollBasic") + proto.RegisterType((*MsgVotePollBasicResponse)(nil), "regen.group.v1alpha1.MsgVotePollBasicResponse") + proto.RegisterType((*MsgVotePollAgg)(nil), "regen.group.v1alpha1.MsgVotePollAgg") + proto.RegisterType((*MsgVotePollAggResponse)(nil), "regen.group.v1alpha1.MsgVotePollAggResponse") +} + +func init() { proto.RegisterFile("regen/group/v1alpha1/tx.proto", fileDescriptor_b4673626e7797578) } + +var fileDescriptor_b4673626e7797578 = []byte{ + // 1475 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xcf, 0x8f, 0xdb, 0xc4, + 0x17, 0x5f, 0x27, 0xd9, 0x64, 0xf7, 0xed, 0x36, 0xdd, 0xba, 0x69, 0x9b, 0xba, 0xdd, 0x24, 0x5f, + 0x77, 0xab, 0xa6, 0xdd, 0xdd, 0xa4, 0xdd, 0xed, 0xa1, 0xed, 0xb7, 0x20, 0xed, 0x6e, 0x17, 0xb4, + 0xa2, 0x4b, 0x8b, 0xdb, 0xa2, 0x82, 0x10, 0x91, 0x63, 0x0f, 0xae, 0xa9, 0xed, 0xb1, 0x62, 0xa7, + 0xdd, 0x1c, 0x38, 0x22, 0x71, 0x42, 0x48, 0x48, 0x80, 0xc4, 0x81, 0xfe, 0x03, 0x70, 0x40, 0x5c, + 0xb9, 0x70, 0xa1, 0xe2, 0xd4, 0x23, 0xa7, 0x0a, 0xb5, 0x37, 0xb8, 0x71, 0x47, 0x42, 0x1e, 0x8f, + 0x27, 0x4e, 0x62, 0x3b, 0xce, 0xb6, 0x02, 0x71, 0xda, 0x9d, 0x99, 0xcf, 0xfb, 0xf5, 0x79, 0x6f, + 0x9e, 0xe7, 0x05, 0x16, 0x3b, 0x48, 0x43, 0x56, 0x53, 0xeb, 0xe0, 0xae, 0xdd, 0x7c, 0x70, 0x41, + 0x36, 0xec, 0x7b, 0xf2, 0x85, 0xa6, 0xbb, 0xd7, 0xb0, 0x3b, 0xd8, 0xc5, 0x7c, 0x89, 0x1c, 0x37, + 0xc8, 0x71, 0x23, 0x38, 0x16, 0x4a, 0x1a, 0xd6, 0x30, 0x01, 0x34, 0xbd, 0xff, 0x7c, 0xac, 0x30, + 0xaf, 0x60, 0xc7, 0xc4, 0x0e, 0x5d, 0x1d, 0xd7, 0x30, 0xd6, 0x0c, 0xd4, 0x24, 0xab, 0x76, 0xf7, + 0x83, 0xa6, 0x6c, 0xf5, 0xe8, 0x51, 0x75, 0xf8, 0xc8, 0xd5, 0x4d, 0xe4, 0xb8, 0xb2, 0x69, 0x53, + 0x40, 0x2d, 0xda, 0xa9, 0x9e, 0x8d, 0xa8, 0x76, 0xf1, 0x6b, 0x0e, 0x8a, 0xbb, 0x8e, 0xb6, 0xd5, + 0x41, 0xb2, 0x8b, 0x5e, 0xf7, 0x70, 0x7c, 0x09, 0xa6, 0x65, 0xd5, 0xd4, 0xad, 0x32, 0x57, 0xe3, + 0xea, 0xb3, 0x92, 0xbf, 0xe0, 0xaf, 0x42, 0xc1, 0x44, 0x66, 0x1b, 0x75, 0x9c, 0x72, 0xa6, 0x96, + 0xad, 0xcf, 0xad, 0x9d, 0x6c, 0x44, 0x85, 0xd4, 0xd8, 0x25, 0xa0, 0xcd, 0xdc, 0xe3, 0xa7, 0xd5, + 0x29, 0x29, 0x10, 0xe1, 0x05, 0x98, 0x31, 0x91, 0x2b, 0xab, 0xb2, 0x2b, 0x97, 0xb3, 0x35, 0xae, + 0x3e, 0x2f, 0xb1, 0x35, 0x7f, 0x1c, 0x66, 0xda, 0x86, 0xd3, 0xc2, 0x96, 0xd1, 0x2b, 0xe7, 0x6a, + 0x5c, 0x7d, 0x46, 0x2a, 0xb4, 0x0d, 0xe7, 0x86, 0x65, 0xf4, 0xc4, 0x75, 0x38, 0x3a, 0xe8, 0x9c, + 0x84, 0x1c, 0x1b, 0x5b, 0x0e, 0xf2, 0x84, 0x88, 0xe1, 0x96, 0xae, 0x12, 0x3f, 0x73, 0x52, 0x81, + 0xac, 0x77, 0x54, 0xf1, 0x73, 0x0e, 0x8e, 0xec, 0x3a, 0xda, 0x1d, 0x5b, 0x0d, 0xa4, 0x76, 0xa9, + 0x17, 0xd1, 0x91, 0x85, 0x55, 0x65, 0x06, 0x54, 0xf1, 0x3b, 0x50, 0xf4, 0x23, 0x68, 0x75, 0x89, + 0x36, 0xa7, 0x9c, 0x4d, 0x1d, 0xfb, 0x01, 0x5f, 0xd2, 0x77, 0xc3, 0x11, 0xab, 0xb0, 0x18, 0xe9, + 0x54, 0x10, 0x91, 0xa8, 0xc0, 0xe1, 0x41, 0xc0, 0x06, 0xf1, 0x6e, 0x62, 0x9f, 0x4f, 0xc0, 0xac, + 0x85, 0x1e, 0xb6, 0x7c, 0xa1, 0x2c, 0x11, 0x9a, 0xb1, 0xd0, 0x43, 0xa2, 0x4d, 0x5c, 0x84, 0x13, + 0x11, 0x46, 0x98, 0x0f, 0x88, 0xf0, 0x3d, 0xe0, 0x24, 0x4d, 0xd2, 0xc4, 0x6e, 0x24, 0x64, 0x5c, + 0xac, 0x41, 0x25, 0xda, 0x0c, 0x73, 0xe4, 0x47, 0x3f, 0x87, 0xa1, 0xcc, 0x6f, 0x28, 0x0a, 0xee, + 0x5a, 0xee, 0x4b, 0x75, 0x84, 0x7f, 0x0b, 0x0e, 0xaa, 0x48, 0xd1, 0x1d, 0x1d, 0x5b, 0x2d, 0x1b, + 0x1b, 0xba, 0xe2, 0x57, 0xe0, 0xdc, 0x5a, 0xa9, 0xe1, 0x5f, 0xad, 0x46, 0x70, 0xb5, 0x1a, 0x1b, + 0x56, 0x6f, 0x93, 0xff, 0xe5, 0x87, 0xd5, 0xe2, 0x35, 0x2a, 0x70, 0x93, 0xe0, 0xa5, 0xa2, 0x3a, + 0xb0, 0xbe, 0x92, 0xfb, 0xe4, 0x51, 0x75, 0x4a, 0xbc, 0x4c, 0xb2, 0x3d, 0xea, 0x3e, 0xab, 0xdf, + 0x32, 0x14, 0x64, 0x55, 0xed, 0x20, 0xc7, 0xa1, 0x81, 0x04, 0x4b, 0x51, 0x07, 0x61, 0x28, 0x45, + 0xbe, 0x68, 0x52, 0x39, 0x84, 0xb4, 0x65, 0x06, 0xb4, 0x25, 0x57, 0xc3, 0x12, 0x88, 0xf1, 0xa6, + 0x58, 0x2e, 0xbe, 0xe3, 0xe0, 0x54, 0x24, 0x6c, 0x90, 0x89, 0x89, 0x5d, 0x8b, 0x20, 0x3f, 0xfb, + 0x52, 0xc8, 0x5f, 0x85, 0xe5, 0x14, 0xfe, 0xb2, 0xf8, 0xee, 0x0f, 0xdf, 0x4c, 0x0a, 0x1f, 0x53, + 0xfb, 0xf1, 0x81, 0x25, 0x95, 0xfe, 0x19, 0x38, 0x9d, 0x68, 0x8c, 0x79, 0xf5, 0x33, 0x07, 0x87, + 0x58, 0x09, 0xdd, 0xec, 0x60, 0x1b, 0x3b, 0xb2, 0x11, 0x5f, 0x36, 0xfc, 0x49, 0x98, 0xb5, 0x09, + 0x2a, 0xe8, 0xd0, 0xb3, 0x52, 0x7f, 0x23, 0xf1, 0x12, 0xd4, 0x21, 0x67, 0x3a, 0x9a, 0x53, 0xce, + 0x91, 0xd6, 0x16, 0x49, 0xbe, 0x44, 0x10, 0x7c, 0x03, 0x72, 0x68, 0x0f, 0x29, 0xe5, 0xe9, 0x1a, + 0x57, 0x2f, 0xae, 0x09, 0xd1, 0x4d, 0x70, 0x7b, 0x0f, 0x29, 0x12, 0xc1, 0xd1, 0x74, 0x5c, 0x85, + 0xe3, 0x23, 0x81, 0xb0, 0x7b, 0x50, 0x85, 0x39, 0x9b, 0xee, 0xf5, 0x5b, 0x39, 0x04, 0x5b, 0x3b, + 0xaa, 0xf8, 0x13, 0x07, 0x85, 0x5d, 0x47, 0x7b, 0x1b, 0xbb, 0xe3, 0xc1, 0x5e, 0xa6, 0x1e, 0x60, + 0x17, 0x75, 0x68, 0x46, 0xfc, 0x05, 0x7f, 0x11, 0xf2, 0xca, 0x3d, 0xac, 0x2b, 0x88, 0x84, 0x5e, + 0x8c, 0xeb, 0xde, 0x5b, 0x04, 0x23, 0x51, 0xec, 0x00, 0x65, 0xb9, 0x21, 0xca, 0x26, 0x24, 0x42, + 0x3c, 0x04, 0x07, 0x69, 0x0c, 0x2c, 0xbf, 0xdf, 0x70, 0x30, 0x4f, 0xf7, 0x36, 0x65, 0x47, 0x57, + 0xc6, 0x07, 0xd7, 0x0f, 0x23, 0x33, 0x41, 0x18, 0x97, 0x20, 0x8f, 0xf6, 0x6c, 0xbd, 0x13, 0x5c, + 0x2e, 0x61, 0x24, 0xbf, 0xb7, 0x83, 0x47, 0x03, 0xfd, 0x70, 0x51, 0xbc, 0xf8, 0x6d, 0x06, 0x4a, + 0x61, 0x0f, 0x53, 0xe7, 0xec, 0x9f, 0xf6, 0xb4, 0x9f, 0xf6, 0x5c, 0x38, 0xed, 0xef, 0x41, 0xc1, + 0xee, 0xb6, 0x5b, 0xf7, 0x51, 0x8f, 0xe4, 0x29, 0xae, 0xaf, 0xac, 0xfe, 0xfe, 0xb4, 0x5a, 0xb2, + 0xbb, 0x6d, 0x43, 0x57, 0x3c, 0xec, 0x0a, 0x36, 0x75, 0x17, 0x99, 0xb6, 0xdb, 0xfb, 0xf3, 0x69, + 0xf5, 0x50, 0x4f, 0x36, 0x8d, 0x2b, 0x62, 0xff, 0x54, 0x94, 0xf2, 0x76, 0xb7, 0xfd, 0x06, 0xea, + 0xf1, 0x0b, 0x90, 0x75, 0x74, 0xad, 0x9c, 0x27, 0x95, 0xe1, 0xfd, 0x2b, 0x7e, 0x95, 0x01, 0xa0, + 0x7c, 0x6d, 0x68, 0x1a, 0x7f, 0x14, 0xf2, 0x0e, 0xb2, 0x54, 0xd4, 0xa1, 0x37, 0x95, 0xae, 0x86, + 0xd9, 0xcb, 0x8c, 0xb0, 0xb7, 0xe6, 0x47, 0xe3, 0xbf, 0x35, 0xc6, 0x91, 0xe7, 0x43, 0x43, 0xdc, + 0xe5, 0x26, 0xe4, 0xee, 0x18, 0x14, 0x64, 0x4d, 0x6b, 0x79, 0xb1, 0x4c, 0x93, 0x58, 0xf2, 0xb2, + 0xa6, 0xdd, 0xd2, 0xb5, 0x81, 0xfa, 0xcf, 0xc7, 0xd4, 0x7f, 0x21, 0x65, 0xfd, 0x97, 0x80, 0xef, + 0x33, 0xc3, 0xae, 0xc0, 0x26, 0xb9, 0xd9, 0x1e, 0x6c, 0x7c, 0x49, 0x79, 0x6c, 0xea, 0x9a, 0xc5, + 0xae, 0x36, 0x5d, 0xd1, 0x9b, 0x45, 0x4c, 0x05, 0x6a, 0xbf, 0xc8, 0xc0, 0x81, 0x7e, 0xc3, 0xc1, + 0x86, 0x91, 0xf0, 0x58, 0xf4, 0x4a, 0xc7, 0xd5, 0x5d, 0x03, 0x05, 0x1d, 0x83, 0x2c, 0xf8, 0x57, + 0xa0, 0x80, 0x6d, 0x57, 0xc7, 0x96, 0x43, 0x6b, 0x71, 0x31, 0x3a, 0xc4, 0x1b, 0x3e, 0x28, 0x78, + 0xed, 0x52, 0x19, 0xaf, 0x4b, 0x2b, 0x9e, 0x75, 0x1c, 0x54, 0x64, 0xb0, 0xe4, 0x17, 0x01, 0xbc, + 0x84, 0xb5, 0x0c, 0xdd, 0xd4, 0x5d, 0x42, 0xf8, 0xb4, 0x34, 0xeb, 0xed, 0x5c, 0xf7, 0x36, 0x12, + 0x39, 0xbf, 0x02, 0x05, 0xef, 0x79, 0x8f, 0xbb, 0x2e, 0xa1, 0x3d, 0x4d, 0x8e, 0x03, 0x01, 0xda, + 0x88, 0xcf, 0x87, 0xde, 0x54, 0x1e, 0x2f, 0xec, 0x42, 0x1f, 0x83, 0x82, 0x8d, 0x8d, 0x10, 0xf3, + 0x79, 0x6f, 0xb9, 0xa3, 0x8a, 0x5f, 0x72, 0x30, 0x47, 0x13, 0x47, 0x88, 0x8c, 0x03, 0xc6, 0x34, + 0xde, 0x17, 0xa4, 0x31, 0xa1, 0x03, 0x8b, 0x47, 0xc8, 0x6b, 0x39, 0x70, 0x8c, 0xe5, 0xfe, 0x23, + 0x58, 0x08, 0x6d, 0xfb, 0x8d, 0x35, 0xd6, 0xe9, 0xa3, 0x90, 0xf7, 0x4d, 0x05, 0x35, 0xe5, 0xaf, + 0x5e, 0xa0, 0x65, 0x7e, 0x9f, 0x81, 0xf2, 0xb0, 0xfd, 0xb1, 0x2c, 0x87, 0x69, 0xca, 0xec, 0x83, + 0xa6, 0xff, 0x7a, 0xdf, 0xfc, 0xc3, 0x1f, 0x41, 0x03, 0xd2, 0x92, 0x7a, 0x67, 0x88, 0xc2, 0xcc, + 0x00, 0x85, 0x97, 0xc3, 0x3d, 0x33, 0x25, 0x81, 0xff, 0x4a, 0xeb, 0x14, 0xcb, 0x64, 0xc4, 0x0a, + 0x05, 0x1b, 0xd4, 0xc7, 0xb9, 0x73, 0x90, 0x23, 0xbd, 0xb0, 0x04, 0x0b, 0xdb, 0x77, 0xb7, 0xb7, + 0x5a, 0x77, 0xde, 0xbc, 0x75, 0x73, 0x7b, 0x6b, 0xe7, 0xb5, 0x9d, 0xed, 0x6b, 0x0b, 0x53, 0xfc, + 0x3c, 0xcc, 0x90, 0xdd, 0xdb, 0xd2, 0x3b, 0x0b, 0xdc, 0xda, 0x5f, 0xf3, 0x90, 0xdd, 0x75, 0x34, + 0x5e, 0x86, 0xb9, 0xf0, 0xe8, 0xbe, 0x14, 0x33, 0x97, 0x0e, 0x8c, 0x22, 0xc2, 0x4a, 0x1a, 0x14, + 0x2b, 0xdb, 0x07, 0xc0, 0x47, 0x8c, 0xd2, 0xcb, 0xb1, 0x3a, 0x46, 0xc1, 0xc2, 0xfa, 0x04, 0x60, + 0x66, 0xd7, 0x86, 0x85, 0x91, 0x61, 0xf8, 0x6c, 0x1a, 0x45, 0x04, 0x2a, 0x5c, 0x48, 0x0d, 0x65, + 0x16, 0x7b, 0x70, 0x38, 0x6a, 0xf4, 0x5d, 0x49, 0xe7, 0xbd, 0x8f, 0x16, 0x2e, 0x4e, 0x82, 0x0e, + 0x93, 0x1c, 0x31, 0xeb, 0x2e, 0xa7, 0x49, 0x14, 0x05, 0x27, 0x90, 0x9c, 0x30, 0x86, 0x7e, 0xcc, + 0xc1, 0xb1, 0xb8, 0x51, 0xf3, 0x7c, 0x2a, 0x06, 0x43, 0x12, 0xc2, 0xa5, 0x49, 0x25, 0x98, 0x1f, + 0x8f, 0x38, 0xa8, 0x8d, 0x1d, 0x30, 0x2f, 0x4f, 0xa0, 0x7e, 0x50, 0x54, 0xd8, 0xd8, 0xb7, 0x28, + 0x73, 0xf1, 0x53, 0x0e, 0x84, 0x84, 0x21, 0x71, 0x7d, 0x02, 0x0b, 0xac, 0x58, 0xfe, 0xbf, 0x0f, + 0x21, 0xe6, 0xd0, 0x87, 0x50, 0x1c, 0x9a, 0x0e, 0xcf, 0x8c, 0x29, 0x81, 0x00, 0x28, 0x34, 0x53, + 0x02, 0x99, 0xad, 0xeb, 0x90, 0x23, 0x13, 0xd8, 0x62, 0xac, 0xa0, 0x77, 0x2c, 0x9c, 0x4e, 0x3c, + 0x66, 0xda, 0xee, 0x40, 0x21, 0x78, 0x25, 0xd7, 0x12, 0x25, 0x36, 0x34, 0x4d, 0xa8, 0x8f, 0x43, + 0x84, 0x9d, 0x24, 0x0d, 0x34, 0xde, 0x49, 0xef, 0x38, 0xc1, 0xc9, 0xf0, 0x33, 0x92, 0x7f, 0x1f, + 0x20, 0xf4, 0x84, 0x3c, 0x35, 0x8e, 0x31, 0x6c, 0x18, 0xc2, 0x72, 0x0a, 0x10, 0xd3, 0x7f, 0x17, + 0x66, 0xd8, 0xbb, 0xea, 0x7f, 0x89, 0x31, 0x12, 0xdd, 0x67, 0xc7, 0x42, 0x98, 0x66, 0x19, 0xe6, + 0xc2, 0x1f, 0xd3, 0xa5, 0xb1, 0x92, 0x1e, 0xcd, 0x2b, 0x69, 0x50, 0x81, 0x89, 0xcd, 0x57, 0x1f, + 0x3f, 0xab, 0x70, 0x4f, 0x9e, 0x55, 0xb8, 0xdf, 0x9e, 0x55, 0xb8, 0xcf, 0x9e, 0x57, 0xa6, 0x9e, + 0x3c, 0xaf, 0x4c, 0xfd, 0xfa, 0xbc, 0x32, 0xf5, 0xee, 0x92, 0xa6, 0xbb, 0xf7, 0xba, 0xed, 0x86, + 0x82, 0xcd, 0xa6, 0xff, 0x3b, 0x36, 0xfd, 0xb3, 0xea, 0xa8, 0xf7, 0x9b, 0x7b, 0xfe, 0x6f, 0xd1, + 0xed, 0x3c, 0xf9, 0xb8, 0xae, 0xff, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x48, 0xf8, 0x8f, 0x4a, 0x36, + 0x17, 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 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // CreateGroup creates a new group with an admin account address, a list of members and some optional metadata. + CreateGroup(ctx context.Context, in *MsgCreateGroup, opts ...grpc.CallOption) (*MsgCreateGroupResponse, error) + // UpdateGroupMembers updates the group members with given group id and admin address. + UpdateGroupMembers(ctx context.Context, in *MsgUpdateGroupMembers, opts ...grpc.CallOption) (*MsgUpdateGroupMembersResponse, error) + // UpdateGroupAdmin updates the group admin with given group id and previous admin address. + UpdateGroupAdmin(ctx context.Context, in *MsgUpdateGroupAdmin, opts ...grpc.CallOption) (*MsgUpdateGroupAdminResponse, error) + // UpdateGroupMetadata updates the group metadata with given group id and admin address. + UpdateGroupMetadata(ctx context.Context, in *MsgUpdateGroupMetadata, opts ...grpc.CallOption) (*MsgUpdateGroupMetadataResponse, error) + // CreateGroupAccount creates a new group account using given DecisionPolicy. + CreateGroupAccount(ctx context.Context, in *MsgCreateGroupAccount, opts ...grpc.CallOption) (*MsgCreateGroupAccountResponse, error) + // UpdateGroupAccountAdmin updates a group account admin. + UpdateGroupAccountAdmin(ctx context.Context, in *MsgUpdateGroupAccountAdmin, opts ...grpc.CallOption) (*MsgUpdateGroupAccountAdminResponse, error) + // UpdateGroupAccountDecisionPolicy allows a group account decision policy to be updated. + UpdateGroupAccountDecisionPolicy(ctx context.Context, in *MsgUpdateGroupAccountDecisionPolicy, opts ...grpc.CallOption) (*MsgUpdateGroupAccountDecisionPolicyResponse, error) + // UpdateGroupAccountMetadata updates a group account metadata. + UpdateGroupAccountMetadata(ctx context.Context, in *MsgUpdateGroupAccountMetadata, opts ...grpc.CallOption) (*MsgUpdateGroupAccountMetadataResponse, error) + // CreateProposal submits a new proposal. + CreateProposal(ctx context.Context, in *MsgCreateProposal, opts ...grpc.CallOption) (*MsgCreateProposalResponse, error) + // Vote allows a voter to vote on a proposal. + Vote(ctx context.Context, in *MsgVote, opts ...grpc.CallOption) (*MsgVoteResponse, error) + // VoteAgg allows a sender to submit a set of votes + VoteAgg(ctx context.Context, in *MsgVoteAgg, opts ...grpc.CallOption) (*MsgVoteAggResponse, error) + // Exec executes a proposal. + Exec(ctx context.Context, in *MsgExec, opts ...grpc.CallOption) (*MsgExecResponse, error) + // CreatePoll submits a new poll. + CreatePoll(ctx context.Context, in *MsgCreatePoll, opts ...grpc.CallOption) (*MsgCreatePollResponse, error) + // VotePoll allows a voter to vote on a poll. + VotePoll(ctx context.Context, in *MsgVotePoll, opts ...grpc.CallOption) (*MsgVotePollResponse, error) + // VotePollAgg allows a sender to submit a set of votes + VotePollAgg(ctx context.Context, in *MsgVotePollAgg, opts ...grpc.CallOption) (*MsgVotePollAggResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) CreateGroup(ctx context.Context, in *MsgCreateGroup, opts ...grpc.CallOption) (*MsgCreateGroupResponse, error) { + out := new(MsgCreateGroupResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/CreateGroup", in, out, opts...) + if err != nil { + return nil, err } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/CreateProposal", + return out, nil +} + +func (c *msgClient) UpdateGroupMembers(ctx context.Context, in *MsgUpdateGroupMembers, opts ...grpc.CallOption) (*MsgUpdateGroupMembersResponse, error) { + out := new(MsgUpdateGroupMembersResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupMembers", in, out, opts...) + if err != nil { + return nil, err } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CreateProposal(ctx, req.(*MsgCreateProposal)) + return out, nil +} + +func (c *msgClient) UpdateGroupAdmin(ctx context.Context, in *MsgUpdateGroupAdmin, opts ...grpc.CallOption) (*MsgUpdateGroupAdminResponse, error) { + out := new(MsgUpdateGroupAdminResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAdmin", in, out, opts...) + if err != nil { + return nil, err } - return interceptor(ctx, in, info, handler) + return out, nil } -func _Msg_Vote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgVote) - if err := dec(in); err != nil { +func (c *msgClient) UpdateGroupMetadata(ctx context.Context, in *MsgUpdateGroupMetadata, opts ...grpc.CallOption) (*MsgUpdateGroupMetadataResponse, error) { + out := new(MsgUpdateGroupMetadataResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupMetadata", in, out, opts...) + if err != nil { return nil, err } - if interceptor == nil { - return srv.(MsgServer).Vote(ctx, in) + return out, nil +} + +func (c *msgClient) CreateGroupAccount(ctx context.Context, in *MsgCreateGroupAccount, opts ...grpc.CallOption) (*MsgCreateGroupAccountResponse, error) { + out := new(MsgCreateGroupAccountResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/CreateGroupAccount", in, out, opts...) + if err != nil { + return nil, err } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/Vote", + return out, nil +} + +func (c *msgClient) UpdateGroupAccountAdmin(ctx context.Context, in *MsgUpdateGroupAccountAdmin, opts ...grpc.CallOption) (*MsgUpdateGroupAccountAdminResponse, error) { + out := new(MsgUpdateGroupAccountAdminResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAccountAdmin", in, out, opts...) + if err != nil { + return nil, err } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Vote(ctx, req.(*MsgVote)) + return out, nil +} + +func (c *msgClient) UpdateGroupAccountDecisionPolicy(ctx context.Context, in *MsgUpdateGroupAccountDecisionPolicy, opts ...grpc.CallOption) (*MsgUpdateGroupAccountDecisionPolicyResponse, error) { + out := new(MsgUpdateGroupAccountDecisionPolicyResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAccountDecisionPolicy", in, out, opts...) + if err != nil { + return nil, err } - return interceptor(ctx, in, info, handler) + return out, nil } -func _Msg_VoteAgg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgVoteAgg) - if err := dec(in); err != nil { +func (c *msgClient) UpdateGroupAccountMetadata(ctx context.Context, in *MsgUpdateGroupAccountMetadata, opts ...grpc.CallOption) (*MsgUpdateGroupAccountMetadataResponse, error) { + out := new(MsgUpdateGroupAccountMetadataResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/UpdateGroupAccountMetadata", in, out, opts...) + if err != nil { return nil, err } - if interceptor == nil { - return srv.(MsgServer).VoteAgg(ctx, in) + return out, nil +} + +func (c *msgClient) CreateProposal(ctx context.Context, in *MsgCreateProposal, opts ...grpc.CallOption) (*MsgCreateProposalResponse, error) { + out := new(MsgCreateProposalResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/CreateProposal", in, out, opts...) + if err != nil { + return nil, err } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/VoteAgg", + return out, nil +} + +func (c *msgClient) Vote(ctx context.Context, in *MsgVote, opts ...grpc.CallOption) (*MsgVoteResponse, error) { + out := new(MsgVoteResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/Vote", in, out, opts...) + if err != nil { + return nil, err } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).VoteAgg(ctx, req.(*MsgVoteAgg)) + return out, nil +} + +func (c *msgClient) VoteAgg(ctx context.Context, in *MsgVoteAgg, opts ...grpc.CallOption) (*MsgVoteAggResponse, error) { + out := new(MsgVoteAggResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/VoteAgg", in, out, opts...) + if err != nil { + return nil, err } - return interceptor(ctx, in, info, handler) + return out, nil } -func _Msg_Exec_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgExec) - if err := dec(in); err != nil { +func (c *msgClient) Exec(ctx context.Context, in *MsgExec, opts ...grpc.CallOption) (*MsgExecResponse, error) { + out := new(MsgExecResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/Exec", in, out, opts...) + if err != nil { return nil, err } - if interceptor == nil { - return srv.(MsgServer).Exec(ctx, in) + return out, nil +} + +func (c *msgClient) CreatePoll(ctx context.Context, in *MsgCreatePoll, opts ...grpc.CallOption) (*MsgCreatePollResponse, error) { + out := new(MsgCreatePollResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/CreatePoll", in, out, opts...) + if err != nil { + return nil, err } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/regen.group.v1alpha1.Msg/Exec", + return out, nil +} + +func (c *msgClient) VotePoll(ctx context.Context, in *MsgVotePoll, opts ...grpc.CallOption) (*MsgVotePollResponse, error) { + out := new(MsgVotePollResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/VotePoll", in, out, opts...) + if err != nil { + return nil, err } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Exec(ctx, req.(*MsgExec)) + return out, nil +} + +func (c *msgClient) VotePollAgg(ctx context.Context, in *MsgVotePollAgg, opts ...grpc.CallOption) (*MsgVotePollAggResponse, error) { + out := new(MsgVotePollAggResponse) + err := c.cc.Invoke(ctx, "/regen.group.v1alpha1.Msg/VotePollAgg", in, out, opts...) + if err != nil { + return nil, err } - return interceptor(ctx, in, info, handler) + return out, nil } -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "regen.group.v1alpha1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "CreateGroup", - Handler: _Msg_CreateGroup_Handler, - }, - { - MethodName: "UpdateGroupMembers", - Handler: _Msg_UpdateGroupMembers_Handler, - }, - { - MethodName: "UpdateGroupAdmin", - Handler: _Msg_UpdateGroupAdmin_Handler, - }, - { - MethodName: "UpdateGroupMetadata", - Handler: _Msg_UpdateGroupMetadata_Handler, - }, - { - MethodName: "CreateGroupAccount", - Handler: _Msg_CreateGroupAccount_Handler, - }, - { - MethodName: "UpdateGroupAccountAdmin", - Handler: _Msg_UpdateGroupAccountAdmin_Handler, - }, - { - MethodName: "UpdateGroupAccountDecisionPolicy", - Handler: _Msg_UpdateGroupAccountDecisionPolicy_Handler, - }, - { - MethodName: "UpdateGroupAccountMetadata", - Handler: _Msg_UpdateGroupAccountMetadata_Handler, - }, - { - MethodName: "CreateProposal", - Handler: _Msg_CreateProposal_Handler, - }, - { - MethodName: "Vote", - Handler: _Msg_Vote_Handler, - }, - { - MethodName: "VoteAgg", - Handler: _Msg_VoteAgg_Handler, - }, - { - MethodName: "Exec", - Handler: _Msg_Exec_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "regen/group/v1alpha1/tx.proto", +// MsgServer is the server API for Msg service. +type MsgServer interface { + // CreateGroup creates a new group with an admin account address, a list of members and some optional metadata. + CreateGroup(context.Context, *MsgCreateGroup) (*MsgCreateGroupResponse, error) + // UpdateGroupMembers updates the group members with given group id and admin address. + UpdateGroupMembers(context.Context, *MsgUpdateGroupMembers) (*MsgUpdateGroupMembersResponse, error) + // UpdateGroupAdmin updates the group admin with given group id and previous admin address. + UpdateGroupAdmin(context.Context, *MsgUpdateGroupAdmin) (*MsgUpdateGroupAdminResponse, error) + // UpdateGroupMetadata updates the group metadata with given group id and admin address. + UpdateGroupMetadata(context.Context, *MsgUpdateGroupMetadata) (*MsgUpdateGroupMetadataResponse, error) + // CreateGroupAccount creates a new group account using given DecisionPolicy. + CreateGroupAccount(context.Context, *MsgCreateGroupAccount) (*MsgCreateGroupAccountResponse, error) + // UpdateGroupAccountAdmin updates a group account admin. + UpdateGroupAccountAdmin(context.Context, *MsgUpdateGroupAccountAdmin) (*MsgUpdateGroupAccountAdminResponse, error) + // UpdateGroupAccountDecisionPolicy allows a group account decision policy to be updated. + UpdateGroupAccountDecisionPolicy(context.Context, *MsgUpdateGroupAccountDecisionPolicy) (*MsgUpdateGroupAccountDecisionPolicyResponse, error) + // UpdateGroupAccountMetadata updates a group account metadata. + UpdateGroupAccountMetadata(context.Context, *MsgUpdateGroupAccountMetadata) (*MsgUpdateGroupAccountMetadataResponse, error) + // CreateProposal submits a new proposal. + CreateProposal(context.Context, *MsgCreateProposal) (*MsgCreateProposalResponse, error) + // Vote allows a voter to vote on a proposal. + Vote(context.Context, *MsgVote) (*MsgVoteResponse, error) + // VoteAgg allows a sender to submit a set of votes + VoteAgg(context.Context, *MsgVoteAgg) (*MsgVoteAggResponse, error) + // Exec executes a proposal. + Exec(context.Context, *MsgExec) (*MsgExecResponse, error) + // CreatePoll submits a new poll. + CreatePoll(context.Context, *MsgCreatePoll) (*MsgCreatePollResponse, error) + // VotePoll allows a voter to vote on a poll. + VotePoll(context.Context, *MsgVotePoll) (*MsgVotePollResponse, error) + // VotePollAgg allows a sender to submit a set of votes + VotePollAgg(context.Context, *MsgVotePollAgg) (*MsgVotePollAggResponse, error) } -func (m *MsgCreateGroup) 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 +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { } -func (m *MsgCreateGroup) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (*UnimplementedMsgServer) CreateGroup(ctx context.Context, req *MsgCreateGroup) (*MsgCreateGroupResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateGroup not implemented") +} +func (*UnimplementedMsgServer) UpdateGroupMembers(ctx context.Context, req *MsgUpdateGroupMembers) (*MsgUpdateGroupMembersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateGroupMembers not implemented") +} +func (*UnimplementedMsgServer) UpdateGroupAdmin(ctx context.Context, req *MsgUpdateGroupAdmin) (*MsgUpdateGroupAdminResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateGroupAdmin not implemented") +} +func (*UnimplementedMsgServer) UpdateGroupMetadata(ctx context.Context, req *MsgUpdateGroupMetadata) (*MsgUpdateGroupMetadataResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateGroupMetadata not implemented") +} +func (*UnimplementedMsgServer) CreateGroupAccount(ctx context.Context, req *MsgCreateGroupAccount) (*MsgCreateGroupAccountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateGroupAccount not implemented") +} +func (*UnimplementedMsgServer) UpdateGroupAccountAdmin(ctx context.Context, req *MsgUpdateGroupAccountAdmin) (*MsgUpdateGroupAccountAdminResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateGroupAccountAdmin not implemented") +} +func (*UnimplementedMsgServer) UpdateGroupAccountDecisionPolicy(ctx context.Context, req *MsgUpdateGroupAccountDecisionPolicy) (*MsgUpdateGroupAccountDecisionPolicyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateGroupAccountDecisionPolicy not implemented") +} +func (*UnimplementedMsgServer) UpdateGroupAccountMetadata(ctx context.Context, req *MsgUpdateGroupAccountMetadata) (*MsgUpdateGroupAccountMetadataResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateGroupAccountMetadata not implemented") +} +func (*UnimplementedMsgServer) CreateProposal(ctx context.Context, req *MsgCreateProposal) (*MsgCreateProposalResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateProposal not implemented") +} +func (*UnimplementedMsgServer) Vote(ctx context.Context, req *MsgVote) (*MsgVoteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Vote not implemented") +} +func (*UnimplementedMsgServer) VoteAgg(ctx context.Context, req *MsgVoteAgg) (*MsgVoteAggResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VoteAgg not implemented") +} +func (*UnimplementedMsgServer) Exec(ctx context.Context, req *MsgExec) (*MsgExecResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Exec not implemented") +} +func (*UnimplementedMsgServer) CreatePoll(ctx context.Context, req *MsgCreatePoll) (*MsgCreatePollResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreatePoll not implemented") +} +func (*UnimplementedMsgServer) VotePoll(ctx context.Context, req *MsgVotePoll) (*MsgVotePollResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VotePoll not implemented") +} +func (*UnimplementedMsgServer) VotePollAgg(ctx context.Context, req *MsgVotePollAgg) (*MsgVotePollAggResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VotePollAgg not implemented") } -func (m *MsgCreateGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.BlsOnly { - i-- - if m.BlsOnly { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x20 +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_CreateGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateGroup) + if err := dec(in); err != nil { + return nil, err } - if len(m.Metadata) > 0 { - i -= len(m.Metadata) - copy(dAtA[i:], m.Metadata) - i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) - i-- - dAtA[i] = 0x1a + if interceptor == nil { + return srv.(MsgServer).CreateGroup(ctx, in) } - if len(m.Members) > 0 { - for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Members[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/CreateGroup", } - if len(m.Admin) > 0 { - i -= len(m.Admin) - copy(dAtA[i:], m.Admin) - i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) - i-- - dAtA[i] = 0xa + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateGroup(ctx, req.(*MsgCreateGroup)) } - return len(dAtA) - i, nil + return interceptor(ctx, in, info, handler) } -func (m *MsgCreateGroupResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Msg_UpdateGroupMembers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateGroupMembers) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *MsgCreateGroupResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgCreateGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.GroupId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) - i-- - dAtA[i] = 0x8 + if interceptor == nil { + return srv.(MsgServer).UpdateGroupMembers(ctx, in) } - return len(dAtA) - i, nil + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupMembers", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateGroupMembers(ctx, req.(*MsgUpdateGroupMembers)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgUpdateGroupMembers) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Msg_UpdateGroupAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateGroupAdmin) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(MsgServer).UpdateGroupAdmin(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAdmin", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateGroupAdmin(ctx, req.(*MsgUpdateGroupAdmin)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgUpdateGroupMembers) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func _Msg_UpdateGroupMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateGroupMetadata) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateGroupMetadata(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupMetadata", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateGroupMetadata(ctx, req.(*MsgUpdateGroupMetadata)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgUpdateGroupMembers) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.MemberUpdates) > 0 { - for iNdEx := len(m.MemberUpdates) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.MemberUpdates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } +func _Msg_CreateGroupAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateGroupAccount) + if err := dec(in); err != nil { + return nil, err } - if m.GroupId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) - i-- - dAtA[i] = 0x10 + if interceptor == nil { + return srv.(MsgServer).CreateGroupAccount(ctx, in) } - if len(m.Admin) > 0 { - i -= len(m.Admin) - copy(dAtA[i:], m.Admin) - i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) - i-- - dAtA[i] = 0xa + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/CreateGroupAccount", } - return len(dAtA) - i, nil + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateGroupAccount(ctx, req.(*MsgCreateGroupAccount)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgUpdateGroupMembersResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Msg_UpdateGroupAccountAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateGroupAccountAdmin) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *MsgUpdateGroupMembersResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateGroupMembersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil + if interceptor == nil { + return srv.(MsgServer).UpdateGroupAccountAdmin(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAccountAdmin", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateGroupAccountAdmin(ctx, req.(*MsgUpdateGroupAccountAdmin)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgUpdateGroupAdmin) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Msg_UpdateGroupAccountDecisionPolicy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateGroupAccountDecisionPolicy) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *MsgUpdateGroupAdmin) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateGroupAdmin) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.NewAdmin) > 0 { - i -= len(m.NewAdmin) - copy(dAtA[i:], m.NewAdmin) - i = encodeVarintTx(dAtA, i, uint64(len(m.NewAdmin))) - i-- - dAtA[i] = 0x1a + if interceptor == nil { + return srv.(MsgServer).UpdateGroupAccountDecisionPolicy(ctx, in) } - if m.GroupId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) - i-- - dAtA[i] = 0x10 + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAccountDecisionPolicy", } - if len(m.Admin) > 0 { - i -= len(m.Admin) - copy(dAtA[i:], m.Admin) - i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) - i-- - dAtA[i] = 0xa + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateGroupAccountDecisionPolicy(ctx, req.(*MsgUpdateGroupAccountDecisionPolicy)) } - return len(dAtA) - i, nil + return interceptor(ctx, in, info, handler) } -func (m *MsgUpdateGroupAdminResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Msg_UpdateGroupAccountMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateGroupAccountMetadata) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *MsgUpdateGroupAdminResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + if interceptor == nil { + return srv.(MsgServer).UpdateGroupAccountMetadata(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/UpdateGroupAccountMetadata", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateGroupAccountMetadata(ctx, req.(*MsgUpdateGroupAccountMetadata)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgUpdateGroupAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +func _Msg_CreateProposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateProposal) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateProposal(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/CreateProposal", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateProposal(ctx, req.(*MsgCreateProposal)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgUpdateGroupMetadata) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Msg_Vote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgVote) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(MsgServer).Vote(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/Vote", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Vote(ctx, req.(*MsgVote)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgUpdateGroupMetadata) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func _Msg_VoteAgg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgVoteAgg) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).VoteAgg(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/VoteAgg", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).VoteAgg(ctx, req.(*MsgVoteAgg)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgUpdateGroupMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Metadata) > 0 { - i -= len(m.Metadata) - copy(dAtA[i:], m.Metadata) - i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) - i-- - dAtA[i] = 0x1a +func _Msg_Exec_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgExec) + if err := dec(in); err != nil { + return nil, err } - if m.GroupId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) - i-- - dAtA[i] = 0x10 + if interceptor == nil { + return srv.(MsgServer).Exec(ctx, in) } - if len(m.Admin) > 0 { - i -= len(m.Admin) - copy(dAtA[i:], m.Admin) - i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) - i-- - dAtA[i] = 0xa + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/Exec", } - return len(dAtA) - i, nil + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Exec(ctx, req.(*MsgExec)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgUpdateGroupMetadataResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Msg_CreatePoll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreatePoll) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(MsgServer).CreatePoll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/CreatePoll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreatePoll(ctx, req.(*MsgCreatePoll)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgUpdateGroupMetadataResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func _Msg_VotePoll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgVotePoll) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).VotePoll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/VotePoll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).VotePoll(ctx, req.(*MsgVotePoll)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgUpdateGroupMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +func _Msg_VotePollAgg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgVotePollAgg) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).VotePollAgg(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/regen.group.v1alpha1.Msg/VotePollAgg", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).VotePollAgg(ctx, req.(*MsgVotePollAgg)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgCreateGroupAccount) Marshal() (dAtA []byte, err error) { +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "regen.group.v1alpha1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateGroup", + Handler: _Msg_CreateGroup_Handler, + }, + { + MethodName: "UpdateGroupMembers", + Handler: _Msg_UpdateGroupMembers_Handler, + }, + { + MethodName: "UpdateGroupAdmin", + Handler: _Msg_UpdateGroupAdmin_Handler, + }, + { + MethodName: "UpdateGroupMetadata", + Handler: _Msg_UpdateGroupMetadata_Handler, + }, + { + MethodName: "CreateGroupAccount", + Handler: _Msg_CreateGroupAccount_Handler, + }, + { + MethodName: "UpdateGroupAccountAdmin", + Handler: _Msg_UpdateGroupAccountAdmin_Handler, + }, + { + MethodName: "UpdateGroupAccountDecisionPolicy", + Handler: _Msg_UpdateGroupAccountDecisionPolicy_Handler, + }, + { + MethodName: "UpdateGroupAccountMetadata", + Handler: _Msg_UpdateGroupAccountMetadata_Handler, + }, + { + MethodName: "CreateProposal", + Handler: _Msg_CreateProposal_Handler, + }, + { + MethodName: "Vote", + Handler: _Msg_Vote_Handler, + }, + { + MethodName: "VoteAgg", + Handler: _Msg_VoteAgg_Handler, + }, + { + MethodName: "Exec", + Handler: _Msg_Exec_Handler, + }, + { + MethodName: "CreatePoll", + Handler: _Msg_CreatePoll_Handler, + }, + { + MethodName: "VotePoll", + Handler: _Msg_VotePoll_Handler, + }, + { + MethodName: "VotePollAgg", + Handler: _Msg_VotePollAgg_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "regen/group/v1alpha1/tx.proto", +} + +func (m *MsgCreateGroup) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2377,27 +2720,25 @@ func (m *MsgCreateGroupAccount) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateGroupAccount) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateGroup) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateGroupAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.DecisionPolicy != nil { - { - size, err := m.DecisionPolicy.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + if m.BlsOnly { + i-- + if m.BlsOnly { + dAtA[i] = 1 + } else { + dAtA[i] = 0 } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x20 } if len(m.Metadata) > 0 { i -= len(m.Metadata) @@ -2406,10 +2747,19 @@ func (m *MsgCreateGroupAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if m.GroupId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) - i-- - dAtA[i] = 0x10 + if len(m.Members) > 0 { + for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Members[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } } if len(m.Admin) > 0 { i -= len(m.Admin) @@ -2421,7 +2771,7 @@ func (m *MsgCreateGroupAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgCreateGroupAccountResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateGroupResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2431,27 +2781,25 @@ func (m *MsgCreateGroupAccountResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateGroupAccountResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateGroupResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateGroupAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + if m.GroupId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *MsgUpdateGroupAccountAdmin) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateGroupMembers) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2461,29 +2809,34 @@ func (m *MsgUpdateGroupAccountAdmin) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateGroupAccountAdmin) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupMembers) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateGroupAccountAdmin) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupMembers) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.NewAdmin) > 0 { - i -= len(m.NewAdmin) - copy(dAtA[i:], m.NewAdmin) - i = encodeVarintTx(dAtA, i, uint64(len(m.NewAdmin))) - i-- - dAtA[i] = 0x1a + if len(m.MemberUpdates) > 0 { + for iNdEx := len(m.MemberUpdates) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.MemberUpdates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + if m.GroupId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } if len(m.Admin) > 0 { i -= len(m.Admin) @@ -2495,7 +2848,7 @@ func (m *MsgUpdateGroupAccountAdmin) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *MsgUpdateGroupAccountAdminResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateGroupMembersResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2505,12 +2858,12 @@ func (m *MsgUpdateGroupAccountAdminResponse) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *MsgUpdateGroupAccountAdminResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupMembersResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateGroupAccountAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupMembersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2518,7 +2871,7 @@ func (m *MsgUpdateGroupAccountAdminResponse) MarshalToSizedBuffer(dAtA []byte) ( return len(dAtA) - i, nil } -func (m *MsgUpdateGroupAccountDecisionPolicy) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateGroupAdmin) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2528,34 +2881,27 @@ func (m *MsgUpdateGroupAccountDecisionPolicy) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *MsgUpdateGroupAccountDecisionPolicy) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAdmin) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateGroupAccountDecisionPolicy) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAdmin) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.DecisionPolicy != nil { - { - size, err := m.DecisionPolicy.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } + if len(m.NewAdmin) > 0 { + i -= len(m.NewAdmin) + copy(dAtA[i:], m.NewAdmin) + i = encodeVarintTx(dAtA, i, uint64(len(m.NewAdmin))) i-- dAtA[i] = 0x1a } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + if m.GroupId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } if len(m.Admin) > 0 { i -= len(m.Admin) @@ -2567,7 +2913,7 @@ func (m *MsgUpdateGroupAccountDecisionPolicy) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } -func (m *MsgUpdateGroupAccountDecisionPolicyResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateGroupAdminResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2577,12 +2923,12 @@ func (m *MsgUpdateGroupAccountDecisionPolicyResponse) Marshal() (dAtA []byte, er return dAtA[:n], nil } -func (m *MsgUpdateGroupAccountDecisionPolicyResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAdminResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateGroupAccountDecisionPolicyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2590,7 +2936,7 @@ func (m *MsgUpdateGroupAccountDecisionPolicyResponse) MarshalToSizedBuffer(dAtA return len(dAtA) - i, nil } -func (m *MsgUpdateGroupAccountMetadata) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateGroupMetadata) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2600,12 +2946,12 @@ func (m *MsgUpdateGroupAccountMetadata) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateGroupAccountMetadata) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupMetadata) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateGroupAccountMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2617,12 +2963,10 @@ func (m *MsgUpdateGroupAccountMetadata) MarshalToSizedBuffer(dAtA []byte) (int, i-- dAtA[i] = 0x1a } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + if m.GroupId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } if len(m.Admin) > 0 { i -= len(m.Admin) @@ -2634,7 +2978,7 @@ func (m *MsgUpdateGroupAccountMetadata) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *MsgUpdateGroupAccountMetadataResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateGroupMetadataResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2644,12 +2988,12 @@ func (m *MsgUpdateGroupAccountMetadataResponse) Marshal() (dAtA []byte, err erro return dAtA[:n], nil } -func (m *MsgUpdateGroupAccountMetadataResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupMetadataResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateGroupAccountMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2657,7 +3001,7 @@ func (m *MsgUpdateGroupAccountMetadataResponse) MarshalToSizedBuffer(dAtA []byte return len(dAtA) - i, nil } -func (m *MsgCreateProposal) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateGroupAccount) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2667,34 +3011,27 @@ func (m *MsgCreateProposal) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateProposal) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateGroupAccount) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateGroupAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Exec != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Exec)) + if m.DecisionPolicy != nil { + { + size, err := m.DecisionPolicy.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x28 - } - if len(m.Msgs) > 0 { - for iNdEx := len(m.Msgs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Msgs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } + dAtA[i] = 0x22 } if len(m.Metadata) > 0 { i -= len(m.Metadata) @@ -2703,26 +3040,22 @@ func (m *MsgCreateProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if len(m.Proposers) > 0 { - for iNdEx := len(m.Proposers) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Proposers[iNdEx]) - copy(dAtA[i:], m.Proposers[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Proposers[iNdEx]))) - i-- - dAtA[i] = 0x12 - } + if m.GroupId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x10 } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgCreateProposalResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateGroupAccountResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2732,25 +3065,27 @@ func (m *MsgCreateProposalResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateProposalResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateGroupAccountResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateGroupAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.ProposalId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgVote) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateGroupAccountAdmin) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2760,49 +3095,41 @@ func (m *MsgVote) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgVote) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAccountAdmin) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAccountAdmin) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Exec != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Exec)) - i-- - dAtA[i] = 0x28 - } - if len(m.Metadata) > 0 { - i -= len(m.Metadata) - copy(dAtA[i:], m.Metadata) - i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) - i-- - dAtA[i] = 0x22 - } - if m.Choice != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Choice)) + if len(m.NewAdmin) > 0 { + i -= len(m.NewAdmin) + copy(dAtA[i:], m.NewAdmin) + i = encodeVarintTx(dAtA, i, uint64(len(m.NewAdmin))) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x1a } - if len(m.Voter) > 0 { - i -= len(m.Voter) - copy(dAtA[i:], m.Voter) - i = encodeVarintTx(dAtA, i, uint64(len(m.Voter))) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) i-- dAtA[i] = 0x12 } - if m.ProposalId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgVoteResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateGroupAccountAdminResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2812,12 +3139,12 @@ func (m *MsgVoteResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgVoteResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAccountAdminResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAccountAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2825,7 +3152,7 @@ func (m *MsgVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgVoteBasic) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateGroupAccountDecisionPolicy) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2835,40 +3162,46 @@ func (m *MsgVoteBasic) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgVoteBasic) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAccountDecisionPolicy) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgVoteBasic) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAccountDecisionPolicy) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - { - size, err := m.Timeout.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.DecisionPolicy != nil { + { + size, err := m.DecisionPolicy.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a } - i-- - dAtA[i] = 0x1a - if m.Choice != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Choice)) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x12 } - if m.ProposalId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgVoteBasicResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2878,66 +3211,20 @@ func (m *MsgVoteBasicResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgVoteBasicResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgVoteBasicResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Sig) > 0 { - i -= len(m.Sig) - copy(dAtA[i:], m.Sig) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sig))) - i-- - dAtA[i] = 0x32 - } - if m.PubKey != nil { - { - size, err := m.PubKey.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - if len(m.Voter) > 0 { - i -= len(m.Voter) - copy(dAtA[i:], m.Voter) - i = encodeVarintTx(dAtA, i, uint64(len(m.Voter))) - i-- - dAtA[i] = 0x22 - } - { - size, err := m.Timeout.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if m.Choice != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Choice)) - i-- - dAtA[i] = 0x10 - } - if m.ProposalId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) - i-- - dAtA[i] = 0x8 - } return len(dAtA) - i, nil } -func (m *MsgVoteAgg) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateGroupAccountMetadata) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2947,79 +3234,41 @@ func (m *MsgVoteAgg) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgVoteAgg) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAccountMetadata) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgVoteAgg) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAccountMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Exec != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Exec)) - i-- - dAtA[i] = 0x38 - } if len(m.Metadata) > 0 { i -= len(m.Metadata) copy(dAtA[i:], m.Metadata) i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) i-- - dAtA[i] = 0x32 - } - if len(m.AggSig) > 0 { - i -= len(m.AggSig) - copy(dAtA[i:], m.AggSig) - i = encodeVarintTx(dAtA, i, uint64(len(m.AggSig))) - i-- - dAtA[i] = 0x2a - } - { - size, err := m.Timeout.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if len(m.Votes) > 0 { - dAtA8 := make([]byte, len(m.Votes)*10) - var j7 int - for _, num := range m.Votes { - for num >= 1<<7 { - dAtA8[j7] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j7++ - } - dAtA8[j7] = uint8(num) - j7++ - } - i -= j7 - copy(dAtA[i:], dAtA8[:j7]) - i = encodeVarintTx(dAtA, i, uint64(j7)) - i-- dAtA[i] = 0x1a } - if m.ProposalId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x12 } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgVoteAggResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateGroupAccountMetadataResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -3029,12 +3278,12 @@ func (m *MsgVoteAggResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgVoteAggResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAccountMetadataResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgVoteAggResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateGroupAccountMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -3042,7 +3291,7 @@ func (m *MsgVoteAggResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgExec) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateProposal) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -3052,32 +3301,62 @@ func (m *MsgExec) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgExec) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateProposal) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgExec) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + if m.Exec != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Exec)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x28 } - if m.ProposalId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + if len(m.Msgs) > 0 { + for iNdEx := len(m.Msgs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Msgs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) i-- - dAtA[i] = 0x8 + dAtA[i] = 0x1a + } + if len(m.Proposers) > 0 { + for iNdEx := len(m.Proposers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Proposers[iNdEx]) + copy(dAtA[i:], m.Proposers[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Proposers[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgExecResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateProposalResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -3087,486 +3366,2186 @@ func (m *MsgExecResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgExecResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateProposalResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgExecResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if m.ProposalId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *MsgVote) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *MsgCreateGroup) Size() (n int) { - if m == nil { - return 0 - } + +func (m *MsgVote) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.Exec != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Exec)) + i-- + dAtA[i] = 0x28 } - if len(m.Members) > 0 { - for _, e := range m.Members { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x22 } - l = len(m.Metadata) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.Choice != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Choice)) + i-- + dAtA[i] = 0x18 } - if m.BlsOnly { - n += 2 + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x12 } - return n + if m.ProposalId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } -func (m *MsgCreateGroupResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.GroupId != 0 { - n += 1 + sovTx(uint64(m.GroupId)) +func (m *MsgVoteResponse) 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 n + return dAtA[:n], nil } -func (m *MsgUpdateGroupMembers) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.GroupId != 0 { - n += 1 + sovTx(uint64(m.GroupId)) - } - if len(m.MemberUpdates) > 0 { - for _, e := range m.MemberUpdates { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - return n +func (m *MsgVoteResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateGroupMembersResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *MsgVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - return n + return len(dAtA) - i, nil } -func (m *MsgUpdateGroupAdmin) Size() (n int) { - if m == nil { - return 0 +func (m *MsgVoteBasic) 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 *MsgVoteBasic) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVoteBasic) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + { + size, err := m.Expiry.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - if m.GroupId != 0 { - n += 1 + sovTx(uint64(m.GroupId)) + i-- + dAtA[i] = 0x1a + if m.Choice != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Choice)) + i-- + dAtA[i] = 0x10 } - l = len(m.NewAdmin) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.ProposalId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *MsgUpdateGroupAdminResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgVoteBasicResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -func (m *MsgUpdateGroupMetadata) Size() (n int) { - if m == nil { - return 0 - } +func (m *MsgVoteBasicResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVoteBasicResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.GroupId != 0 { - n += 1 + sovTx(uint64(m.GroupId)) + if len(m.Sig) > 0 { + i -= len(m.Sig) + copy(dAtA[i:], m.Sig) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sig))) + i-- + dAtA[i] = 0x32 } - l = len(m.Metadata) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.PubKey != nil { + { + size, err := m.PubKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a } - return n + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x22 + } + { + size, err := m.Expiry.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.Choice != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Choice)) + i-- + dAtA[i] = 0x10 + } + if m.ProposalId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } -func (m *MsgUpdateGroupMetadataResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgVoteAgg) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -func (m *MsgCreateGroupAccount) Size() (n int) { - if m == nil { - return 0 - } +func (m *MsgVoteAgg) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVoteAgg) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.Exec != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Exec)) + i-- + dAtA[i] = 0x38 } - if m.GroupId != 0 { - n += 1 + sovTx(uint64(m.GroupId)) + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x32 } - l = len(m.Metadata) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.AggSig) > 0 { + i -= len(m.AggSig) + copy(dAtA[i:], m.AggSig) + i = encodeVarintTx(dAtA, i, uint64(len(m.AggSig))) + i-- + dAtA[i] = 0x2a } - if m.DecisionPolicy != nil { - l = m.DecisionPolicy.Size() - n += 1 + l + sovTx(uint64(l)) + { + size, err := m.Expiry.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - return n -} - -func (m *MsgCreateGroupAccountResponse) Size() (n int) { - if m == nil { - return 0 + i-- + dAtA[i] = 0x22 + if len(m.Votes) > 0 { + dAtA8 := make([]byte, len(m.Votes)*10) + var j7 int + for _, num := range m.Votes { + for num >= 1<<7 { + dAtA8[j7] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j7++ + } + dAtA8[j7] = uint8(num) + j7++ + } + i -= j7 + copy(dAtA[i:], dAtA8[:j7]) + i = encodeVarintTx(dAtA, i, uint64(j7)) + i-- + dAtA[i] = 0x1a } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.ProposalId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x10 } - return n + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *MsgUpdateGroupAccountAdmin) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Address) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.NewAdmin) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) +func (m *MsgVoteAggResponse) 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 n + return dAtA[:n], nil } -func (m *MsgUpdateGroupAccountAdminResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *MsgVoteAggResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVoteAggResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - return n + return len(dAtA) - i, nil } -func (m *MsgUpdateGroupAccountDecisionPolicy) Size() (n int) { - if m == nil { - return 0 +func (m *MsgExec) 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 *MsgExec) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExec) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Address) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x12 } - if m.DecisionPolicy != nil { - l = m.DecisionPolicy.Size() - n += 1 + l + sovTx(uint64(l)) + if m.ProposalId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ProposalId)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *MsgUpdateGroupAccountDecisionPolicyResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgExecResponse) 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 *MsgExecResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - return n + return len(dAtA) - i, nil } -func (m *MsgUpdateGroupAccountMetadata) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Address) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Metadata) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) +func (m *MsgCreatePoll) 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 n + return dAtA[:n], nil } -func (m *MsgUpdateGroupAccountMetadataResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n +func (m *MsgCreatePoll) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateProposal) Size() (n int) { - if m == nil { - return 0 - } +func (m *MsgCreatePoll) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if len(m.Proposers) > 0 { - for _, s := range m.Proposers { - l = len(s) - n += 1 + l + sovTx(uint64(l)) + { + size, err := m.Timeout.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - l = len(m.Metadata) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + i-- + dAtA[i] = 0x3a + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x32 } - if len(m.Msgs) > 0 { - for _, e := range m.Msgs { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) + if m.VoteLimit != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.VoteLimit)) + i-- + dAtA[i] = 0x28 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x22 + } + { + size, err := m.Options.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - if m.Exec != 0 { - n += 1 + sovTx(uint64(m.Exec)) + i-- + dAtA[i] = 0x1a + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintTx(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0x12 } - return n + if m.GroupId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } -func (m *MsgCreateProposalResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgCreatePollResponse) 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 *MsgCreatePollResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreatePollResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.ProposalId != 0 { - n += 1 + sovTx(uint64(m.ProposalId)) + if m.PollId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *MsgVote) Size() (n int) { - if m == nil { - return 0 +func (m *MsgVotePoll) 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 *MsgVotePoll) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVotePoll) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.ProposalId != 0 { - n += 1 + sovTx(uint64(m.ProposalId)) - } - l = len(m.Voter) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x22 } - if m.Choice != 0 { - n += 1 + sovTx(uint64(m.Choice)) + { + size, err := m.Options.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - l = len(m.Metadata) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + i-- + dAtA[i] = 0x1a + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x12 } - if m.Exec != 0 { - n += 1 + sovTx(uint64(m.Exec)) + if m.PollId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *MsgVoteResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgVotePollResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -func (m *MsgVoteBasic) Size() (n int) { - if m == nil { - return 0 - } +func (m *MsgVotePollResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVotePollResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.ProposalId != 0 { - n += 1 + sovTx(uint64(m.ProposalId)) - } - if m.Choice != 0 { - n += 1 + sovTx(uint64(m.Choice)) - } - l = m.Timeout.Size() - n += 1 + l + sovTx(uint64(l)) - return n + return len(dAtA) - i, nil } -func (m *MsgVoteBasicResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgVotePollBasic) 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 *MsgVotePollBasic) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVotePollBasic) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.ProposalId != 0 { - n += 1 + sovTx(uint64(m.ProposalId)) - } - if m.Choice != 0 { - n += 1 + sovTx(uint64(m.Choice)) - } - l = m.Timeout.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Voter) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + { + size, err := m.Expiry.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - if m.PubKey != nil { - l = m.PubKey.Size() - n += 1 + l + sovTx(uint64(l)) + i-- + dAtA[i] = 0x1a + if len(m.Option) > 0 { + i -= len(m.Option) + copy(dAtA[i:], m.Option) + i = encodeVarintTx(dAtA, i, uint64(len(m.Option))) + i-- + dAtA[i] = 0x12 } - l = len(m.Sig) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.PollId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *MsgVoteAgg) Size() (n int) { - if m == nil { - return 0 +func (m *MsgVotePollBasicResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + return dAtA[:n], nil +} + +func (m *MsgVotePollBasicResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVotePollBasicResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Sig) > 0 { + i -= len(m.Sig) + copy(dAtA[i:], m.Sig) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sig))) + i-- + dAtA[i] = 0x32 } - if m.ProposalId != 0 { - n += 1 + sovTx(uint64(m.ProposalId)) + if m.PubKey != nil { + { + size, err := m.PubKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x22 + } + { + size, err := m.Expiry.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.Options.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.PollId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgVotePollAgg) 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 *MsgVotePollAgg) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVotePollAgg) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x32 + } + if len(m.AggSig) > 0 { + i -= len(m.AggSig) + copy(dAtA[i:], m.AggSig) + i = encodeVarintTx(dAtA, i, uint64(len(m.AggSig))) + i-- + dAtA[i] = 0x2a + } + { + size, err := m.Expiry.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x22 if len(m.Votes) > 0 { - l = 0 - for _, e := range m.Votes { - l += sovTx(uint64(e)) + for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Votes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a } - n += 1 + sovTx(uint64(l)) + l } - l = m.Timeout.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.AggSig) + if m.PollId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgVotePollAggResponse) 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 *MsgVotePollAggResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVotePollAggResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCreateGroup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if len(m.Members) > 0 { + for _, e := range m.Members { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } l = len(m.Metadata) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.Exec != 0 { - n += 1 + sovTx(uint64(m.Exec)) + if m.BlsOnly { + n += 2 + } + return n +} + +func (m *MsgCreateGroupResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovTx(uint64(m.GroupId)) + } + return n +} + +func (m *MsgUpdateGroupMembers) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.GroupId != 0 { + n += 1 + sovTx(uint64(m.GroupId)) + } + if len(m.MemberUpdates) > 0 { + for _, e := range m.MemberUpdates { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgUpdateGroupMembersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateGroupAdmin) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.GroupId != 0 { + n += 1 + sovTx(uint64(m.GroupId)) + } + l = len(m.NewAdmin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateGroupAdminResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateGroupMetadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.GroupId != 0 { + n += 1 + sovTx(uint64(m.GroupId)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateGroupMetadataResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCreateGroupAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.GroupId != 0 { + n += 1 + sovTx(uint64(m.GroupId)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.DecisionPolicy != nil { + l = m.DecisionPolicy.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateGroupAccountResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateGroupAccountAdmin) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.NewAdmin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateGroupAccountAdminResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateGroupAccountDecisionPolicy) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.DecisionPolicy != nil { + l = m.DecisionPolicy.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateGroupAccountMetadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateGroupAccountMetadataResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCreateProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Proposers) > 0 { + for _, s := range m.Proposers { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Msgs) > 0 { + for _, e := range m.Msgs { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + if m.Exec != 0 { + n += 1 + sovTx(uint64(m.Exec)) + } + return n +} + +func (m *MsgCreateProposalResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovTx(uint64(m.ProposalId)) + } + return n +} + +func (m *MsgVote) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovTx(uint64(m.ProposalId)) + } + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Choice != 0 { + n += 1 + sovTx(uint64(m.Choice)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Exec != 0 { + n += 1 + sovTx(uint64(m.Exec)) + } + return n +} + +func (m *MsgVoteResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgVoteBasic) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovTx(uint64(m.ProposalId)) + } + if m.Choice != 0 { + n += 1 + sovTx(uint64(m.Choice)) + } + l = m.Expiry.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgVoteBasicResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovTx(uint64(m.ProposalId)) + } + if m.Choice != 0 { + n += 1 + sovTx(uint64(m.Choice)) + } + l = m.Expiry.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.PubKey != nil { + l = m.PubKey.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Sig) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgVoteAgg) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.ProposalId != 0 { + n += 1 + sovTx(uint64(m.ProposalId)) + } + if len(m.Votes) > 0 { + l = 0 + for _, e := range m.Votes { + l += sovTx(uint64(e)) + } + n += 1 + sovTx(uint64(l)) + l + } + l = m.Expiry.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.AggSig) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Exec != 0 { + n += 1 + sovTx(uint64(m.Exec)) + } + return n +} + +func (m *MsgVoteAggResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgExec) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ProposalId != 0 { + n += 1 + sovTx(uint64(m.ProposalId)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgExecResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCreatePoll) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovTx(uint64(m.GroupId)) + } + l = len(m.Title) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Options.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.VoteLimit != 0 { + n += 1 + sovTx(uint64(m.VoteLimit)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Timeout.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgCreatePollResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovTx(uint64(m.PollId)) + } + return n +} + +func (m *MsgVotePoll) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovTx(uint64(m.PollId)) + } + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Options.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgVotePollResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgVotePollBasic) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovTx(uint64(m.PollId)) + } + l = len(m.Option) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Expiry.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgVotePollBasicResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovTx(uint64(m.PollId)) + } + l = m.Options.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.Expiry.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.PubKey != nil { + l = m.PubKey.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Sig) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgVotePollAgg) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.PollId != 0 { + n += 1 + sovTx(uint64(m.PollId)) + } + if len(m.Votes) > 0 { + for _, e := range m.Votes { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + l = m.Expiry.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.AggSig) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgVotePollAggResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreateGroup) 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 ErrIntOverflowTx + } + 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: MsgCreateGroup: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateGroup: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Members = append(m.Members, Member{}) + if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlsOnly", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.BlsOnly = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateGroupResponse) 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 ErrIntOverflowTx + } + 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: MsgCreateGroupResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateGroupResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupMembers) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupMembers: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupMembers: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MemberUpdates", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MemberUpdates = append(m.MemberUpdates, Member{}) + if err := m.MemberUpdates[len(m.MemberUpdates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupMembersResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupMembersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupMembersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupAdmin) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupAdmin: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupAdmin: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewAdmin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NewAdmin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupAdminResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupAdminResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateGroupMetadata) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupMetadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } - return n -} -func (m *MsgVoteAggResponse) Size() (n int) { - if m == nil { - return 0 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - return n + return nil } - -func (m *MsgExec) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ProposalId != 0 { - n += 1 + sovTx(uint64(m.ProposalId)) - } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) +func (m *MsgUpdateGroupMetadataResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateGroupMetadataResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateGroupMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } - return n -} -func (m *MsgExecResponse) Size() (n int) { - if m == nil { - return 0 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + return nil } -func (m *MsgCreateGroup) Unmarshal(dAtA []byte) error { +func (m *MsgCreateGroupAccount) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3589,10 +5568,10 @@ func (m *MsgCreateGroup) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateGroup: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreateGroupAccount: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateGroup: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreateGroupAccount: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3628,10 +5607,10 @@ func (m *MsgCreateGroup) Unmarshal(dAtA []byte) error { m.Admin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) } - var msglen int + m.GroupId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -3641,26 +5620,11 @@ func (m *MsgCreateGroup) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.GroupId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Members = append(m.Members, Member{}) - if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) @@ -3696,10 +5660,10 @@ func (m *MsgCreateGroup) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BlsOnly", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DecisionPolicy", wireType) } - var v int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -3709,12 +5673,28 @@ func (m *MsgCreateGroup) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - m.BlsOnly = bool(v != 0) + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DecisionPolicy == nil { + m.DecisionPolicy = &types.Any{} + } + if err := m.DecisionPolicy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -3736,7 +5716,7 @@ func (m *MsgCreateGroup) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateGroupResponse) Unmarshal(dAtA []byte) error { +func (m *MsgCreateGroupAccountResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3759,17 +5739,17 @@ func (m *MsgCreateGroupResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateGroupResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreateGroupAccountResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateGroupResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreateGroupAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - m.GroupId = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -3779,11 +5759,24 @@ func (m *MsgCreateGroupResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GroupId |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -3805,7 +5798,7 @@ func (m *MsgCreateGroupResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateGroupMembers) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateGroupAccountAdmin) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3828,10 +5821,10 @@ func (m *MsgUpdateGroupMembers) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateGroupMembers: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateGroupAccountAdmin: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateGroupMembers: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateGroupAccountAdmin: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3867,10 +5860,10 @@ func (m *MsgUpdateGroupMembers) Unmarshal(dAtA []byte) error { m.Admin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - m.GroupId = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -3880,16 +5873,29 @@ func (m *MsgUpdateGroupMembers) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GroupId |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MemberUpdates", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NewAdmin", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -3899,25 +5905,23 @@ func (m *MsgUpdateGroupMembers) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.MemberUpdates = append(m.MemberUpdates, Member{}) - if err := m.MemberUpdates[len(m.MemberUpdates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.NewAdmin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3940,7 +5944,7 @@ func (m *MsgUpdateGroupMembers) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateGroupMembersResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateGroupAccountAdminResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3963,10 +5967,10 @@ func (m *MsgUpdateGroupMembersResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateGroupMembersResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateGroupAccountAdminResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateGroupMembersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateGroupAccountAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -3990,7 +5994,7 @@ func (m *MsgUpdateGroupMembersResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateGroupAdmin) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateGroupAccountDecisionPolicy) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4013,10 +6017,10 @@ func (m *MsgUpdateGroupAdmin) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateGroupAdmin: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateGroupAccountDecisionPolicy: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateGroupAdmin: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateGroupAccountDecisionPolicy: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -4052,10 +6056,10 @@ func (m *MsgUpdateGroupAdmin) Unmarshal(dAtA []byte) error { m.Admin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - m.GroupId = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -4065,16 +6069,29 @@ func (m *MsgUpdateGroupAdmin) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GroupId |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewAdmin", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DecisionPolicy", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -4084,23 +6101,27 @@ func (m *MsgUpdateGroupAdmin) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.NewAdmin = string(dAtA[iNdEx:postIndex]) + if m.DecisionPolicy == nil { + m.DecisionPolicy = &types.Any{} + } + if err := m.DecisionPolicy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -4123,7 +6144,7 @@ func (m *MsgUpdateGroupAdmin) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateGroupAdminResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateGroupAccountDecisionPolicyResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4146,10 +6167,10 @@ func (m *MsgUpdateGroupAdminResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateGroupAdminResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateGroupAccountDecisionPolicyResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateGroupAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateGroupAccountDecisionPolicyResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -4173,7 +6194,7 @@ func (m *MsgUpdateGroupAdminResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateGroupMetadata) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateGroupAccountMetadata) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4196,10 +6217,10 @@ func (m *MsgUpdateGroupMetadata) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateGroupMetadata: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateGroupAccountMetadata: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateGroupMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateGroupAccountMetadata: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -4235,10 +6256,10 @@ func (m *MsgUpdateGroupMetadata) Unmarshal(dAtA []byte) error { m.Admin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - m.GroupId = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -4248,11 +6269,24 @@ func (m *MsgUpdateGroupMetadata) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GroupId |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) @@ -4308,7 +6342,7 @@ func (m *MsgUpdateGroupMetadata) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateGroupMetadataResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateGroupAccountMetadataResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4331,10 +6365,10 @@ func (m *MsgUpdateGroupMetadataResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateGroupMetadataResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateGroupAccountMetadataResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateGroupMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateGroupAccountMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -4358,7 +6392,7 @@ func (m *MsgUpdateGroupMetadataResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateGroupAccount) Unmarshal(dAtA []byte) error { +func (m *MsgCreateProposal) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4381,15 +6415,15 @@ func (m *MsgCreateGroupAccount) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateGroupAccount: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreateProposal: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateGroupAccount: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreateProposal: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4417,13 +6451,13 @@ func (m *MsgCreateGroupAccount) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Admin = string(dAtA[iNdEx:postIndex]) + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proposers", wireType) } - m.GroupId = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -4433,11 +6467,24 @@ func (m *MsgCreateGroupAccount) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GroupId |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proposers = append(m.Proposers, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) @@ -4474,7 +6521,7 @@ func (m *MsgCreateGroupAccount) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DecisionPolicy", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Msgs", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4501,13 +6548,30 @@ func (m *MsgCreateGroupAccount) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.DecisionPolicy == nil { - m.DecisionPolicy = &types.Any{} - } - if err := m.DecisionPolicy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Msgs = append(m.Msgs, &types.Any{}) + if err := m.Msgs[len(m.Msgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Exec", wireType) + } + m.Exec = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Exec |= Exec(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -4529,7 +6593,7 @@ func (m *MsgCreateGroupAccount) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateGroupAccountResponse) Unmarshal(dAtA []byte) error { +func (m *MsgCreateProposalResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4552,17 +6616,17 @@ func (m *MsgCreateGroupAccountResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateGroupAccountResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreateProposalResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateGroupAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreateProposalResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) } - var stringLen uint64 + m.ProposalId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -4572,24 +6636,11 @@ func (m *MsgCreateGroupAccountResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ProposalId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -4611,7 +6662,7 @@ func (m *MsgCreateGroupAccountResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateGroupAccountAdmin) Unmarshal(dAtA []byte) error { +func (m *MsgVote) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4634,15 +6685,34 @@ func (m *MsgUpdateGroupAccountAdmin) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateGroupAccountAdmin: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVote: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateGroupAccountAdmin: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVote: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4670,13 +6740,32 @@ func (m *MsgUpdateGroupAccountAdmin) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Admin = string(dAtA[iNdEx:postIndex]) + m.Voter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Choice", wireType) + } + m.Choice = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Choice |= Choice(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -4686,29 +6775,31 @@ func (m *MsgUpdateGroupAccountAdmin) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewAdmin", wireType) + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Exec", wireType) } - var stringLen uint64 + m.Exec = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -4718,24 +6809,61 @@ func (m *MsgUpdateGroupAccountAdmin) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.Exec |= Exec(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err } - postIndex := iNdEx + intStringLen - if postIndex < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } - if postIndex > l { + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgVoteResponse) 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 ErrIntOverflowTx + } + if iNdEx >= l { return io.ErrUnexpectedEOF } - m.NewAdmin = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex + 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: MsgVoteResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgVoteResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -4757,7 +6885,7 @@ func (m *MsgUpdateGroupAccountAdmin) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateGroupAccountAdminResponse) Unmarshal(dAtA []byte) error { +func (m *MsgVoteBasic) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4780,12 +6908,83 @@ func (m *MsgUpdateGroupAccountAdminResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateGroupAccountAdminResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVoteBasic: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateGroupAccountAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVoteBasic: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Choice", wireType) + } + m.Choice = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Choice |= Choice(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expiry", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Expiry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -4807,7 +7006,7 @@ func (m *MsgUpdateGroupAccountAdminResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateGroupAccountDecisionPolicy) Unmarshal(dAtA []byte) error { +func (m *MsgVoteBasicResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4830,17 +7029,55 @@ func (m *MsgUpdateGroupAccountDecisionPolicy) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateGroupAccountDecisionPolicy: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVoteBasicResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateGroupAccountDecisionPolicy: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVoteBasicResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Choice", wireType) + } + m.Choice = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Choice |= Choice(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Expiry", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -4850,27 +7087,28 @@ func (m *MsgUpdateGroupAccountDecisionPolicy) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Admin = string(dAtA[iNdEx:postIndex]) + if err := m.Expiry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 2: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4898,11 +7136,11 @@ func (m *MsgUpdateGroupAccountDecisionPolicy) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.Voter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DecisionPolicy", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4929,13 +7167,47 @@ func (m *MsgUpdateGroupAccountDecisionPolicy) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.DecisionPolicy == nil { - m.DecisionPolicy = &types.Any{} + if m.PubKey == nil { + m.PubKey = &types.Any{} } - if err := m.DecisionPolicy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sig", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sig = append(m.Sig[:0], dAtA[iNdEx:postIndex]...) + if m.Sig == nil { + m.Sig = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -4957,7 +7229,7 @@ func (m *MsgUpdateGroupAccountDecisionPolicy) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateGroupAccountDecisionPolicyResponse) Unmarshal(dAtA []byte) error { +func (m *MsgVoteAgg) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4980,67 +7252,137 @@ func (m *MsgUpdateGroupAccountDecisionPolicyResponse) Unmarshal(dAtA []byte) err fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateGroupAccountDecisionPolicyResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVoteAgg: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateGroupAccountDecisionPolicyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVoteAgg: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx } - if (iNdEx + skippy) > l { + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { return io.ErrUnexpectedEOF } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateGroupAccountMetadata) 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 ErrIntOverflowTx + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) } - if iNdEx >= l { - return io.ErrUnexpectedEOF + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + case 3: + if wireType == 0 { + var v Choice + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= Choice(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Votes = append(m.Votes, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + if elementCount != 0 && len(m.Votes) == 0 { + m.Votes = make([]Choice, 0, elementCount) + } + for iNdEx < postIndex { + var v Choice + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= Choice(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Votes = append(m.Votes, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Votes", wireType) } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateGroupAccountMetadata: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateGroupAccountMetadata: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Expiry", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -5050,29 +7392,30 @@ func (m *MsgUpdateGroupAccountMetadata) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Admin = string(dAtA[iNdEx:postIndex]) + if err := m.Expiry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 2: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AggSig", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -5082,25 +7425,27 @@ func (m *MsgUpdateGroupAccountMetadata) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.AggSig = append(m.AggSig[:0], dAtA[iNdEx:postIndex]...) + if m.AggSig == nil { + m.AggSig = []byte{} + } iNdEx = postIndex - case 3: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) } @@ -5134,6 +7479,25 @@ func (m *MsgUpdateGroupAccountMetadata) Unmarshal(dAtA []byte) error { m.Metadata = []byte{} } iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Exec", wireType) + } + m.Exec = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Exec |= Exec(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -5155,7 +7519,7 @@ func (m *MsgUpdateGroupAccountMetadata) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateGroupAccountMetadataResponse) Unmarshal(dAtA []byte) error { +func (m *MsgVoteAggResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5178,10 +7542,10 @@ func (m *MsgUpdateGroupAccountMetadataResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateGroupAccountMetadataResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVoteAggResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateGroupAccountMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVoteAggResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -5205,7 +7569,7 @@ func (m *MsgUpdateGroupAccountMetadataResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateProposal) Unmarshal(dAtA []byte) error { +func (m *MsgExec) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5228,17 +7592,17 @@ func (m *MsgCreateProposal) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateProposal: wiretype end group for non-group") + return fmt.Errorf("proto: MsgExec: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateProposal: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgExec: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) } - var stringLen uint64 + m.ProposalId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -5248,27 +7612,14 @@ func (m *MsgCreateProposal) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ProposalId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proposers", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5280,111 +7631,24 @@ func (m *MsgCreateProposal) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Proposers = append(m.Proposers, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) - if m.Metadata == nil { - m.Metadata = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Msgs", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Msgs = append(m.Msgs, &types.Any{}) - if err := m.Msgs[len(m.Msgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Signer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Exec", wireType) - } - m.Exec = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Exec |= Exec(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -5406,7 +7670,7 @@ func (m *MsgCreateProposal) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateProposalResponse) Unmarshal(dAtA []byte) error { +func (m *MsgExecResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5429,31 +7693,12 @@ func (m *MsgCreateProposalResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateProposalResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgExecResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateProposalResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgExecResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) - } - m.ProposalId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ProposalId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -5475,7 +7720,7 @@ func (m *MsgCreateProposalResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgVote) Unmarshal(dAtA []byte) error { +func (m *MsgCreatePoll) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5498,17 +7743,17 @@ func (m *MsgVote) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgVote: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreatePoll: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgVote: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreatePoll: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) } - m.ProposalId = 0 + m.GroupId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -5518,14 +7763,14 @@ func (m *MsgVote) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProposalId |= uint64(b&0x7F) << shift + m.GroupId |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5553,13 +7798,13 @@ func (m *MsgVote) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Voter = string(dAtA[iNdEx:postIndex]) + m.Title = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Choice", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) } - m.Choice = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -5569,12 +7814,77 @@ func (m *MsgVote) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Choice |= Choice(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Options.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VoteLimit", wireType) + } + m.VoteLimit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VoteLimit |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) } @@ -5608,11 +7918,11 @@ func (m *MsgVote) Unmarshal(dAtA []byte) error { m.Metadata = []byte{} } iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Exec", wireType) + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) } - m.Exec = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -5622,11 +7932,25 @@ func (m *MsgVote) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Exec |= Exec(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -5648,7 +7972,7 @@ func (m *MsgVote) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgVoteResponse) Unmarshal(dAtA []byte) error { +func (m *MsgCreatePollResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5671,12 +7995,31 @@ func (m *MsgVoteResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgVoteResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreatePollResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgVoteResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreatePollResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) + } + m.PollId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PollId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -5698,7 +8041,7 @@ func (m *MsgVoteResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgVoteBasic) Unmarshal(dAtA []byte) error { +func (m *MsgVotePoll) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5721,17 +8064,17 @@ func (m *MsgVoteBasic) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgVoteBasic: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVotePoll: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgVoteBasic: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVotePoll: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) } - m.ProposalId = 0 + m.PollId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -5741,16 +8084,16 @@ func (m *MsgVoteBasic) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProposalId |= uint64(b&0x7F) << shift + m.PollId |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Choice", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) } - m.Choice = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -5760,14 +8103,27 @@ func (m *MsgVoteBasic) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Choice |= Choice(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Voter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -5784,20 +8140,104 @@ func (m *MsgVoteBasic) Unmarshal(dAtA []byte) error { break } } - if msglen < 0 { + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Options.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF } - if postIndex > l { + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgVotePollResponse) 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 ErrIntOverflowTx + } + if iNdEx >= l { return io.ErrUnexpectedEOF } - if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - iNdEx = postIndex + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgVotePollResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgVotePollResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -5819,7 +8259,7 @@ func (m *MsgVoteBasic) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgVoteBasicResponse) Unmarshal(dAtA []byte) error { +func (m *MsgVotePollBasic) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5842,17 +8282,17 @@ func (m *MsgVoteBasicResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgVoteBasicResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVotePollBasic: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgVoteBasicResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVotePollBasic: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) } - m.ProposalId = 0 + m.PollId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -5862,66 +8302,14 @@ func (m *MsgVoteBasicResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProposalId |= uint64(b&0x7F) << shift + m.PollId |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Choice", wireType) - } - m.Choice = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Choice |= Choice(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Option", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5949,11 +8337,11 @@ func (m *MsgVoteBasicResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Voter = string(dAtA[iNdEx:postIndex]) + m.Option = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Expiry", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -5980,47 +8368,10 @@ func (m *MsgVoteBasicResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.PubKey == nil { - m.PubKey = &types.Any{} - } - if err := m.PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Expiry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sig", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sig = append(m.Sig[:0], dAtA[iNdEx:postIndex]...) - if m.Sig == nil { - m.Sig = []byte{} - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -6042,7 +8393,7 @@ func (m *MsgVoteBasicResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgVoteAgg) Unmarshal(dAtA []byte) error { +func (m *MsgVotePollBasicResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -6065,17 +8416,17 @@ func (m *MsgVoteAgg) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgVoteAgg: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVotePollBasicResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgVoteAgg: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVotePollBasicResponse: 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) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) } - var stringLen uint64 + m.PollId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -6085,29 +8436,16 @@ func (m *MsgVoteAgg) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.PollId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) } - m.ProposalId = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -6117,83 +8455,28 @@ func (m *MsgVoteAgg) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProposalId |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 3: - if wireType == 0 { - var v Choice - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= Choice(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Votes = append(m.Votes, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - if elementCount != 0 && len(m.Votes) == 0 { - m.Votes = make([]Choice, 0, elementCount) - } - for iNdEx < postIndex { - var v Choice - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= Choice(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Votes = append(m.Votes, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field Votes", wireType) + if msglen < 0 { + return ErrInvalidLengthTx } - case 4: + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Options.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Expiry", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -6220,15 +8503,15 @@ func (m *MsgVoteAgg) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Expiry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 5: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AggSig", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -6238,31 +8521,29 @@ func (m *MsgVoteAgg) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.AggSig = append(m.AggSig[:0], dAtA[iNdEx:postIndex]...) - if m.AggSig == nil { - m.AggSig = []byte{} - } + m.Voter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -6272,31 +8553,33 @@ func (m *MsgVoteAgg) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) - if m.Metadata == nil { - m.Metadata = []byte{} + if m.PubKey == nil { + m.PubKey = &types.Any{} + } + if err := m.PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Exec", wireType) + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sig", wireType) } - m.Exec = 0 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -6306,11 +8589,26 @@ func (m *MsgVoteAgg) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Exec |= Exec(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sig = append(m.Sig[:0], dAtA[iNdEx:postIndex]...) + if m.Sig == nil { + m.Sig = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -6332,7 +8630,7 @@ func (m *MsgVoteAgg) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgVoteAggResponse) Unmarshal(dAtA []byte) error { +func (m *MsgVotePollAgg) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -6355,67 +8653,102 @@ func (m *MsgVoteAggResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgVoteAggResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVotePollAgg: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgVoteAggResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVotePollAgg: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx } - if (iNdEx + skippy) > l { + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { return io.ErrUnexpectedEOF } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgExec) 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 ErrIntOverflowTx + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) } - if iNdEx >= l { + m.PollId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PollId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Votes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.Votes = append(m.Votes, Options{}) + if err := m.Votes[len(m.Votes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgExec: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgExec: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expiry", wireType) } - m.ProposalId = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -6425,16 +8758,30 @@ func (m *MsgExec) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProposalId |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 2: + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Expiry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AggSig", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -6444,23 +8791,59 @@ func (m *MsgExec) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Signer = string(dAtA[iNdEx:postIndex]) + m.AggSig = append(m.AggSig[:0], dAtA[iNdEx:postIndex]...) + if m.AggSig == nil { + m.AggSig = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex @@ -6483,7 +8866,7 @@ func (m *MsgExec) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgExecResponse) Unmarshal(dAtA []byte) error { +func (m *MsgVotePollAggResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -6506,10 +8889,10 @@ func (m *MsgExecResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgExecResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVotePollAggResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgExecResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVotePollAggResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/x/group/types.go b/x/group/types.go index 91635c690f..1160a041e2 100644 --- a/x/group/types.go +++ b/x/group/types.go @@ -5,10 +5,10 @@ import ( "time" "github.com/cockroachdb/apd/v2" + "github.com/cosmos/cosmos-sdk/regen/orm" + "github.com/cosmos/cosmos-sdk/regen/types/math" proto "github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/types" - "github.com/cosmos/cosmos-sdk/regen/types/math" - "github.com/cosmos/cosmos-sdk/regen/orm" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -282,6 +282,40 @@ func ChoiceFromString(str string) (Choice, error) { // for various entities within the group module // TODO: This could be used as params once x/params is upgraded to use protobuf const MaxMetadataLength = 255 +const MaxTitleLength = 255 +const MaxOptionLength = 127 + +// assertMetadataLength returns an error if given metadata length +// is greater than a fixed maxMetadataLength. +func assertMetadataLength(metadata []byte, description string) error { + if len(metadata) > MaxMetadataLength { + return sdkerrors.Wrap(ErrMaxLimit, description) + } + return nil +} + +// assertTitleLength returns an error if given title length +// is greater than a fixed maxTitleLength. +func assertTitleLength(title string, description string) error { + if len(title) > MaxTitleLength { + return sdkerrors.Wrap(ErrMaxLimit, description) + } + return nil +} + +// assertOptionsLength returns an error if the length of options +// is greater than a fixed maxOptionLength or the lenght of any option is greater than a fixed MaxTitleLength. +func assertOptionsLength(options Options, description string) error { + if len(options.Titles) > MaxOptionLength { + return sdkerrors.Wrapf(ErrMaxLimit, "%s: %s", description, "number of option titles") + } + for _, t := range options.Titles { + if len(t) > MaxTitleLength { + return sdkerrors.Wrapf(ErrMaxLimit, "%s: %s", description, "option title length") + } + } + return nil +} var _ orm.Validateable = GroupInfo{} @@ -322,6 +356,45 @@ func (g GroupMember) ValidateBasic() error { return nil } +func (v VotePoll) PrimaryKeyFields() []interface{} { + return []interface{}{v.PollId, v.Voter} +} + +var _ orm.Validateable = VotePoll{} + +func (v VotePoll) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(v.Voter) + if err != nil { + return sdkerrors.Wrap(err, "voter") + } + + if v.PollId == 0 { + return sdkerrors.Wrap(ErrEmpty, "poll") + } + + if err := assertMetadataLength(v.Metadata, "metadata"); err != nil { + return err + } + + if err := assertOptionsLength(v.Options, "vote options"); err != nil { + return err + } + + if err := v.Options.ValidateBasic(); err != nil { + return err + } + + t, err := types.TimestampFromProto(&v.SubmittedAt) + if err != nil { + return sdkerrors.Wrap(err, "submitted at") + } + if t.IsZero() { + return sdkerrors.Wrap(ErrEmpty, "submitted at") + } + + return nil +} + func (t *Tally) Sub(vote Vote, weight string) error { if err := t.operation(vote, weight, math.SafeSub); err != nil { return err @@ -479,6 +552,48 @@ func (t Tally) ValidateBasic() error { return nil } +func (t *TallyPoll) Sub(vote VotePoll, weight string) error { + if err := t.operation(vote, weight, math.SafeSub); err != nil { + return err + } + return nil +} + +func (t *TallyPoll) Add(vote VotePoll, weight string) error { + if err := t.operation(vote, weight, math.Add); err != nil { + return err + } + return nil +} + +func (t *TallyPoll) operation(vote VotePoll, weight string, op operation) error { + weightDec, err := math.ParsePositiveDecimal(weight) + if err != nil { + return err + } + + for _, option := range vote.Options.Titles { + res, err := math.ParseNonNegativeDecimal("0") + if err != nil { + return err + } + if x, ok := t.Counts[option]; ok { + res, err = math.ParseNonNegativeDecimal(x) + if err != nil { + return err + } + } + err = op(res, res, weightDec) + if err != nil { + return sdkerrors.Wrap(err, "count") + } + + t.Counts[option] = math.DecimalString(res) + } + + return nil +} + // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (q QueryGroupAccountsByGroupResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { return unpackGroupAccounts(unpacker, q.GroupAccounts) diff --git a/x/group/types.pb.go b/x/group/types.pb.go index 2131bb0aa9..5a0b89a281 100644 --- a/x/group/types.pb.go +++ b/x/group/types.pb.go @@ -175,6 +175,42 @@ func (Proposal_ExecutorResult) EnumDescriptor() ([]byte, []int) { return fileDescriptor_9b7906b115009838, []int{6, 2} } +// Status defines poll statuses. +type Poll_Status int32 + +const ( + // An empty value is invalid and not allowed. + PollStatusInvalid Poll_Status = 0 + // Initial status of a poll when persisted. + PollStatusSubmitted Poll_Status = 1 + // Final status of a poll when the final tally was executed. + PollStatusClosed Poll_Status = 2 + // Final status of a poll when the group was modified before the final tally. + PollStatusAborted Poll_Status = 3 +) + +var Poll_Status_name = map[int32]string{ + 0: "STATUS_UNSPECIFIED", + 1: "STATUS_SUBMITTED", + 2: "STATUS_CLOSED", + 3: "STATUS_ABORTED", +} + +var Poll_Status_value = map[string]int32{ + "STATUS_UNSPECIFIED": 0, + "STATUS_SUBMITTED": 1, + "STATUS_CLOSED": 2, + "STATUS_ABORTED": 3, +} + +func (x Poll_Status) String() string { + return proto.EnumName(Poll_Status_name, int32(x)) +} + +func (Poll_Status) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{11, 0} +} + // Member represents a group member with an account address, // non-zero weight and metadata. type Member struct { @@ -742,11 +778,227 @@ func (m *Vote) GetSubmittedAt() types.Timestamp { return types.Timestamp{} } +// TallyPoll represents the sum of weighted votes for a poll. +type TallyPoll struct { + Counts map[string]string `protobuf:"bytes,1,rep,name=counts,proto3" json:"counts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *TallyPoll) Reset() { *m = TallyPoll{} } +func (m *TallyPoll) String() string { return proto.CompactTextString(m) } +func (*TallyPoll) ProtoMessage() {} +func (*TallyPoll) Descriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{9} +} +func (m *TallyPoll) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TallyPoll) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TallyPoll.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 *TallyPoll) XXX_Merge(src proto.Message) { + xxx_messageInfo_TallyPoll.Merge(m, src) +} +func (m *TallyPoll) XXX_Size() int { + return m.Size() +} +func (m *TallyPoll) XXX_DiscardUnknown() { + xxx_messageInfo_TallyPoll.DiscardUnknown(m) +} + +var xxx_messageInfo_TallyPoll proto.InternalMessageInfo + +type Options struct { + Titles []string `protobuf:"bytes,1,rep,name=titles,proto3" json:"titles,omitempty"` +} + +func (m *Options) Reset() { *m = Options{} } +func (m *Options) String() string { return proto.CompactTextString(m) } +func (*Options) ProtoMessage() {} +func (*Options) Descriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{10} +} +func (m *Options) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Options) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Options.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 *Options) XXX_Merge(src proto.Message) { + xxx_messageInfo_Options.Merge(m, src) +} +func (m *Options) XXX_Size() int { + return m.Size() +} +func (m *Options) XXX_DiscardUnknown() { + xxx_messageInfo_Options.DiscardUnknown(m) +} + +var xxx_messageInfo_Options proto.InternalMessageInfo + +type Poll struct { + // poll_id is the unique id of the poll. + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` + // group_id is the unique ID of the group. + GroupId uint64 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"` + Options Options `protobuf:"bytes,4,opt,name=options,proto3" json:"options"` + Creator string `protobuf:"bytes,5,opt,name=creator,proto3" json:"creator,omitempty"` + VoteLimit int32 `protobuf:"varint,6,opt,name=vote_limit,json=voteLimit,proto3" json:"vote_limit,omitempty"` + // vote_state contains the sums of all weighted votes for this poll. + VoteState TallyPoll `protobuf:"bytes,7,opt,name=vote_state,json=voteState,proto3" json:"vote_state"` + // metadata is any arbitrary metadata to attached to the proposal. + Metadata []byte `protobuf:"bytes,8,opt,name=metadata,proto3" json:"metadata,omitempty"` + // submitted_at is a timestamp specifying when a proposal was submitted. + SubmittedAt types.Timestamp `protobuf:"bytes,9,opt,name=submitted_at,json=submittedAt,proto3" json:"submitted_at"` + // group_version tracks the version of the group that this proposal corresponds to. + // When group membership is changed, existing proposals from previous group versions will become invalid. + GroupVersion uint64 `protobuf:"varint,10,opt,name=group_version,json=groupVersion,proto3" json:"group_version,omitempty"` + // Status represents the high level position in the life cycle of the proposal. Initial value is Submitted. + Status Poll_Status `protobuf:"varint,11,opt,name=status,proto3,enum=regen.group.v1alpha1.Poll_Status" json:"status,omitempty"` + // timeout is the timestamp of the block where the poll times out. Header times of the votes + // must be before this end time to be included in the election. + Timeout types.Timestamp `protobuf:"bytes,12,opt,name=timeout,proto3" json:"timeout"` +} + +func (m *Poll) Reset() { *m = Poll{} } +func (m *Poll) String() string { return proto.CompactTextString(m) } +func (*Poll) ProtoMessage() {} +func (*Poll) Descriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{11} +} +func (m *Poll) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Poll) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Poll.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 *Poll) XXX_Merge(src proto.Message) { + xxx_messageInfo_Poll.Merge(m, src) +} +func (m *Poll) XXX_Size() int { + return m.Size() +} +func (m *Poll) XXX_DiscardUnknown() { + xxx_messageInfo_Poll.DiscardUnknown(m) +} + +var xxx_messageInfo_Poll proto.InternalMessageInfo + +// VotePoll represents a vote for a poll. +type VotePoll struct { + // poll_id is the unique ID of the pool. + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` + // voter is the account address of the voter. + Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"` + // options are the voter's choices on the poll. + Options Options `protobuf:"bytes,3,opt,name=options,proto3" json:"options"` + // metadata is any arbitrary metadata to attached to the vote. + Metadata []byte `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"` + // submitted_at is the timestamp when the vote was submitted. + SubmittedAt types.Timestamp `protobuf:"bytes,5,opt,name=submitted_at,json=submittedAt,proto3" json:"submitted_at"` +} + +func (m *VotePoll) Reset() { *m = VotePoll{} } +func (m *VotePoll) String() string { return proto.CompactTextString(m) } +func (*VotePoll) ProtoMessage() {} +func (*VotePoll) Descriptor() ([]byte, []int) { + return fileDescriptor_9b7906b115009838, []int{12} +} +func (m *VotePoll) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VotePoll) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VotePoll.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 *VotePoll) XXX_Merge(src proto.Message) { + xxx_messageInfo_VotePoll.Merge(m, src) +} +func (m *VotePoll) XXX_Size() int { + return m.Size() +} +func (m *VotePoll) XXX_DiscardUnknown() { + xxx_messageInfo_VotePoll.DiscardUnknown(m) +} + +var xxx_messageInfo_VotePoll proto.InternalMessageInfo + +func (m *VotePoll) GetPollId() uint64 { + if m != nil { + return m.PollId + } + return 0 +} + +func (m *VotePoll) GetVoter() string { + if m != nil { + return m.Voter + } + return "" +} + +func (m *VotePoll) GetOptions() Options { + if m != nil { + return m.Options + } + return Options{} +} + +func (m *VotePoll) GetMetadata() []byte { + if m != nil { + return m.Metadata + } + return nil +} + +func (m *VotePoll) GetSubmittedAt() types.Timestamp { + if m != nil { + return m.SubmittedAt + } + return types.Timestamp{} +} + func init() { proto.RegisterEnum("regen.group.v1alpha1.Choice", Choice_name, Choice_value) proto.RegisterEnum("regen.group.v1alpha1.Proposal_Status", Proposal_Status_name, Proposal_Status_value) proto.RegisterEnum("regen.group.v1alpha1.Proposal_Result", Proposal_Result_name, Proposal_Result_value) proto.RegisterEnum("regen.group.v1alpha1.Proposal_ExecutorResult", Proposal_ExecutorResult_name, Proposal_ExecutorResult_value) + proto.RegisterEnum("regen.group.v1alpha1.Poll_Status", Poll_Status_name, Poll_Status_value) proto.RegisterType((*Member)(nil), "regen.group.v1alpha1.Member") proto.RegisterType((*Members)(nil), "regen.group.v1alpha1.Members") proto.RegisterType((*ThresholdDecisionPolicy)(nil), "regen.group.v1alpha1.ThresholdDecisionPolicy") @@ -756,93 +1008,116 @@ func init() { proto.RegisterType((*Proposal)(nil), "regen.group.v1alpha1.Proposal") proto.RegisterType((*Tally)(nil), "regen.group.v1alpha1.Tally") proto.RegisterType((*Vote)(nil), "regen.group.v1alpha1.Vote") + proto.RegisterType((*TallyPoll)(nil), "regen.group.v1alpha1.TallyPoll") + proto.RegisterMapType((map[string]string)(nil), "regen.group.v1alpha1.TallyPoll.CountsEntry") + proto.RegisterType((*Options)(nil), "regen.group.v1alpha1.Options") + proto.RegisterType((*Poll)(nil), "regen.group.v1alpha1.Poll") + proto.RegisterType((*VotePoll)(nil), "regen.group.v1alpha1.VotePoll") } func init() { proto.RegisterFile("regen/group/v1alpha1/types.proto", fileDescriptor_9b7906b115009838) } var fileDescriptor_9b7906b115009838 = []byte{ - // 1293 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0xda, 0x8e, 0xff, 0x3c, 0x3b, 0x8e, 0x35, 0xa4, 0xad, 0xe3, 0xa4, 0xce, 0xd6, 0xa5, - 0x52, 0x04, 0x8a, 0xad, 0x04, 0x38, 0x10, 0xd1, 0x0a, 0x7b, 0xb3, 0x29, 0x86, 0xd4, 0x0e, 0xbb, - 0x76, 0x80, 0x1e, 0xb0, 0xd6, 0xbb, 0x53, 0x67, 0xe9, 0x7a, 0xc7, 0xda, 0x1d, 0x87, 0x9a, 0x0f, - 0x80, 0x8a, 0x4f, 0xdc, 0x10, 0x07, 0x4b, 0x95, 0xf8, 0x02, 0x1c, 0xf8, 0x10, 0x15, 0xa7, 0x0a, - 0x71, 0x40, 0x1c, 0x10, 0x6a, 0x2f, 0x5c, 0xf8, 0x0e, 0x68, 0x67, 0x66, 0x93, 0xb8, 0x71, 0xdc, - 0x1e, 0x38, 0xd9, 0x6f, 0xe6, 0xf7, 0x7b, 0x7f, 0x7e, 0xef, 0xed, 0xcc, 0x80, 0xec, 0xe1, 0x1e, - 0x76, 0x2b, 0x3d, 0x8f, 0x0c, 0x07, 0x95, 0x93, 0x6d, 0xc3, 0x19, 0x1c, 0x1b, 0xdb, 0x15, 0x3a, - 0x1a, 0x60, 0xbf, 0x3c, 0xf0, 0x08, 0x25, 0x68, 0x85, 0x21, 0xca, 0x0c, 0x51, 0x0e, 0x11, 0x85, - 0x95, 0x1e, 0xe9, 0x11, 0x06, 0xa8, 0x04, 0xff, 0x38, 0xb6, 0x50, 0xec, 0x11, 0xd2, 0x73, 0x70, - 0x85, 0x59, 0xdd, 0xe1, 0x83, 0x8a, 0x35, 0xf4, 0x0c, 0x6a, 0x13, 0x57, 0xec, 0x6f, 0xbc, 0xbc, - 0x4f, 0xed, 0x3e, 0xf6, 0xa9, 0xd1, 0x1f, 0x08, 0x40, 0xc6, 0x24, 0x7e, 0x9f, 0x88, 0xd0, 0x85, - 0xd5, 0x97, 0xe1, 0x86, 0x3b, 0xe2, 0x5b, 0xa5, 0x23, 0x88, 0xdf, 0xc3, 0xfd, 0x2e, 0xf6, 0x50, - 0x1e, 0x12, 0x86, 0x65, 0x79, 0xd8, 0xf7, 0xf3, 0x92, 0x2c, 0x6d, 0xa6, 0xb4, 0xd0, 0x44, 0x57, - 0x21, 0xfe, 0x35, 0xb6, 0x7b, 0xc7, 0x34, 0x1f, 0x61, 0x1b, 0xc2, 0x42, 0x05, 0x48, 0xf6, 0x31, - 0x35, 0x2c, 0x83, 0x1a, 0xf9, 0xa8, 0x2c, 0x6d, 0x66, 0xb4, 0x53, 0xbb, 0x74, 0x17, 0x12, 0xdc, - 0xaf, 0x8f, 0x3e, 0x80, 0x44, 0x9f, 0xff, 0xcd, 0x4b, 0x72, 0x74, 0x33, 0xbd, 0xb3, 0x5e, 0x9e, - 0x25, 0x45, 0x99, 0xe3, 0x6b, 0xb1, 0xa7, 0x7f, 0x6d, 0x2c, 0x68, 0x21, 0xa5, 0xf4, 0xad, 0x04, - 0xd7, 0x5a, 0xc7, 0x1e, 0xf6, 0x8f, 0x89, 0x63, 0xed, 0x61, 0xd3, 0xf6, 0x6d, 0xe2, 0x1e, 0x12, - 0xc7, 0x36, 0x47, 0x68, 0x1d, 0x52, 0x34, 0xdc, 0x12, 0x49, 0x9f, 0x2d, 0xa0, 0xf7, 0x21, 0x11, - 0xc8, 0x42, 0x86, 0x3c, 0xef, 0xf4, 0xce, 0x6a, 0x99, 0xeb, 0x50, 0x0e, 0x75, 0x28, 0xef, 0x09, - 0x59, 0xc3, 0xa0, 0x02, 0xbf, 0x8b, 0x7e, 0xfb, 0x65, 0x2b, 0x3b, 0x1d, 0xac, 0xf4, 0xb3, 0x04, - 0xa9, 0xbb, 0x41, 0xc6, 0x75, 0xf7, 0x01, 0x41, 0xab, 0x90, 0x64, 0xe9, 0x77, 0x6c, 0x1e, 0x39, - 0xa6, 0x25, 0x98, 0x5d, 0xb7, 0xd0, 0x0a, 0x2c, 0x1a, 0x56, 0xdf, 0x76, 0x85, 0x5a, 0xdc, 0x98, - 0x27, 0x56, 0x20, 0xfd, 0x09, 0xf6, 0x82, 0x58, 0xf9, 0x18, 0xf7, 0x25, 0x4c, 0x74, 0x03, 0x32, - 0x94, 0x50, 0xc3, 0xe9, 0x88, 0x06, 0x2c, 0x32, 0x97, 0x69, 0xb6, 0xf6, 0x19, 0xef, 0xc2, 0x2a, - 0x24, 0xbb, 0x8e, 0xdf, 0x21, 0xae, 0x33, 0xca, 0xc7, 0x65, 0x69, 0x33, 0xa9, 0x25, 0xba, 0x8e, - 0xdf, 0x74, 0x9d, 0x51, 0xe9, 0x4b, 0x48, 0xb3, 0x8c, 0x45, 0x87, 0xe7, 0xe4, 0xfc, 0x2e, 0xc4, - 0xb9, 0xe0, 0x42, 0xaa, 0xb9, 0x2d, 0xd2, 0x04, 0xb6, 0xf4, 0x43, 0x04, 0x72, 0x2c, 0x40, 0xd5, - 0x34, 0xc9, 0xd0, 0xa5, 0x4c, 0x99, 0xcb, 0xe7, 0xe8, 0x7c, 0xfc, 0xc8, 0x25, 0x9a, 0x45, 0x2f, - 0xd3, 0x2c, 0x76, 0xb9, 0x66, 0x8b, 0xd3, 0x9a, 0x7d, 0x0a, 0xcb, 0x96, 0x68, 0x5d, 0x67, 0xc0, - 0x7a, 0xc7, 0x74, 0x49, 0xef, 0xac, 0x5c, 0xe8, 0x7f, 0xd5, 0x1d, 0xd5, 0xd0, 0xaf, 0x17, 0x7a, - 0xad, 0x65, 0xad, 0xe9, 0x41, 0xbb, 0x05, 0x59, 0x0b, 0x7b, 0xf6, 0x09, 0x1b, 0x96, 0xce, 0x43, - 0x3c, 0xca, 0x27, 0x58, 0x3a, 0x4b, 0x67, 0xab, 0x9f, 0xe0, 0xd1, 0x6e, 0xf2, 0xf1, 0x93, 0x8d, - 0x85, 0x7f, 0x9e, 0x6c, 0x48, 0xa5, 0x7f, 0x01, 0x92, 0x87, 0x1e, 0x19, 0x10, 0xdf, 0x70, 0xd0, - 0x06, 0xa4, 0x07, 0xe2, 0xff, 0x99, 0xf4, 0x10, 0x2e, 0xd5, 0xad, 0xf3, 0x92, 0x45, 0xa6, 0x25, - 0x9b, 0x37, 0x35, 0xeb, 0x90, 0xe2, 0x3e, 0x82, 0x2f, 0x2b, 0x26, 0x47, 0x83, 0xe9, 0x3f, 0x5d, - 0x40, 0x0a, 0x64, 0xfc, 0x61, 0xb7, 0x6f, 0x53, 0x8a, 0xad, 0x8e, 0xc1, 0x27, 0x27, 0xbd, 0x53, - 0xb8, 0x20, 0x41, 0x2b, 0x3c, 0x39, 0xc4, 0x37, 0x90, 0x3e, 0x65, 0x55, 0x29, 0xba, 0x09, 0x4b, - 0xbc, 0x63, 0xa1, 0xd4, 0x71, 0x96, 0x7b, 0x86, 0x2d, 0x1e, 0x09, 0xbd, 0x77, 0xe0, 0x0a, 0x07, - 0x19, 0x7c, 0x0a, 0x4e, 0xc1, 0x09, 0x06, 0x7e, 0xa3, 0x77, 0x6e, 0x42, 0x42, 0xce, 0x6d, 0x88, - 0xfb, 0xd4, 0xa0, 0x43, 0x3f, 0x9f, 0x94, 0xa5, 0xcd, 0xec, 0xce, 0xad, 0xd9, 0xf3, 0x16, 0x4a, - 0x58, 0xd6, 0x19, 0x58, 0x13, 0xa4, 0x80, 0xee, 0x61, 0x7f, 0xe8, 0xd0, 0x7c, 0xea, 0xb5, 0xe8, - 0x1a, 0x03, 0x6b, 0x82, 0x84, 0x3e, 0x04, 0x38, 0x21, 0x14, 0x77, 0x02, 0x6f, 0x38, 0x0f, 0x4c, - 0x99, 0xb5, 0xd9, 0x2e, 0x5a, 0x86, 0xe3, 0x8c, 0x84, 0x34, 0xa9, 0x80, 0x14, 0x64, 0x82, 0xd1, - 0xee, 0xd9, 0xd9, 0x92, 0x7e, 0x4d, 0x61, 0x43, 0x02, 0x3a, 0x82, 0x65, 0xfc, 0x08, 0x9b, 0x43, - 0x4a, 0xbc, 0x8e, 0xa8, 0x22, 0xc3, 0xaa, 0xd8, 0x7a, 0x45, 0x15, 0xaa, 0x60, 0x89, 0x6a, 0xb2, - 0x78, 0xca, 0x46, 0x9b, 0x10, 0xeb, 0xfb, 0x3d, 0x3f, 0xbf, 0xc4, 0x0e, 0xd9, 0x99, 0xc3, 0xae, - 0x31, 0x44, 0xe9, 0x99, 0x04, 0x71, 0xae, 0x28, 0xda, 0x06, 0xa4, 0xb7, 0xaa, 0xad, 0xb6, 0xde, - 0x69, 0x37, 0xf4, 0x43, 0x55, 0xa9, 0xef, 0xd7, 0xd5, 0xbd, 0xdc, 0x42, 0x61, 0x75, 0x3c, 0x91, - 0xaf, 0x84, 0x91, 0x39, 0xb6, 0xee, 0x9e, 0x18, 0x8e, 0x6d, 0xa1, 0x6d, 0xc8, 0x09, 0x8a, 0xde, - 0xae, 0xdd, 0xab, 0xb7, 0x5a, 0xea, 0x5e, 0x4e, 0x2a, 0xac, 0x8d, 0x27, 0xf2, 0xb5, 0x69, 0x82, - 0x1e, 0x4e, 0x12, 0x7a, 0x1b, 0x96, 0x04, 0x45, 0x39, 0x68, 0xea, 0xea, 0x5e, 0x2e, 0x52, 0xc8, - 0x8f, 0x27, 0xf2, 0xca, 0x34, 0x5e, 0x71, 0x88, 0x8f, 0x2d, 0xb4, 0x05, 0x59, 0x01, 0xae, 0xd6, - 0x9a, 0x5a, 0xe0, 0x3d, 0x3a, 0x2b, 0x9d, 0x6a, 0x97, 0x78, 0x14, 0x5b, 0x85, 0xd8, 0xe3, 0x9f, - 0x8a, 0x0b, 0xa5, 0x3f, 0x25, 0x88, 0x0b, 0x1d, 0xb6, 0x01, 0x69, 0xaa, 0xde, 0x3e, 0x68, 0xcd, - 0x2b, 0x89, 0x63, 0xc3, 0x92, 0xde, 0x3b, 0x47, 0xd9, 0xaf, 0x37, 0xaa, 0x07, 0xf5, 0xfb, 0xac, - 0xa8, 0xeb, 0xe3, 0x89, 0xbc, 0x3a, 0x4d, 0x69, 0xbb, 0x0f, 0x6c, 0xd7, 0x70, 0xec, 0x6f, 0xb0, - 0x85, 0x2a, 0xb0, 0x2c, 0x68, 0x55, 0x45, 0x51, 0x0f, 0x5b, 0xac, 0xb0, 0xc2, 0x78, 0x22, 0x5f, - 0x9d, 0xe6, 0x54, 0x4d, 0x13, 0x0f, 0xe8, 0x14, 0x41, 0x53, 0x3f, 0x56, 0x15, 0x5e, 0xdb, 0x0c, - 0x82, 0x86, 0xbf, 0xc2, 0xe6, 0x59, 0x71, 0x3f, 0x46, 0x20, 0x3b, 0xdd, 0x7c, 0x54, 0x83, 0x35, - 0xf5, 0x73, 0x55, 0x69, 0xb7, 0x9a, 0x5a, 0x67, 0x66, 0xb5, 0x37, 0xc6, 0x13, 0xf9, 0x7a, 0xe8, - 0x75, 0x9a, 0x1c, 0x56, 0x7d, 0x1b, 0xae, 0xbd, 0xec, 0xa3, 0xd1, 0x6c, 0x75, 0xb4, 0x76, 0x23, - 0x27, 0x15, 0xe4, 0xf1, 0x44, 0x5e, 0x9f, 0xcd, 0x6f, 0x10, 0xaa, 0x0d, 0x5d, 0x74, 0xe7, 0x22, - 0x5d, 0x6f, 0x2b, 0x8a, 0xaa, 0xeb, 0xb9, 0xc8, 0xbc, 0xf0, 0xfa, 0xd0, 0x34, 0x83, 0xb3, 0x6d, - 0x06, 0x7f, 0xbf, 0x5a, 0x3f, 0x68, 0x6b, 0x6a, 0x2e, 0x3a, 0x8f, 0xbf, 0x6f, 0xd8, 0xce, 0xd0, - 0xc3, 0x5c, 0x9b, 0xdd, 0x58, 0x70, 0xe6, 0x96, 0xbe, 0x93, 0x60, 0x91, 0x7d, 0xaa, 0x68, 0x0d, - 0x52, 0x23, 0xec, 0x77, 0xd8, 0x69, 0x23, 0x2e, 0xa0, 0xe4, 0x08, 0xfb, 0x4a, 0x60, 0x07, 0x37, - 0x90, 0x4b, 0xc4, 0x9e, 0x38, 0x69, 0x5d, 0xc2, 0xb7, 0x6e, 0xc2, 0x92, 0xd1, 0xf5, 0xa9, 0x61, - 0xbb, 0x62, 0x9f, 0xdf, 0x44, 0x19, 0xb1, 0xc8, 0x41, 0xd7, 0x01, 0x4e, 0x30, 0x0d, 0x3d, 0xc4, - 0xf8, 0x8b, 0x23, 0x58, 0x61, 0xdb, 0x22, 0x97, 0xdf, 0x25, 0x88, 0x1d, 0x11, 0x8a, 0x5f, 0x7d, - 0xee, 0xaf, 0xc0, 0x62, 0x70, 0xa4, 0x78, 0xe1, 0x4b, 0x81, 0x19, 0xc1, 0x5d, 0x6c, 0x1e, 0x13, - 0xdb, 0xc4, 0x2c, 0x85, 0xec, 0x65, 0x77, 0xb1, 0xc2, 0x30, 0x9a, 0xc0, 0xce, 0xbd, 0x2b, 0xff, - 0x8f, 0xbb, 0xe0, 0x2d, 0x0b, 0xe2, 0x3c, 0x24, 0xba, 0x0a, 0x48, 0xf9, 0xa8, 0x59, 0x57, 0xd4, - 0xe9, 0x91, 0x43, 0x4b, 0x90, 0x12, 0xeb, 0x8d, 0x66, 0x4e, 0x42, 0x59, 0x00, 0x61, 0x7e, 0xa1, - 0xea, 0xb9, 0x08, 0x42, 0x90, 0x15, 0x76, 0xb5, 0xa6, 0xb7, 0xaa, 0xf5, 0x46, 0x2e, 0x8a, 0x96, - 0x21, 0x2d, 0xd6, 0x8e, 0xd4, 0x56, 0x33, 0x17, 0xab, 0xdd, 0x79, 0xfa, 0xbc, 0x28, 0x3d, 0x7b, - 0x5e, 0x94, 0xfe, 0x7e, 0x5e, 0x94, 0xbe, 0x7f, 0x51, 0x5c, 0x78, 0xf6, 0xa2, 0xb8, 0xf0, 0xc7, - 0x8b, 0xe2, 0xc2, 0xfd, 0x37, 0x7b, 0x36, 0x3d, 0x1e, 0x76, 0xcb, 0x26, 0xe9, 0x57, 0xf8, 0xeb, - 0x56, 0xfc, 0x6c, 0xf9, 0xd6, 0xc3, 0xca, 0x23, 0xfe, 0xf4, 0xee, 0xc6, 0x59, 0x31, 0xef, 0xfc, - 0x17, 0x00, 0x00, 0xff, 0xff, 0xf5, 0x84, 0x4c, 0x18, 0x90, 0x0b, 0x00, 0x00, + // 1582 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xcd, 0x6e, 0x1b, 0x47, + 0x12, 0xd6, 0x90, 0x14, 0x7f, 0x8a, 0x14, 0xc5, 0x6d, 0xcb, 0x16, 0x45, 0x49, 0xd4, 0x98, 0x5e, + 0xc3, 0xda, 0x35, 0x44, 0x42, 0xda, 0x5d, 0x60, 0x2d, 0xac, 0x8d, 0xa5, 0xa8, 0x91, 0x97, 0xbb, + 0xb2, 0xa8, 0x1d, 0x92, 0x4a, 0xe2, 0x43, 0x88, 0x21, 0xa7, 0x4d, 0x4d, 0x3c, 0x9c, 0x26, 0x66, + 0x9a, 0x8a, 0x99, 0x07, 0x08, 0x1c, 0x9e, 0x92, 0x53, 0x90, 0x03, 0x01, 0x03, 0x79, 0x81, 0x1c, + 0xf2, 0x00, 0x39, 0x1a, 0x39, 0x19, 0x41, 0x0e, 0x49, 0x0e, 0x41, 0x60, 0x5f, 0x72, 0xc9, 0x3b, + 0x04, 0xd3, 0xdd, 0x23, 0x72, 0x24, 0x8a, 0x72, 0x02, 0xe7, 0xa4, 0xa9, 0xee, 0xfa, 0xba, 0xab, + 0xbe, 0x2a, 0xd6, 0xd7, 0x02, 0xd9, 0xc6, 0x6d, 0x6c, 0x15, 0xda, 0x36, 0xe9, 0x75, 0x0b, 0x27, + 0x9b, 0x9a, 0xd9, 0x3d, 0xd6, 0x36, 0x0b, 0xb4, 0xdf, 0xc5, 0x4e, 0xbe, 0x6b, 0x13, 0x4a, 0xd0, + 0x02, 0xf3, 0xc8, 0x33, 0x8f, 0xbc, 0xe7, 0x91, 0x59, 0x68, 0x93, 0x36, 0x61, 0x0e, 0x05, 0xf7, + 0x8b, 0xfb, 0x66, 0xb2, 0x6d, 0x42, 0xda, 0x26, 0x2e, 0x30, 0xab, 0xd9, 0x7b, 0x54, 0xd0, 0x7b, + 0xb6, 0x46, 0x0d, 0x62, 0x89, 0xfd, 0xb5, 0xb3, 0xfb, 0xd4, 0xe8, 0x60, 0x87, 0x6a, 0x9d, 0xae, + 0x70, 0x48, 0xb4, 0x88, 0xd3, 0x21, 0xe2, 0xea, 0xcc, 0xd2, 0x59, 0x77, 0xcd, 0xea, 0xf3, 0xad, + 0xdc, 0x11, 0x84, 0x1f, 0xe0, 0x4e, 0x13, 0xdb, 0x28, 0x0d, 0x11, 0x4d, 0xd7, 0x6d, 0xec, 0x38, + 0x69, 0x49, 0x96, 0xd6, 0x63, 0xaa, 0x67, 0xa2, 0x6b, 0x10, 0x7e, 0x1f, 0x1b, 0xed, 0x63, 0x9a, + 0x0e, 0xb0, 0x0d, 0x61, 0xa1, 0x0c, 0x44, 0x3b, 0x98, 0x6a, 0xba, 0x46, 0xb5, 0x74, 0x50, 0x96, + 0xd6, 0x13, 0xea, 0xa9, 0x9d, 0xbb, 0x0f, 0x11, 0x7e, 0xae, 0x83, 0xfe, 0x05, 0x91, 0x0e, 0xff, + 0x4c, 0x4b, 0x72, 0x70, 0x3d, 0xbe, 0xb5, 0x92, 0x9f, 0x44, 0x45, 0x9e, 0xfb, 0xef, 0x84, 0x9e, + 0xff, 0xb8, 0x36, 0xa3, 0x7a, 0x90, 0xdc, 0x87, 0x12, 0x2c, 0xd6, 0x8e, 0x6d, 0xec, 0x1c, 0x13, + 0x53, 0xdf, 0xc5, 0x2d, 0xc3, 0x31, 0x88, 0x75, 0x48, 0x4c, 0xa3, 0xd5, 0x47, 0x2b, 0x10, 0xa3, + 0xde, 0x96, 0x08, 0x7a, 0xb4, 0x80, 0xee, 0x40, 0xc4, 0xa5, 0x85, 0xf4, 0x78, 0xdc, 0xf1, 0xad, + 0xa5, 0x3c, 0xe7, 0x21, 0xef, 0xf1, 0x90, 0xdf, 0x15, 0xb4, 0x7a, 0x97, 0x0a, 0xff, 0x6d, 0xf4, + 0xcd, 0x97, 0x1b, 0x49, 0xff, 0x65, 0xb9, 0x2f, 0x24, 0x88, 0xdd, 0x77, 0x23, 0x2e, 0x5b, 0x8f, + 0x08, 0x5a, 0x82, 0x28, 0x0b, 0xbf, 0x61, 0xf0, 0x9b, 0x43, 0x6a, 0x84, 0xd9, 0x65, 0x1d, 0x2d, + 0xc0, 0xac, 0xa6, 0x77, 0x0c, 0x4b, 0xb0, 0xc5, 0x8d, 0x69, 0x64, 0xb9, 0xd4, 0x9f, 0x60, 0xdb, + 0xbd, 0x2b, 0x1d, 0xe2, 0x67, 0x09, 0x13, 0x5d, 0x87, 0x04, 0x25, 0x54, 0x33, 0x1b, 0xa2, 0x00, + 0xb3, 0xec, 0xc8, 0x38, 0x5b, 0x7b, 0x8b, 0x57, 0x61, 0x09, 0xa2, 0x4d, 0xd3, 0x69, 0x10, 0xcb, + 0xec, 0xa7, 0xc3, 0xb2, 0xb4, 0x1e, 0x55, 0x23, 0x4d, 0xd3, 0xa9, 0x58, 0x66, 0x3f, 0xf7, 0x2e, + 0xc4, 0x59, 0xc4, 0xa2, 0xc2, 0x53, 0x62, 0xfe, 0x3b, 0x84, 0x39, 0xe1, 0x82, 0xaa, 0xa9, 0x25, + 0x52, 0x85, 0x6f, 0xee, 0xd3, 0x00, 0xa4, 0xd8, 0x05, 0xc5, 0x56, 0x8b, 0xf4, 0x2c, 0xca, 0x98, + 0xb9, 0xb8, 0x8f, 0xc6, 0xef, 0x0f, 0x5c, 0xc0, 0x59, 0xf0, 0x22, 0xce, 0x42, 0x17, 0x73, 0x36, + 0xeb, 0xe7, 0xec, 0xff, 0x30, 0xaf, 0x8b, 0xd2, 0x35, 0xba, 0xac, 0x76, 0x8c, 0x97, 0xf8, 0xd6, + 0xc2, 0xb9, 0xfa, 0x17, 0xad, 0xfe, 0x0e, 0xfa, 0xfa, 0x5c, 0xad, 0xd5, 0xa4, 0xee, 0x6f, 0xb4, + 0x9b, 0x90, 0xd4, 0xb1, 0x6d, 0x9c, 0xb0, 0x66, 0x69, 0x3c, 0xc6, 0xfd, 0x74, 0x84, 0x85, 0x33, + 0x37, 0x5a, 0xfd, 0x1f, 0xee, 0x6f, 0x47, 0x9f, 0x3e, 0x5b, 0x9b, 0xf9, 0xf9, 0xd9, 0x9a, 0x94, + 0xfb, 0x05, 0x20, 0x7a, 0x68, 0x93, 0x2e, 0x71, 0x34, 0x13, 0xad, 0x41, 0xbc, 0x2b, 0xbe, 0x47, + 0xd4, 0x83, 0xb7, 0x54, 0xd6, 0xc7, 0x29, 0x0b, 0xf8, 0x29, 0x9b, 0xd6, 0x35, 0x2b, 0x10, 0xe3, + 0x67, 0xb8, 0xbf, 0xac, 0x90, 0x1c, 0x74, 0xbb, 0xff, 0x74, 0x01, 0x95, 0x20, 0xe1, 0xf4, 0x9a, + 0x1d, 0x83, 0x52, 0xac, 0x37, 0x34, 0xde, 0x39, 0xf1, 0xad, 0xcc, 0x39, 0x0a, 0x6a, 0xde, 0xe4, + 0x10, 0xbf, 0x81, 0xf8, 0x29, 0xaa, 0x48, 0xd1, 0x0d, 0x98, 0xe3, 0x15, 0xf3, 0xa8, 0x0e, 0xb3, + 0xd8, 0x13, 0x6c, 0xf1, 0x48, 0xf0, 0xbd, 0x05, 0x57, 0xb9, 0x93, 0xc6, 0xbb, 0xe0, 0xd4, 0x39, + 0xc2, 0x9c, 0xaf, 0xb4, 0xc7, 0x3a, 0xc4, 0xc3, 0xdc, 0x85, 0xb0, 0x43, 0x35, 0xda, 0x73, 0xd2, + 0x51, 0x59, 0x5a, 0x4f, 0x6e, 0xdd, 0x9c, 0xdc, 0x6f, 0x1e, 0x85, 0xf9, 0x2a, 0x73, 0x56, 0x05, + 0xc8, 0x85, 0xdb, 0xd8, 0xe9, 0x99, 0x34, 0x1d, 0x7b, 0x2d, 0xb8, 0xca, 0x9c, 0x55, 0x01, 0x42, + 0xff, 0x06, 0x38, 0x21, 0x14, 0x37, 0xdc, 0xd3, 0x70, 0x1a, 0x18, 0x33, 0xcb, 0x93, 0x8f, 0xa8, + 0x69, 0xa6, 0xd9, 0x17, 0xd4, 0xc4, 0x5c, 0x90, 0x1b, 0x09, 0x46, 0xdb, 0xa3, 0xd9, 0x12, 0x7f, + 0x4d, 0x62, 0x3d, 0x00, 0x3a, 0x82, 0x79, 0xfc, 0x04, 0xb7, 0x7a, 0x94, 0xd8, 0x0d, 0x91, 0x45, + 0x82, 0x65, 0xb1, 0x71, 0x49, 0x16, 0x8a, 0x40, 0x89, 0x6c, 0x92, 0xd8, 0x67, 0xa3, 0x75, 0x08, + 0x75, 0x9c, 0xb6, 0x93, 0x9e, 0x63, 0x43, 0x76, 0x62, 0xb3, 0xab, 0xcc, 0x23, 0xf7, 0x42, 0x82, + 0x30, 0x67, 0x14, 0x6d, 0x02, 0xaa, 0xd6, 0x8a, 0xb5, 0x7a, 0xb5, 0x51, 0x3f, 0xa8, 0x1e, 0x2a, + 0xa5, 0xf2, 0x5e, 0x59, 0xd9, 0x4d, 0xcd, 0x64, 0x96, 0x06, 0x43, 0xf9, 0xaa, 0x77, 0x33, 0xf7, + 0x2d, 0x5b, 0x27, 0x9a, 0x69, 0xe8, 0x68, 0x13, 0x52, 0x02, 0x52, 0xad, 0xef, 0x3c, 0x28, 0xd7, + 0x6a, 0xca, 0x6e, 0x4a, 0xca, 0x2c, 0x0f, 0x86, 0xf2, 0xa2, 0x1f, 0x50, 0xf5, 0x3a, 0x09, 0xdd, + 0x86, 0x39, 0x01, 0x29, 0xed, 0x57, 0xaa, 0xca, 0x6e, 0x2a, 0x90, 0x49, 0x0f, 0x86, 0xf2, 0x82, + 0xdf, 0xbf, 0x64, 0x12, 0x07, 0xeb, 0x68, 0x03, 0x92, 0xc2, 0xb9, 0xb8, 0x53, 0x51, 0xdd, 0xd3, + 0x83, 0x93, 0xc2, 0x29, 0x36, 0x89, 0x4d, 0xb1, 0x9e, 0x09, 0x3d, 0xfd, 0x3c, 0x3b, 0x93, 0xfb, + 0x41, 0x82, 0xb0, 0xe0, 0x61, 0x13, 0x90, 0xaa, 0x54, 0xeb, 0xfb, 0xb5, 0x69, 0x29, 0x71, 0x5f, + 0x2f, 0xa5, 0x7f, 0x8c, 0x41, 0xf6, 0xca, 0x07, 0xc5, 0xfd, 0xf2, 0x43, 0x96, 0xd4, 0xea, 0x60, + 0x28, 0x2f, 0xf9, 0x21, 0x75, 0xeb, 0x91, 0x61, 0x69, 0xa6, 0xf1, 0x01, 0xd6, 0x51, 0x01, 0xe6, + 0x05, 0xac, 0x58, 0x2a, 0x29, 0x87, 0x35, 0x96, 0x58, 0x66, 0x30, 0x94, 0xaf, 0xf9, 0x31, 0xc5, + 0x56, 0x0b, 0x77, 0xa9, 0x0f, 0xa0, 0x2a, 0xff, 0x55, 0x4a, 0x3c, 0xb7, 0x09, 0x00, 0x15, 0xbf, + 0x87, 0x5b, 0xa3, 0xe4, 0x3e, 0x0b, 0x40, 0xd2, 0x5f, 0x7c, 0xb4, 0x03, 0xcb, 0xca, 0xdb, 0x4a, + 0xa9, 0x5e, 0xab, 0xa8, 0x8d, 0x89, 0xd9, 0x5e, 0x1f, 0x0c, 0xe5, 0x55, 0xef, 0x54, 0x3f, 0xd8, + 0xcb, 0xfa, 0x2e, 0x2c, 0x9e, 0x3d, 0xe3, 0xa0, 0x52, 0x6b, 0xa8, 0xf5, 0x83, 0x94, 0x94, 0x91, + 0x07, 0x43, 0x79, 0x65, 0x32, 0xfe, 0x80, 0x50, 0xb5, 0x67, 0xa1, 0x7b, 0xe7, 0xe1, 0xd5, 0x7a, + 0xa9, 0xa4, 0x54, 0xab, 0xa9, 0xc0, 0xb4, 0xeb, 0xab, 0xbd, 0x56, 0xcb, 0x9d, 0x6d, 0x13, 0xf0, + 0x7b, 0xc5, 0xf2, 0x7e, 0x5d, 0x55, 0x52, 0xc1, 0x69, 0xf8, 0x3d, 0xcd, 0x30, 0x7b, 0x36, 0xe6, + 0xdc, 0x6c, 0x87, 0xdc, 0x99, 0x9b, 0xfb, 0x48, 0x82, 0x59, 0xf6, 0x53, 0x45, 0xcb, 0x10, 0xeb, + 0x63, 0xa7, 0xc1, 0xa6, 0x8d, 0x10, 0xa0, 0x68, 0x1f, 0x3b, 0x25, 0xd7, 0x76, 0x15, 0xc8, 0x22, + 0x62, 0x4f, 0x4c, 0x5a, 0x8b, 0xf0, 0xad, 0x1b, 0x30, 0xa7, 0x35, 0x1d, 0xaa, 0x19, 0x96, 0xd8, + 0xe7, 0x4a, 0x94, 0x10, 0x8b, 0xdc, 0x69, 0x15, 0xe0, 0x04, 0x53, 0xef, 0x84, 0x10, 0x7f, 0x71, + 0xb8, 0x2b, 0x6c, 0x5b, 0xc4, 0xf2, 0xad, 0x04, 0xa1, 0x23, 0x42, 0xf1, 0xe5, 0x73, 0x7f, 0x01, + 0x66, 0xdd, 0x91, 0x62, 0x7b, 0x2f, 0x05, 0x66, 0xb8, 0x5a, 0xdc, 0x3a, 0x26, 0x46, 0x0b, 0xb3, + 0x10, 0x92, 0x17, 0x69, 0x71, 0x89, 0xf9, 0xa8, 0xc2, 0x77, 0xaa, 0x56, 0xbe, 0x09, 0x2d, 0xc8, + 0x7d, 0x22, 0x41, 0x8c, 0x51, 0x7c, 0x48, 0x4c, 0x13, 0x95, 0x20, 0xcc, 0x48, 0xf0, 0xde, 0x74, + 0xb7, 0xa7, 0x8c, 0x4f, 0x17, 0x90, 0x67, 0x0c, 0x39, 0x8a, 0x45, 0xed, 0xbe, 0x2a, 0xa0, 0x99, + 0x3b, 0x10, 0x1f, 0x5b, 0x46, 0x29, 0x08, 0xba, 0xd2, 0xca, 0x8b, 0xe6, 0x7e, 0x32, 0x82, 0x34, + 0xb3, 0x87, 0x4f, 0x09, 0x72, 0x8d, 0xed, 0xc0, 0x3f, 0x25, 0x41, 0xf5, 0x2d, 0x88, 0x54, 0xba, + 0xae, 0xfa, 0xb2, 0x47, 0x2a, 0x35, 0xa8, 0x89, 0x79, 0x40, 0x31, 0x55, 0x58, 0x5e, 0x4d, 0x66, + 0x21, 0xc4, 0xe2, 0x5e, 0x84, 0x48, 0x97, 0x98, 0x63, 0xf5, 0x08, 0xbb, 0x66, 0x59, 0xbf, 0xe4, + 0x71, 0xc2, 0x0e, 0xf3, 0x1e, 0x27, 0xcc, 0x40, 0x77, 0x21, 0x42, 0xf8, 0xdd, 0x8c, 0xef, 0xf8, + 0xd6, 0xea, 0x64, 0x0a, 0x44, 0x80, 0x9e, 0x0a, 0x08, 0x8c, 0xab, 0xf9, 0x2d, 0x1b, 0x6b, 0x94, + 0xd8, 0xe2, 0x51, 0xe7, 0x99, 0xac, 0xc9, 0x5c, 0x75, 0x32, 0x8d, 0x8e, 0x41, 0x99, 0xe2, 0xce, + 0x72, 0xe9, 0xd9, 0x77, 0x17, 0xd0, 0xae, 0x4f, 0xbc, 0x22, 0xec, 0xea, 0xb5, 0x4b, 0xd8, 0x3f, + 0x2f, 0x60, 0xe3, 0xed, 0x12, 0xbd, 0xa4, 0x5d, 0x62, 0x6f, 0xe4, 0xe9, 0x00, 0x13, 0x9e, 0x0e, + 0x77, 0x4e, 0x9f, 0x01, 0x71, 0xd6, 0xea, 0xd7, 0x2f, 0x50, 0x40, 0xb7, 0x81, 0xce, 0x3c, 0x01, + 0xc6, 0x14, 0x38, 0xf1, 0x1b, 0x15, 0x38, 0xf7, 0xd5, 0x48, 0xff, 0x36, 0x2e, 0xd0, 0xbf, 0xab, + 0x83, 0xa1, 0xfc, 0x27, 0xf7, 0x5e, 0xbf, 0xf6, 0x6d, 0x4c, 0xd4, 0xbe, 0xc5, 0xc1, 0x50, 0xbe, + 0x32, 0x72, 0x1e, 0xe9, 0xde, 0xad, 0xf3, 0xba, 0xb7, 0x30, 0x18, 0xca, 0xa9, 0x91, 0xaf, 0xd0, + 0xbc, 0xbf, 0x4c, 0xd0, 0xbc, 0x33, 0x21, 0xf8, 0xf4, 0x4e, 0xb4, 0xf5, 0xf7, 0x12, 0x44, 0xdd, + 0x51, 0x33, 0xbd, 0xb5, 0x27, 0x8f, 0x99, 0xb1, 0xfe, 0x0d, 0xfe, 0x8e, 0xfe, 0xfd, 0xa3, 0xe7, + 0xcd, 0x5f, 0x75, 0x08, 0xf3, 0x11, 0x87, 0xae, 0x01, 0x2a, 0xfd, 0xa7, 0x52, 0x2e, 0x29, 0xfe, + 0x1a, 0xa1, 0x39, 0x88, 0x89, 0xf5, 0x83, 0x4a, 0x4a, 0x42, 0x49, 0x00, 0x61, 0xbe, 0xa3, 0x54, + 0x53, 0x01, 0x84, 0x20, 0x29, 0xec, 0xe2, 0x4e, 0xb5, 0x56, 0x2c, 0x1f, 0xa4, 0x82, 0x68, 0x1e, + 0xe2, 0x62, 0xed, 0x48, 0xa9, 0x55, 0x52, 0xa1, 0x9d, 0x7b, 0xcf, 0x5f, 0x66, 0xa5, 0x17, 0x2f, + 0xb3, 0xd2, 0x4f, 0x2f, 0xb3, 0xd2, 0xc7, 0xaf, 0xb2, 0x33, 0x2f, 0x5e, 0x65, 0x67, 0xbe, 0x7b, + 0x95, 0x9d, 0x79, 0xf8, 0xe7, 0xb6, 0x41, 0x8f, 0x7b, 0xcd, 0x7c, 0x8b, 0x74, 0x0a, 0xfc, 0xbf, + 0x69, 0xf1, 0x67, 0xc3, 0xd1, 0x1f, 0x17, 0x9e, 0xf0, 0x7f, 0xf5, 0x9b, 0x61, 0x96, 0xcc, 0xdf, + 0x7e, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xd4, 0xd7, 0x89, 0x57, 0x00, 0x10, 0x00, 0x00, } func (this *GroupAccountInfo) Equal(that interface{}) bool { @@ -1413,82 +1688,327 @@ func (m *Vote) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *TallyPoll) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *Member) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.Weight) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.Metadata) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - return n + +func (m *TallyPoll) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Members) Size() (n int) { - if m == nil { - return 0 - } +func (m *TallyPoll) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.Members) > 0 { - for _, e := range m.Members { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) + if len(m.Counts) > 0 { + for k := range m.Counts { + v := m.Counts[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = encodeVarintTypes(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintTypes(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintTypes(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa } } - return n + return len(dAtA) - i, nil } -func (m *ThresholdDecisionPolicy) Size() (n int) { - if m == nil { - return 0 +func (m *Options) 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 *Options) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Options) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Threshold) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) + if len(m.Titles) > 0 { + for iNdEx := len(m.Titles) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Titles[iNdEx]) + copy(dAtA[i:], m.Titles[iNdEx]) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Titles[iNdEx]))) + i-- + dAtA[i] = 0xa + } } - l = m.Timeout.Size() - n += 1 + l + sovTypes(uint64(l)) - return n + return len(dAtA) - i, nil } -func (m *GroupInfo) Size() (n int) { - if m == nil { - return 0 +func (m *Poll) 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 *Poll) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Poll) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.GroupId != 0 { - n += 1 + sovTypes(uint64(m.GroupId)) - } - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) + { + size, err := m.Timeout.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) } - l = len(m.Metadata) + i-- + dAtA[i] = 0x62 + if m.Status != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x58 + } + if m.GroupVersion != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.GroupVersion)) + i-- + dAtA[i] = 0x50 + } + { + size, err := m.SubmittedAt.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x42 + } + { + size, err := m.VoteState.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + if m.VoteLimit != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.VoteLimit)) + i-- + dAtA[i] = 0x30 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x2a + } + { + size, err := m.Options.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0x1a + } + if m.GroupId != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.GroupId)) + i-- + dAtA[i] = 0x10 + } + if m.PollId != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *VotePoll) 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 *VotePoll) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VotePoll) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.SubmittedAt.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x22 + } + { + size, err := m.Options.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x12 + } + if m.PollId != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { + offset -= sovTypes(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Member) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Weight) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *Members) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Members) > 0 { + for _, e := range m.Members { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *ThresholdDecisionPolicy) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Threshold) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Timeout.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *GroupInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupId != 0 { + n += 1 + sovTypes(uint64(m.GroupId)) + } + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Metadata) if l > 0 { n += 1 + l + sovTypes(uint64(l)) } @@ -1659,46 +2179,887 @@ func (m *Vote) Size() (n int) { return n } -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 +func (m *TallyPoll) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Counts) > 0 { + for k, v := range m.Counts { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovTypes(uint64(len(k))) + 1 + len(v) + sovTypes(uint64(len(v))) + n += mapEntrySize + 1 + sovTypes(uint64(mapEntrySize)) + } + } + return n } -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + +func (m *Options) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Titles) > 0 { + for _, s := range m.Titles { + l = len(s) + n += 1 + l + sovTypes(uint64(l)) + } + } + return n } -func (m *Member) 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 ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + +func (m *Poll) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovTypes(uint64(m.PollId)) + } + if m.GroupId != 0 { + n += 1 + sovTypes(uint64(m.GroupId)) + } + l = len(m.Title) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Options.Size() + n += 1 + l + sovTypes(uint64(l)) + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.VoteLimit != 0 { + n += 1 + sovTypes(uint64(m.VoteLimit)) + } + l = m.VoteState.Size() + n += 1 + l + sovTypes(uint64(l)) + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.SubmittedAt.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.GroupVersion != 0 { + n += 1 + sovTypes(uint64(m.GroupVersion)) + } + if m.Status != 0 { + n += 1 + sovTypes(uint64(m.Status)) + } + l = m.Timeout.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *VotePoll) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovTypes(uint64(m.PollId)) + } + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Options.Size() + n += 1 + l + sovTypes(uint64(l)) + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.SubmittedAt.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func sovTypes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTypes(x uint64) (n int) { + return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Member) 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 ErrIntOverflowTypes + } + 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: Member: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Member: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Weight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Weight = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Members) 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 ErrIntOverflowTypes + } + 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: Members: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Members: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Members = append(m.Members, Member{}) + if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ThresholdDecisionPolicy) 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 ErrIntOverflowTypes + } + 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: ThresholdDecisionPolicy: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ThresholdDecisionPolicy: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Threshold", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Threshold = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GroupInfo) 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 ErrIntOverflowTypes + } + 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: GroupInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GroupInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalWeight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TotalWeight = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlsOnly", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.BlsOnly = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GroupMember) 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 ErrIntOverflowTypes + } + 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: GroupMember: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GroupMember: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Member", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Member == nil { + m.Member = &Member{} + } + if err := m.Member.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GroupAccountInfo) 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 ErrIntOverflowTypes + } + 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: GroupAccountInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GroupAccountInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Member: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Member: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -1708,29 +3069,50 @@ func (m *Member) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } iNdEx = postIndex - case 2: + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Weight", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DecisionPolicy", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -1740,27 +3122,31 @@ func (m *Member) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - m.Weight = string(dAtA[iNdEx:postIndex]) + if m.DecisionPolicy == nil { + m.DecisionPolicy = &types1.Any{} + } + if err := m.DecisionPolicy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 3: + case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DerivationKey", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -1787,9 +3173,9 @@ func (m *Member) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) - if m.Metadata == nil { - m.Metadata = []byte{} + m.DerivationKey = append(m.DerivationKey[:0], dAtA[iNdEx:postIndex]...) + if m.DerivationKey == nil { + m.DerivationKey = []byte{} } iNdEx = postIndex default: @@ -1813,7 +3199,7 @@ func (m *Member) Unmarshal(dAtA []byte) error { } return nil } -func (m *Members) Unmarshal(dAtA []byte) error { +func (m *Proposal) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1836,17 +3222,36 @@ func (m *Members) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Members: wiretype end group for non-group") + return fmt.Errorf("proto: Proposal: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Members: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Proposal: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + } + m.ProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -1856,79 +3261,61 @@ func (m *Members) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - m.Members = append(m.Members, Member{}) - if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + if byteLen < 0 { + return ErrInvalidLengthTypes } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ThresholdDecisionPolicy) 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 ErrIntOverflowTypes + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ThresholdDecisionPolicy: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ThresholdDecisionPolicy: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Threshold", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Proposers", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1956,11 +3343,11 @@ func (m *ThresholdDecisionPolicy) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Threshold = string(dAtA[iNdEx:postIndex]) + m.Proposers = append(m.Proposers, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 2: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SubmittedAt", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1987,65 +3374,15 @@ func (m *ThresholdDecisionPolicy) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GroupInfo) 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 ErrIntOverflowTypes - } - 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: GroupInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GroupInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + if err := m.SubmittedAt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field GroupVersion", wireType) } - m.GroupId = 0 + m.GroupVersion = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2055,16 +3392,16 @@ func (m *GroupInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GroupId |= uint64(b&0x7F) << shift + m.GroupVersion |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupAccountVersion", wireType) } - var stringLen uint64 + m.GroupAccountVersion = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2074,29 +3411,16 @@ func (m *GroupInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.GroupAccountVersion |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Admin = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } - var byteLen int + m.Status = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2106,31 +3430,16 @@ func (m *GroupInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + m.Status |= Proposal_Status(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) - if m.Metadata == nil { - m.Metadata = []byte{} - } - iNdEx = postIndex - case 4: + case 9: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) } - m.Version = 0 + m.Result = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2140,16 +3449,16 @@ func (m *GroupInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Version |= uint64(b&0x7F) << shift + m.Result |= Proposal_Result(b&0x7F) << shift if b < 0x80 { break } } - case 5: + case 10: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalWeight", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field VoteState", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2159,29 +3468,30 @@ func (m *GroupInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - m.TotalWeight = string(dAtA[iNdEx:postIndex]) + if err := m.VoteState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BlsOnly", wireType) + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) } - var v int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2191,67 +3501,30 @@ func (m *GroupInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - m.BlsOnly = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { + if msglen < 0 { return ErrInvalidLengthTypes } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GroupMember) 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 ErrIntOverflowTypes + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GroupMember: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GroupMember: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 12: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ExecutorResult", wireType) } - m.GroupId = 0 + m.ExecutorResult = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2261,14 +3534,14 @@ func (m *GroupMember) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GroupId |= uint64(b&0x7F) << shift + m.ExecutorResult |= Proposal_ExecutorResult(b&0x7F) << shift if b < 0x80 { break } } - case 2: + case 13: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Member", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Msgs", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2295,10 +3568,8 @@ func (m *GroupMember) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Member == nil { - m.Member = &Member{} - } - if err := m.Member.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Msgs = append(m.Msgs, &types1.Any{}) + if err := m.Msgs[len(m.Msgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2323,7 +3594,7 @@ func (m *GroupMember) Unmarshal(dAtA []byte) error { } return nil } -func (m *GroupAccountInfo) Unmarshal(dAtA []byte) error { +func (m *Tally) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2346,15 +3617,15 @@ func (m *GroupAccountInfo) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GroupAccountInfo: wiretype end group for non-group") + return fmt.Errorf("proto: Tally: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GroupAccountInfo: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Tally: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field YesCount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2382,30 +3653,11 @@ func (m *GroupAccountInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.YesCount = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) - } - m.GroupId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.GroupId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NoCount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2426,73 +3678,20 @@ func (m *GroupAccountInfo) Unmarshal(dAtA []byte) error { if intStringLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Admin = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) - if m.Metadata == nil { - m.Metadata = []byte{} - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - m.Version = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Version |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes } - case 6: + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NoCount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DecisionPolicy", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AbstainCount", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2502,33 +3701,29 @@ func (m *GroupAccountInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if m.DecisionPolicy == nil { - m.DecisionPolicy = &types1.Any{} - } - if err := m.DecisionPolicy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.AbstainCount = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DerivationKey", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field VetoCount", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2538,25 +3733,23 @@ func (m *GroupAccountInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - m.DerivationKey = append(m.DerivationKey[:0], dAtA[iNdEx:postIndex]...) - if m.DerivationKey == nil { - m.DerivationKey = []byte{} - } + m.VetoCount = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2579,7 +3772,7 @@ func (m *GroupAccountInfo) Unmarshal(dAtA []byte) error { } return nil } -func (m *Proposal) Unmarshal(dAtA []byte) error { +func (m *Vote) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2602,10 +3795,10 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Proposal: wiretype end group for non-group") + return fmt.Errorf("proto: Vote: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Proposal: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Vote: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2629,7 +3822,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { } case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2657,9 +3850,28 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.Voter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Choice", wireType) + } + m.Choice = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Choice |= Choice(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) } @@ -2693,11 +3905,11 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { m.Metadata = []byte{} } iNdEx = postIndex - case 4: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proposers", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SubmittedAt", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2707,27 +3919,78 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - m.Proposers = append(m.Proposers, string(dAtA[iNdEx:postIndex])) + if err := m.SubmittedAt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 5: + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TallyPoll) 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 ErrIntOverflowTypes + } + 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: TallyPoll: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TallyPoll: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SubmittedAt", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Counts", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2754,15 +4017,241 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.SubmittedAt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Counts == nil { + m.Counts = make(map[string]string) + } + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthTypes + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthTypes + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return ErrInvalidLengthTypes + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return ErrInvalidLengthTypes + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Counts[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Options) 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 ErrIntOverflowTypes + } + 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: Options: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Options: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Titles", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Titles = append(m.Titles, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { return err } - iNdEx = postIndex - case 6: + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Poll) 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 ErrIntOverflowTypes + } + 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: Poll: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Poll: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupVersion", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) } - m.GroupVersion = 0 + m.PollId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2772,16 +4261,16 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GroupVersion |= uint64(b&0x7F) << shift + m.PollId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 7: + case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupAccountVersion", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) } - m.GroupAccountVersion = 0 + m.GroupId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2791,16 +4280,16 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GroupAccountVersion |= uint64(b&0x7F) << shift + m.GroupId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) } - m.Status = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2810,33 +4299,27 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Status |= Proposal_Status(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes } - m.Result = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Result |= Proposal_Result(b&0x7F) << shift - if b < 0x80 { - break - } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes } - case 10: + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VoteState", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2863,15 +4346,15 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.VoteState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Options.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 11: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2881,30 +4364,29 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 12: + case 6: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ExecutorResult", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field VoteLimit", wireType) } - m.ExecutorResult = 0 + m.VoteLimit = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2914,14 +4396,14 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ExecutorResult |= Proposal_ExecutorResult(b&0x7F) << shift + m.VoteLimit |= int32(b&0x7F) << shift if b < 0x80 { break } } - case 13: + case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Msgs", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field VoteState", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2948,66 +4430,15 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Msgs = append(m.Msgs, &types1.Any{}) - if err := m.Msgs[len(m.Msgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.VoteState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Tally) 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 ErrIntOverflowTypes - } - 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: Tally: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Tally: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 8: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field YesCount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -3017,29 +4448,31 @@ func (m *Tally) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - m.YesCount = string(dAtA[iNdEx:postIndex]) + m.Metadata = append(m.Metadata[:0], dAtA[iNdEx:postIndex]...) + if m.Metadata == nil { + m.Metadata = []byte{} + } iNdEx = postIndex - case 2: + case 9: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NoCount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SubmittedAt", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -3049,29 +4482,30 @@ func (m *Tally) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - m.NoCount = string(dAtA[iNdEx:postIndex]) + if err := m.SubmittedAt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AbstainCount", wireType) + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupVersion", wireType) } - var stringLen uint64 + m.GroupVersion = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -3081,29 +4515,35 @@ func (m *Tally) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.GroupVersion |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } - if postIndex > l { - return io.ErrUnexpectedEOF + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= Poll_Status(b&0x7F) << shift + if b < 0x80 { + break + } } - m.AbstainCount = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: + case 12: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VetoCount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -3113,23 +4553,24 @@ func (m *Tally) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - m.VetoCount = string(dAtA[iNdEx:postIndex]) + if err := m.Timeout.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -3152,7 +4593,7 @@ func (m *Tally) Unmarshal(dAtA []byte) error { } return nil } -func (m *Vote) Unmarshal(dAtA []byte) error { +func (m *VotePoll) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3175,17 +4616,17 @@ func (m *Vote) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Vote: wiretype end group for non-group") + return fmt.Errorf("proto: VotePoll: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Vote: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: VotePoll: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) } - m.ProposalId = 0 + m.PollId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -3195,7 +4636,7 @@ func (m *Vote) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProposalId |= uint64(b&0x7F) << shift + m.PollId |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -3233,10 +4674,10 @@ func (m *Vote) Unmarshal(dAtA []byte) error { m.Voter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Choice", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) } - m.Choice = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -3246,11 +4687,25 @@ func (m *Vote) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Choice |= Choice(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Options.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) diff --git a/x/group/typesupport.go b/x/group/typesupport.go index d300b1b9fb..7d827cc730 100644 --- a/x/group/typesupport.go +++ b/x/group/typesupport.go @@ -37,3 +37,29 @@ func (a AccAddresses) ValidateBasic() error { } return nil } + +// ValidateBasic verifies that check the length of options and if there is any duplication. +func (ops Options) ValidateBasic() error { + if len(ops.Titles) == 0 { + return sdkerrors.Wrap(ErrEmpty, "poll options") + } + + for i, x := range ops.Titles { + if len(x) == 0 { + return sdkerrors.Wrapf(ErrEmpty, "option %d", i) + } + } + + if err := assertOptionsLength(ops, "options"); err != nil { + return err + } + + index := make(map[string]struct{}, len(ops.Titles)) + for _, x := range ops.Titles { + if _, exists := index[x]; exists { + return sdkerrors.Wrapf(ErrDuplicate, "option %s", x) + } + index[x] = struct{}{} + } + return nil +} \ No newline at end of file From e1b58a044bbc55a39f05c182edd4fecc8bbbf91d Mon Sep 17 00:00:00 2001 From: kitty Date: Thu, 16 Sep 2021 16:11:14 +0100 Subject: [PATCH 28/34] fix bls related test errors --- crypto/keys/bls12381/multisig.go | 4 ++-- regen/types/module/client/grpc_gateway/module.go | 2 +- testutil/testdata/tx.go | 2 +- x/auth/ante/ante_test.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crypto/keys/bls12381/multisig.go b/crypto/keys/bls12381/multisig.go index dadfc0c3e1..e7a854c463 100644 --- a/crypto/keys/bls12381/multisig.go +++ b/crypto/keys/bls12381/multisig.go @@ -72,7 +72,7 @@ func VerifyAggregateSignature(msgs [][]byte, msgCheck bool, sig []byte, pkss [][ } for i, msg := range msgs { - if len(msg) <= 0 { + if len(msg) == 0 { return fmt.Errorf("%d-th message is empty", i) } } @@ -82,7 +82,7 @@ func VerifyAggregateSignature(msgs [][]byte, msgCheck bool, sig []byte, pkss [][ } for i, pks := range pkss { - if len(pks) <= 0 { + if len(pks) == 0 { return fmt.Errorf("%d-th public key set is empty", i) } } diff --git a/regen/types/module/client/grpc_gateway/module.go b/regen/types/module/client/grpc_gateway/module.go index b52e030479..4c6f73b69b 100644 --- a/regen/types/module/client/grpc_gateway/module.go +++ b/regen/types/module/client/grpc_gateway/module.go @@ -2,8 +2,8 @@ package grpc_gateway import ( "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/cosmos/cosmos-sdk/regen/types/module" + "github.com/grpc-ecosystem/grpc-gateway/runtime" ) // Module is an interface that modules should implement to register grpc-gateway routes. diff --git a/testutil/testdata/tx.go b/testutil/testdata/tx.go index 5377482e3d..646ac30b49 100644 --- a/testutil/testdata/tx.go +++ b/testutil/testdata/tx.go @@ -45,7 +45,7 @@ func NewTestFeeAmount() sdk.Coins { // NewTestGasLimit is a test fee gas limit. func NewTestGasLimit() uint64 { - return 120000 + return 150000 } // NewTestMsg creates a message for testing with the given signers. diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index 7c31c5f460..5d96cef489 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -573,7 +573,7 @@ func (suite *AnteTestSuite) TestAnteHandlerMemoGas() { "tx with memo has enough gas", func() { feeAmount = sdk.NewCoins(sdk.NewInt64Coin("atom", 0)) - gasLimit = 50000 + gasLimit = 60000 suite.txBuilder.SetMemo(strings.Repeat("0123456789", 10)) }, false, From 34ce85a9c13377f868dbed7642bfc98cefd408db Mon Sep 17 00:00:00 2001 From: kitty Date: Thu, 16 Sep 2021 16:15:30 +0100 Subject: [PATCH 29/34] fix proto-lint errors --- proto/regen/group/v1alpha1/tx.proto | 4 ++-- proto/regen/group/v1alpha1/types.proto | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/proto/regen/group/v1alpha1/tx.proto b/proto/regen/group/v1alpha1/tx.proto index 9ae8517a27..1fa82fc651 100644 --- a/proto/regen/group/v1alpha1/tx.proto +++ b/proto/regen/group/v1alpha1/tx.proto @@ -5,8 +5,8 @@ package regen.group.v1alpha1; option go_package = "github.com/cosmos/cosmos-sdk/x/group"; import "gogoproto/gogo.proto"; -//import "cosmos_proto/cosmos.proto"; -import "cosmos.proto"; +import "cosmos_proto/cosmos.proto"; +//import "cosmos.proto"; import "google/protobuf/any.proto"; import "google/protobuf/timestamp.proto"; import "regen/group/v1alpha1/types.proto"; diff --git a/proto/regen/group/v1alpha1/types.proto b/proto/regen/group/v1alpha1/types.proto index 4c1697a071..cb285154df 100644 --- a/proto/regen/group/v1alpha1/types.proto +++ b/proto/regen/group/v1alpha1/types.proto @@ -7,8 +7,8 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/group"; import "gogoproto/gogo.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; -//import "cosmos_proto/cosmos.proto"; -import "cosmos.proto"; +import "cosmos_proto/cosmos.proto"; +//import "cosmos.proto"; import "google/protobuf/any.proto"; // Member represents a group member with an account address, From e6affc5582229a07721648f52bfd35dc332d93d2 Mon Sep 17 00:00:00 2001 From: kitty Date: Thu, 16 Sep 2021 16:29:08 +0100 Subject: [PATCH 30/34] goimport format --- regen/types/math/dec.go | 1 + 1 file changed, 1 insertion(+) diff --git a/regen/types/math/dec.go b/regen/types/math/dec.go index 8470340513..b38cb5e4ec 100644 --- a/regen/types/math/dec.go +++ b/regen/types/math/dec.go @@ -2,6 +2,7 @@ package math import ( "fmt" + "github.com/cockroachdb/apd/v2" "github.com/cosmos/cosmos-sdk/types/errors" ) From 73eaa36981e2f02e760fc9e6ebdb357bca3e7ae5 Mon Sep 17 00:00:00 2001 From: kitty Date: Thu, 16 Sep 2021 16:42:13 +0100 Subject: [PATCH 31/34] proto comments --- proto/regen/group/v1alpha1/types.proto | 20 ++++++++++++------ x/group/types.pb.go | 28 +++++++++++++++++--------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/proto/regen/group/v1alpha1/types.proto b/proto/regen/group/v1alpha1/types.proto index cb285154df..640c48c774 100644 --- a/proto/regen/group/v1alpha1/types.proto +++ b/proto/regen/group/v1alpha1/types.proto @@ -282,12 +282,16 @@ message TallyPoll { map counts = 1; } +// Options represents the choices voters can vote for a poll. message Options { option (gogoproto.goproto_getters) = false; repeated string titles = 1; } +// Poll defines a group poll. Any member of a group can submit a poll +// for a group to decide upon. +// The options in a poll can be customised by the creator. message Poll { option (gogoproto.goproto_getters) = false; @@ -297,25 +301,29 @@ message Poll { // group_id is the unique ID of the group. uint64 group_id = 2; + // title is the title of the poll. string title = 3; - Options options = 4 [(gogoproto.nullable) = false];; + // options are the choices of the poll. + Options options = 4 [(gogoproto.nullable) = false]; + // creator is the account address of the poll creator. string creator = 5; + // vote_limit is the maximum number of options each voter can choose. int32 vote_limit = 6; // vote_state contains the sums of all weighted votes for this poll. TallyPoll vote_state = 7 [(gogoproto.nullable) = false]; - // metadata is any arbitrary metadata to attached to the proposal. + // metadata is any arbitrary metadata to attached to the poll. bytes metadata = 8; - // submitted_at is a timestamp specifying when a proposal was submitted. + // submitted_at is a timestamp specifying when a poll was submitted. google.protobuf.Timestamp submitted_at = 9 [(gogoproto.nullable) = false]; - // group_version tracks the version of the group that this proposal corresponds to. - // When group membership is changed, existing proposals from previous group versions will become invalid. + // group_version tracks the version of the group that this poll corresponds to. + // When group membership is changed, existing polls from previous group versions will become invalid. uint64 group_version = 10; // Status defines poll statuses. @@ -335,7 +343,7 @@ message Poll { STATUS_ABORTED = 3 [(gogoproto.enumvalue_customname) = "PollStatusAborted"]; } - // Status represents the high level position in the life cycle of the proposal. Initial value is Submitted. + // Status represents the high level position in the life cycle of the poll. Initial value is Submitted. Status status = 11; // timeout is the timestamp of the block where the poll times out. Header times of the votes diff --git a/x/group/types.pb.go b/x/group/types.pb.go index 5a0b89a281..2b60aef509 100644 --- a/x/group/types.pb.go +++ b/x/group/types.pb.go @@ -816,6 +816,7 @@ func (m *TallyPoll) XXX_DiscardUnknown() { var xxx_messageInfo_TallyPoll proto.InternalMessageInfo +// Options represents the choices voters can vote for a poll. type Options struct { Titles []string `protobuf:"bytes,1,rep,name=titles,proto3" json:"titles,omitempty"` } @@ -853,25 +854,32 @@ func (m *Options) XXX_DiscardUnknown() { var xxx_messageInfo_Options proto.InternalMessageInfo +// Poll defines a group poll. Any member of a group can submit a poll +// for a group to decide upon. +// The options in a poll can be customised by the creator. type Poll struct { // poll_id is the unique id of the poll. PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` // group_id is the unique ID of the group. - GroupId uint64 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` - Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"` - Options Options `protobuf:"bytes,4,opt,name=options,proto3" json:"options"` - Creator string `protobuf:"bytes,5,opt,name=creator,proto3" json:"creator,omitempty"` - VoteLimit int32 `protobuf:"varint,6,opt,name=vote_limit,json=voteLimit,proto3" json:"vote_limit,omitempty"` + GroupId uint64 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + // title is the title of the poll. + Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"` + // options are the choices of the poll. + Options Options `protobuf:"bytes,4,opt,name=options,proto3" json:"options"` + // creator is the account address of the poll creator. + Creator string `protobuf:"bytes,5,opt,name=creator,proto3" json:"creator,omitempty"` + // vote_limit is the maximum number of options each voter can choose. + VoteLimit int32 `protobuf:"varint,6,opt,name=vote_limit,json=voteLimit,proto3" json:"vote_limit,omitempty"` // vote_state contains the sums of all weighted votes for this poll. VoteState TallyPoll `protobuf:"bytes,7,opt,name=vote_state,json=voteState,proto3" json:"vote_state"` - // metadata is any arbitrary metadata to attached to the proposal. + // metadata is any arbitrary metadata to attached to the poll. Metadata []byte `protobuf:"bytes,8,opt,name=metadata,proto3" json:"metadata,omitempty"` - // submitted_at is a timestamp specifying when a proposal was submitted. + // submitted_at is a timestamp specifying when a poll was submitted. SubmittedAt types.Timestamp `protobuf:"bytes,9,opt,name=submitted_at,json=submittedAt,proto3" json:"submitted_at"` - // group_version tracks the version of the group that this proposal corresponds to. - // When group membership is changed, existing proposals from previous group versions will become invalid. + // group_version tracks the version of the group that this poll corresponds to. + // When group membership is changed, existing polls from previous group versions will become invalid. GroupVersion uint64 `protobuf:"varint,10,opt,name=group_version,json=groupVersion,proto3" json:"group_version,omitempty"` - // Status represents the high level position in the life cycle of the proposal. Initial value is Submitted. + // Status represents the high level position in the life cycle of the poll. Initial value is Submitted. Status Poll_Status `protobuf:"varint,11,opt,name=status,proto3,enum=regen.group.v1alpha1.Poll_Status" json:"status,omitempty"` // timeout is the timestamp of the block where the poll times out. Header times of the votes // must be before this end time to be included in the election. From 41be207ea360d6700bf8f596ef51474e0be02edb Mon Sep 17 00:00:00 2001 From: kitty Date: Fri, 24 Sep 2021 13:33:14 +0100 Subject: [PATCH 32/34] update blst to v0.3.5 and more tests for bls --- crypto/keys/bls12381/bls12381_test.go | 158 +++++++++++++++++++++++++- go.mod | 2 +- go.sum | 4 +- 3 files changed, 160 insertions(+), 4 deletions(-) diff --git a/crypto/keys/bls12381/bls12381_test.go b/crypto/keys/bls12381/bls12381_test.go index 8271718a64..558dbd7c5f 100644 --- a/crypto/keys/bls12381/bls12381_test.go +++ b/crypto/keys/bls12381/bls12381_test.go @@ -1,12 +1,20 @@ package bls12381_test import ( + "encoding/base64" + "testing" + + "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/bls12381" bench "github.com/cosmos/cosmos-sdk/crypto/keys/internal/benchmarking" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" - "testing" ) func TestSignAndValidateBls12381(t *testing.T) { @@ -31,7 +39,155 @@ func TestKeyFromSecret(t *testing.T) { sig, err := privKey.Sign(msg) require.Nil(t, err) assert.True(t, pubKey.VerifySignature(msg, sig)) +} + +func TestPubKeyEquals(t *testing.T) { + bls12381PubKey := bls12381.GenPrivKey().PubKey().(*bls12381.PubKey) + + testCases := []struct { + msg string + pubKey cryptotypes.PubKey + other cryptotypes.PubKey + expectEq bool + }{ + { + "different bytes", + bls12381PubKey, + bls12381.GenPrivKey().PubKey(), + false, + }, + { + "equals", + bls12381PubKey, + &bls12381.PubKey{ + Key: bls12381PubKey.Key, + }, + true, + }, + { + "different types", + bls12381PubKey, + secp256k1.GenPrivKey().PubKey(), + false, + }, + } + + for _, tc := range testCases { + t.Run(tc.msg, func(t *testing.T) { + eq := tc.pubKey.Equals(tc.other) + require.Equal(t, eq, tc.expectEq) + }) + } +} + +func TestPrivKeyEquals(t *testing.T) { + bls12381PrivKey := bls12381.GenPrivKey() + + testCases := []struct { + msg string + privKey cryptotypes.PrivKey + other cryptotypes.PrivKey + expectEq bool + }{ + { + "different bytes", + bls12381PrivKey, + bls12381.GenPrivKey(), + false, + }, + { + "equals", + bls12381PrivKey, + &bls12381.PrivKey{ + Key: bls12381PrivKey.Key, + }, + true, + }, + { + "different types", + bls12381PrivKey, + secp256k1.GenPrivKey(), + false, + }, + } + + for _, tc := range testCases { + t.Run(tc.msg, func(t *testing.T) { + eq := tc.privKey.Equals(tc.other) + require.Equal(t, eq, tc.expectEq) + }) + } +} + +func TestMarshalAmino(t *testing.T) { + aminoCdc := codec.NewLegacyAmino() + privKey := bls12381.GenPrivKey() + pubKey := privKey.PubKey().(*bls12381.PubKey) + + testCases := []struct { + desc string + msg codec.AminoMarshaler + typ interface{} + expBinary []byte + expJSON string + }{ + { + "bls12381 private key", + privKey, + &bls12381.PrivKey{}, + append([]byte{32}, privKey.Bytes()...), // Length-prefixed. + "\"" + base64.StdEncoding.EncodeToString(privKey.Bytes()) + "\"", + }, + { + "bls12381 public key", + pubKey, + &bls12381.PubKey{}, + append([]byte{96}, pubKey.Bytes()...), // Length-prefixed. + "\"" + base64.StdEncoding.EncodeToString(pubKey.Bytes()) + "\"", + }, + } + + for _, tc := range testCases { + t.Run(tc.desc, func(t *testing.T) { + // Do a round trip of encoding/decoding binary. + bz, err := aminoCdc.Marshal(tc.msg) + require.NoError(t, err) + require.Equal(t, tc.expBinary, bz) + + err = aminoCdc.Unmarshal(bz, tc.typ) + require.NoError(t, err) + + require.Equal(t, tc.msg, tc.typ) + + // Do a round trip of encoding/decoding JSON. + bz, err = aminoCdc.MarshalJSON(tc.msg) + require.NoError(t, err) + require.Equal(t, tc.expJSON, string(bz)) + + err = aminoCdc.UnmarshalJSON(bz, tc.typ) + require.NoError(t, err) + + require.Equal(t, tc.msg, tc.typ) + }) + } +} + +func TestMarshalJSON(t *testing.T) { + require := require.New(t) + privKey := bls12381.GenPrivKey() + pk := privKey.PubKey() + + registry := types.NewInterfaceRegistry() + cryptocodec.RegisterInterfaces(registry) + cdc := codec.NewProtoCodec(registry) + + bz, err := cdc.MarshalInterfaceJSON(pk) + require.NoError(err) + var pk2 cryptotypes.PubKey + err = cdc.UnmarshalInterfaceJSON(bz, &pk2) + require.NoError(err) + require.True(pk2.Equals(pk)) } func BenchmarkSignBls(b *testing.B) { diff --git a/go.mod b/go.mod index 9033a2fc01..870e01ab43 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.8.0 github.com/stretchr/testify v1.7.0 - github.com/supranational/blst v0.3.4 + github.com/supranational/blst v0.3.5 github.com/tendermint/btcd v0.1.1 github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 github.com/tendermint/go-amino v0.16.0 diff --git a/go.sum b/go.sum index 9310a4a9f0..02fb6fe25c 100644 --- a/go.sum +++ b/go.sum @@ -729,8 +729,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/supranational/blst v0.3.4 h1:iZE9lBMoywK2uy2U/5hDOvobQk9FnOQ2wNlu9GmRCoA= -github.com/supranational/blst v0.3.4/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/supranational/blst v0.3.5 h1:/pey7U712GgJBSD1XTiJ5iBqjYIH3QNdrjRoGXlJJ60= +github.com/supranational/blst v0.3.5/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca h1:Ld/zXl5t4+D69SiV4JoN7kkfvJdOWlPpfxrzxpLMoUk= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= From afecb2874e6a80fe7fb81e5941c1a814d42fb040 Mon Sep 17 00:00:00 2001 From: kitounliu <58184672+kitounliu@users.noreply.github.com> Date: Fri, 8 Oct 2021 15:32:21 +0100 Subject: [PATCH 33/34] Update x/auth/ante/sigverify.go Co-authored-by: daeMOn --- x/auth/ante/sigverify.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 87ed963578..42d222ef28 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -347,7 +347,7 @@ func (spvd SetPopValidDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate switch pk.(type) { case *bls12381.PubKey, *secp256k1.PubKey, *ed25519.PubKey: - if !acc.GetPopValid() { + if !acc.GetPopValid() { if err := acc.SetPopValid(true); err != nil { return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPop, err.Error()) } From abae62dc8d3a699eff7dc991233a06650da6d83e Mon Sep 17 00:00:00 2001 From: kitounliu <58184672+kitounliu@users.noreply.github.com> Date: Fri, 8 Oct 2021 15:36:06 +0100 Subject: [PATCH 34/34] Update x/group/client/util.go Co-authored-by: daeMOn --- x/group/client/util.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x/group/client/util.go b/x/group/client/util.go index 02052e380b..0d91589a0a 100644 --- a/x/group/client/util.go +++ b/x/group/client/util.go @@ -29,10 +29,12 @@ func parseMembers(clientCtx client.Context, membersFile string) ([]group.Member, } func execFromString(execStr string) group.Exec { - exec := group.Exec_EXEC_UNSPECIFIED + var exec group.Exec switch execStr { case ExecTry: exec = group.Exec_EXEC_TRY + default: + exec = group.Exec_EXEC_UNSPECIFIED } return exec }