diff --git a/.tool-versions b/.tool-versions index 9d7e0bcc..9264d463 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -golang 1.21.3 \ No newline at end of file +golang 1.21.8 diff --git a/ROSETTA.md b/ROSETTA.md new file mode 100644 index 00000000..096f1ce1 --- /dev/null +++ b/ROSETTA.md @@ -0,0 +1,39 @@ +Enable Rosetta support by modifying `.kujira/config/config.toml` as follows. + +``` +############################################################################### +### Rosetta Configuration ### +############################################################################### + +[rosetta] + +# Enable defines if the Rosetta API server should be enabled. +enable = true + +# Address defines the Rosetta API server to listen on. +address = ":8080" + +# Network defines the name of the blockchain that will be returned by Rosetta. +blockchain = "kujira" + +# Network defines the name of the network that will be returned by Rosetta. +network = "kaiyo-1" + +# Retries defines the number of retries when connecting to the node before failing. +retries = 3 + +# Offline defines if Rosetta server should run in offline mode. +offline = false + +# EnableDefaultSuggestedFee defines if the server should suggest fee by default. +# If 'construction/medata' is called without gas limit and gas price, +# suggested fee based on gas-to-suggest and denom-to-suggest will be given. +enable-fee-suggestion = false + +# GasToSuggest defines gas limit when calculating the fee +gas-to-suggest = 200000 + +# DenomToSuggest defines the defult denom for fee suggestion. +# Price must be in minimum-gas-prices. +denom-to-suggest = "ukuji" +``` diff --git a/UPGRADES.md b/UPGRADES.md new file mode 100644 index 00000000..f02b7064 --- /dev/null +++ b/UPGRADES.md @@ -0,0 +1,16 @@ +# kujira + +**kujira** is a blockchain built using Cosmos SDK and Comet BFT + +Please refer to [docs.kujira.app](https://docs.kujira.app/) and join our [Discord](https://t.co/kur923FTZk) for guidance in getting set up. + +## Upgrades + +- 0 -> v0.4.0 +- 01764000 -> v0.5.0 +- 03495000 -> v0.6.0 +- 04553726 -> v0.6.4 **manual halt-height required** +- 05196234 -> v0.7.1 +- 09226200 -> v0.8.4 **tag `v0.8.4-mainnet`** +- 11478516 -> v0.8.7 **manual halt-height required** +- 16610000 -> v0.9.3-1 (note `-1` suffix) diff --git a/app/ante.go b/app/ante.go index 99ee1625..f446bf95 100644 --- a/app/ante.go +++ b/app/ante.go @@ -42,7 +42,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { sigGasConsumer := options.SigGasConsumer if sigGasConsumer == nil { - sigGasConsumer = ante.DefaultSigVerificationGasConsumer + sigGasConsumer = SigVerificationGasConsumer } anteDecorators := []sdk.AnteDecorator{ diff --git a/app/app.go b/app/app.go index 7f865098..6f0f5520 100644 --- a/app/app.go +++ b/app/app.go @@ -9,6 +9,8 @@ import ( "path/filepath" appparams "github.com/Team-Kujira/core/app/params" + legacygovalliance "github.com/Team-Kujira/core/legacygov/alliance" + legacygovscheduler "github.com/Team-Kujira/core/legacygov/scheduler" "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" "github.com/cosmos/gogoproto/proto" @@ -23,6 +25,7 @@ import ( feegrantkeeper "cosmossdk.io/x/feegrant/keeper" feegrantmodule "cosmossdk.io/x/feegrant/module" "cosmossdk.io/x/tx/signing" + kujiracryptocodec "github.com/Team-Kujira/core/crypto/codec" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -37,7 +40,6 @@ import ( "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/mempool" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" @@ -295,6 +297,10 @@ func New( std.RegisterLegacyAminoCodec(legacyAmino) std.RegisterInterfaces(interfaceRegistry) + kujiracryptocodec.RegisterCrypto(legacyAmino) + kujiracryptocodec.RegisterInterfaces(interfaceRegistry) + legacygovalliance.RegisterInterfaces(interfaceRegistry) + legacygovscheduler.RegisterInterfaces(interfaceRegistry) bApp := baseapp.NewBaseApp(Name, logger, db, txConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) @@ -650,9 +656,11 @@ func New( app.BankKeeper, app.OracleKeeper, *app.DenomKeeper, + app.BatchKeeper, *app.IBCKeeper, app.CwICAKeeper, app.ICAControllerKeeper, + app.TransferKeeper, keys[ibcexported.StoreKey], ), wasmOpts...) @@ -733,6 +741,7 @@ func New( var transferStack ibcporttypes.IBCModule transferStack = transfer.NewIBCModule(app.TransferKeeper) transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper) + transferStack = cwica.NewIBCMiddleware(transferStack, app.CwICAKeeper, app.IBCKeeper.ChannelKeeper) // Create Interchain Accounts Stack // SendPacket, since it is originating from the application to core IBC: @@ -743,7 +752,7 @@ func New( icaControllerStack = cwica.NewIBCModule(app.CwICAKeeper) icaControllerStack = icacontroller.NewIBCMiddleware(icaControllerStack, app.ICAControllerKeeper) - icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper) + // icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper) // RecvPacket, message that originates from core IBC and goes down to app, the flow is: // channel.RecvPacket -> fee.OnRecvPacket -> icaHost.OnRecvPacket @@ -1091,7 +1100,7 @@ func New( BankKeeper: app.BankKeeper, FeegrantKeeper: app.FeeGrantKeeper, SignModeHandler: txConfig.SignModeHandler(), - SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + SigGasConsumer: SigVerificationGasConsumer, }, IBCKeeper: app.IBCKeeper, WasmConfig: &wasmConfig, @@ -1107,16 +1116,14 @@ func New( app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) - nonceMempool := mempool.NewSenderNonceMempool() propHandler := oracleabci.NewProposalHandler( logger, app.OracleKeeper, app.StakingKeeper, app.ModuleManager, - nonceMempool, + nil, bApp, ) - bApp.SetMempool(nonceMempool) bApp.SetPrepareProposal(propHandler.PrepareProposal()) bApp.SetProcessProposal(propHandler.ProcessProposal()) bApp.SetPreBlocker(propHandler.PreBlocker) diff --git a/app/sigverify.go b/app/sigverify.go new file mode 100644 index 00000000..a1de2308 --- /dev/null +++ b/app/sigverify.go @@ -0,0 +1,56 @@ +package app + +import ( + "fmt" + + errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" + authn "github.com/Team-Kujira/core/crypto/keys/authn" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256r1" + "github.com/cosmos/cosmos-sdk/crypto/types/multisig" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/tx/signing" + "github.com/cosmos/cosmos-sdk/x/auth/ante" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// SigVerificationGasConsumer is the implementation of SignatureVerificationGasConsumer. It consumes gas +// for signature verification based upon the public key type. The cost is fetched from the given params and is matched +// by the concrete type. +func SigVerificationGasConsumer( + meter storetypes.GasMeter, sig signing.SignatureV2, params authtypes.Params, +) error { + pubkey := sig.PubKey + switch pubkey := pubkey.(type) { + case *ed25519.PubKey: + meter.ConsumeGas(params.SigVerifyCostED25519, "ante verify: ed25519") + return errorsmod.Wrap(sdkerrors.ErrInvalidPubKey, "ED25519 public keys are unsupported") + + case *secp256k1.PubKey: + meter.ConsumeGas(params.SigVerifyCostSecp256k1, "ante verify: secp256k1") + return nil + + case *secp256r1.PubKey: + meter.ConsumeGas(params.SigVerifyCostSecp256r1(), "ante verify: secp256r1") + return nil + + case *authn.PubKey: + meter.ConsumeGas(params.SigVerifyCostSecp256r1(), "ante verify: authn") + return nil + + case multisig.PubKey: + multisignature, ok := sig.Data.(*signing.MultiSignatureData) + if !ok { + return fmt.Errorf("expected %T, got, %T", &signing.MultiSignatureData{}, sig.Data) + } + err := ante.ConsumeMultisignatureVerificationGas(meter, multisignature, pubkey, params, sig.Sequence) + if err != nil { + return err + } + return nil + default: + return errorsmod.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey) + } +} diff --git a/cmd/kujirad/cmd/root.go b/cmd/kujirad/cmd/root.go index 1f99db59..793a6d43 100644 --- a/cmd/kujirad/cmd/root.go +++ b/cmd/kujirad/cmd/root.go @@ -4,6 +4,7 @@ import ( "errors" "io" "os" + "time" "github.com/prometheus/client_golang/prometheus" "github.com/spf13/cast" @@ -123,6 +124,7 @@ func NewRootCmd() *cobra.Command { // return tmcfg.DefaultConfig if no custom configuration is required for the application. func initTendermintConfig() *tmcfg.Config { cfg := tmcfg.DefaultConfig() + cfg.Consensus.TimeoutCommit = time.Millisecond * 1500 cfg.P2P.Seeds = "" diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go new file mode 100644 index 00000000..59cd8bdc --- /dev/null +++ b/crypto/codec/amino.go @@ -0,0 +1,14 @@ +package codec + +import ( + authn "github.com/Team-Kujira/core/crypto/keys/authn" + + "github.com/cosmos/cosmos-sdk/codec" +) + +// RegisterCrypto registers all crypto dependency types with the provided Amino +// codec. +func RegisterCrypto(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(authn.PubKey{}, + authn.PubKeyName, nil) +} diff --git a/crypto/codec/proto.go b/crypto/codec/proto.go new file mode 100644 index 00000000..3606560b --- /dev/null +++ b/crypto/codec/proto.go @@ -0,0 +1,13 @@ +package codec + +import ( + authn "github.com/Team-Kujira/core/crypto/keys/authn" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" +) + +// RegisterInterfaces registers the sdk.Tx interface. +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + var pk *cryptotypes.PubKey + registry.RegisterImplementations(pk, &authn.PubKey{}) +} diff --git a/crypto/keys/authn/authn.go b/crypto/keys/authn/authn.go new file mode 100644 index 00000000..b7e5e61a --- /dev/null +++ b/crypto/keys/authn/authn.go @@ -0,0 +1,82 @@ +package authn + +import ( + "bytes" + "fmt" + + "github.com/cometbft/cometbft/crypto" + + errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/types/address" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/gogoproto/proto" +) + +const ( + keyType = "authn" + PubKeyName = "tendermint/PubKeyAuthn" +) + +var ( + _ cryptotypes.PubKey = &PubKey{} + _ codec.AminoMarshaler = &PubKey{} +) + +// PubKeySize is comprised of 32 bytes for one field element +// (the x-coordinate), plus one byte for the parity of the y-coordinate. +const PubKeySize = 33 + +// Address returns a Bitcoin style addresses: RIPEMD160(SHA256(pubkey)) +func (pubKey *PubKey) Address() crypto.Address { + if len(pubKey.Key) != PubKeySize { + panic("length of pubkey is incorrect") + } + + return address.Hash(proto.MessageName(pubKey), pubKey.Key) +} + +// Bytes returns the pubkey byte format. +func (pubKey *PubKey) Bytes() []byte { + return pubKey.Key +} + +func (pubKey *PubKey) String() string { + return fmt.Sprintf("PubKeyAuthn{%X}", pubKey.Key) +} + +func (pubKey *PubKey) Type() string { + return keyType +} + +func (pubKey *PubKey) Equals(other cryptotypes.PubKey) bool { + return pubKey.Type() == other.Type() && bytes.Equal(pubKey.Bytes(), other.Bytes()) +} + +// 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 errorsmod.Wrap(sdkerrors.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/authn/keys.pb.go b/crypto/keys/authn/keys.pb.go new file mode 100644 index 00000000..910cc2e5 --- /dev/null +++ b/crypto/keys/authn/keys.pb.go @@ -0,0 +1,375 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kujira/crypto/authn/keys.proto + +package authn + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// PubKey defines a authn public key +type PubKey struct { + KeyId string `protobuf:"bytes,1,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty"` + Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *PubKey) Reset() { *m = PubKey{} } +func (*PubKey) ProtoMessage() {} +func (*PubKey) Descriptor() ([]byte, []int) { + return fileDescriptor_83c6c671dbc05afe, []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) GetKeyId() string { + if m != nil { + return m.KeyId + } + return "" +} + +func (m *PubKey) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func init() { + proto.RegisterType((*PubKey)(nil), "kujira.crypto.authn.PubKey") +} + +func init() { proto.RegisterFile("kujira/crypto/authn/keys.proto", fileDescriptor_83c6c671dbc05afe) } + +var fileDescriptor_83c6c671dbc05afe = []byte{ + // 242 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcb, 0x2e, 0xcd, 0xca, + 0x2c, 0x4a, 0xd4, 0x4f, 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0xd7, 0x4f, 0x2c, 0x2d, 0xc9, 0xc8, 0xd3, + 0xcf, 0x4e, 0xad, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xc8, 0xeb, 0x41, + 0xe4, 0xf5, 0xc0, 0xf2, 0x52, 0x82, 0x89, 0xb9, 0x99, 0x79, 0xf9, 0xfa, 0x60, 0x12, 0xa2, 0x4e, + 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xcc, 0xd4, 0x07, 0xb1, 0x20, 0xa2, 0x4a, 0x09, 0x5c, 0x6c, + 0x01, 0xa5, 0x49, 0xde, 0xa9, 0x95, 0x42, 0xa2, 0x5c, 0x6c, 0xd9, 0xa9, 0x95, 0xf1, 0x99, 0x29, + 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0xac, 0xd9, 0xa9, 0x95, 0x9e, 0x29, 0x42, 0x02, 0x5c, + 0xcc, 0xd9, 0xa9, 0x95, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0x3c, 0x41, 0x20, 0xa6, 0x95, 0xee, 0x8c, + 0x05, 0xf2, 0x0c, 0x5d, 0xcf, 0x37, 0x68, 0x89, 0x95, 0xa4, 0xe6, 0xa5, 0xa4, 0x16, 0xe5, 0x66, + 0xe6, 0x95, 0xe8, 0x43, 0x0c, 0x71, 0x04, 0x59, 0x3e, 0xe9, 0xf9, 0x06, 0x2d, 0x4e, 0x90, 0x51, + 0x69, 0x99, 0xa9, 0x39, 0x29, 0x4e, 0xee, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, + 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, + 0x10, 0xa5, 0x9b, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x1f, 0x92, 0x9a, + 0x98, 0xab, 0xeb, 0x0d, 0xf5, 0x69, 0x7e, 0x51, 0x2a, 0xcc, 0xbb, 0x20, 0x8f, 0x42, 0xfc, 0x9c, + 0xc4, 0x06, 0x76, 0xb1, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xf3, 0x1b, 0x67, 0x98, 0x11, 0x01, + 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] = 0x12 + } + if len(m.KeyId) > 0 { + i -= len(m.KeyId) + copy(dAtA[i:], m.KeyId) + i = encodeVarintKeys(dAtA, i, uint64(len(m.KeyId))) + 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.KeyId) + if l > 0 { + n += 1 + l + sovKeys(uint64(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 KeyId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeys + } + 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 ErrInvalidLengthKeys + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthKeys + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.KeyId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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/authn/signature.go b/crypto/keys/authn/signature.go new file mode 100644 index 00000000..a3767378 --- /dev/null +++ b/crypto/keys/authn/signature.go @@ -0,0 +1,86 @@ +package authn + +import ( + // "bytes" + "bytes" + "crypto" + "crypto/elliptic" + "crypto/sha256" + "encoding/base64" + "encoding/hex" + "encoding/json" + + ecdsa "crypto/ecdsa" +) + +type Signature struct { + AuthenticatorData string `json:"authenticatorData"` + ClientDataJSON string `json:"clientDataJSON"` + Signature string `json:"signature"` +} + +// VerifyBytes verifies a signature of the form R || S. +// It rejects signatures which are not in lower-S form. +// See https://github.com/Team-Kujira/kujira.js/blob/master/src/authn/AuthnWebSigner.ts for a reference implementation +// signing a transaction with the webauthn API +func (pubKey *PubKey) VerifySignature(msg []byte, sigStr []byte) bool { + sig := Signature{} + err := json.Unmarshal(sigStr, &sig) + if err != nil { + return false + } + + clientDataJSON, err := hex.DecodeString(sig.ClientDataJSON) + if err != nil { + return false + } + + clientData := make(map[string]interface{}) + err = json.Unmarshal(clientDataJSON, &clientData) + if err != nil { + return false + } + + challengeBase64, ok := clientData["challenge"].(string) + if !ok { + return false + } + challenge, err := base64.RawURLEncoding.DecodeString(challengeBase64) + if err != nil { + return false + } + + // Check challenge == msg + if !bytes.Equal(challenge, msg) { + return false + } + + publicKey := &ecdsa.PublicKey{Curve: elliptic.P256()} + publicKey.X, publicKey.Y = elliptic.UnmarshalCompressed(elliptic.P256(), pubKey.Key) + if publicKey.X == nil || publicKey.Y == nil { + return false + } + + signatureBytes, err := hex.DecodeString(sig.Signature) + if err != nil { + return false + } + + authenticatorData, err := hex.DecodeString(sig.AuthenticatorData) + if err != nil { + return false + } + + // check authenticatorData length + if len(authenticatorData) < 37 { + return false + } + + clientDataHash := sha256.Sum256(clientDataJSON) + payload := append(authenticatorData, clientDataHash[:]...) + + h := crypto.SHA256.New() + h.Write(payload) + + return ecdsa.VerifyASN1(publicKey, h.Sum(nil), signatureBytes) +} diff --git a/crypto/keys/authn/signature_test.go b/crypto/keys/authn/signature_test.go new file mode 100644 index 00000000..264590d8 --- /dev/null +++ b/crypto/keys/authn/signature_test.go @@ -0,0 +1,520 @@ +package authn + +import ( + "crypto" + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "crypto/sha256" + "encoding/base64" + "encoding/hex" + "encoding/json" + "testing" + + cometcrypto "github.com/cometbft/cometbft/crypto" + "github.com/stretchr/testify/require" +) + +// CollectedClientData represents the contextual bindings of both the WebAuthn Relying Party +// and the client. It is a key-value mapping whose keys are strings. Values can be any type +// that has a valid encoding in JSON. Its structure is defined by the following Web IDL. +// https://www.w3.org/TR/webauthn/#sec-client-data +type CollectedClientData struct { + // Type the string "webauthn.create" when creating new credentials, + // and "webauthn.get" when getting an assertion from an existing credential. The + // purpose of this member is to prevent certain types of signature confusion attacks + //(where an attacker substitutes one legitimate signature for another). + Type CeremonyType `json:"type"` + Challenge string `json:"challenge"` + Origin string `json:"origin"` + TokenBinding *TokenBinding `json:"tokenBinding,omitempty"` + // Chromium (Chrome) returns a hint sometimes about how to handle clientDataJSON in a safe manner + Hint string `json:"new_keys_may_be_added_here,omitempty"` +} + +type TokenBinding struct { + Status TokenBindingStatus `json:"status"` + ID string `json:"id,omitempty"` +} + +type TokenBindingStatus string + +type CeremonyType string + +const ( + CreateCeremony CeremonyType = "webauthn.create" + AssertCeremony CeremonyType = "webauthn.get" +) + +func GenerateAuthnKey(t *testing.T) (*ecdsa.PrivateKey, PubKey) { + curve := elliptic.P256() + privateKey, err := ecdsa.GenerateKey(curve, rand.Reader) + require.NoError(t, err) + pkBytes := elliptic.MarshalCompressed(curve, privateKey.PublicKey.X, privateKey.PublicKey.Y) + pk := PubKey{ + KeyId: "a099eda0fb05e5783379f73a06acca726673b8e07e436edcd0d71645982af65c", + Key: pkBytes, + } + return privateKey, pk +} + +func GenerateClientData(t *testing.T, msg []byte) []byte { + clientData := CollectedClientData{ + // purpose of this member is to prevent certain types of signature confusion attacks + //(where an attacker substitutes one legitimate signature for another). + Type: "webauthn.create", + Challenge: base64.RawURLEncoding.EncodeToString(msg), + Origin: "https://blue.kujira.network", + TokenBinding: nil, + Hint: "", + } + clientDataJSON, err := json.Marshal(clientData) + require.NoError(t, err) + return clientDataJSON +} + +func TestVerifySignature(t *testing.T) { + privateKey, pk := GenerateAuthnKey(t) + authenticatorData := cometcrypto.CRandBytes(37) + msg := cometcrypto.CRandBytes(1000) + clientDataJSON := GenerateClientData(t, msg) + clientDataHash := sha256.Sum256(clientDataJSON) + payload := append(authenticatorData, clientDataHash[:]...) + + h := crypto.SHA256.New() + h.Write(payload) + digest := h.Sum(nil) + + sig, err := ecdsa.SignASN1(rand.Reader, privateKey, digest) + require.NoError(t, err) + + cborSig := Signature{ + AuthenticatorData: hex.EncodeToString(authenticatorData), + ClientDataJSON: hex.EncodeToString(clientDataJSON), + Signature: hex.EncodeToString(sig), + } + + sigBytes, err := json.Marshal(cborSig) + require.NoError(t, err) + require.True(t, pk.VerifySignature(msg, sigBytes)) + + // Mutate the signature + for i := range sigBytes { + sigCpy := make([]byte, len(sigBytes)) + copy(sigCpy, sigBytes) + sigCpy[i] ^= byte(0xFF) + require.False(t, pk.VerifySignature(msg, sigCpy)) + } + + // Mutate the message + msg[1] ^= byte(2) + require.False(t, pk.VerifySignature(msg, sigBytes)) +} + +func TestVerifySignature_ChallengeStdEncoding(t *testing.T) { + privateKey, pk := GenerateAuthnKey(t) + authenticatorData := cometcrypto.CRandBytes(37) + msg := cometcrypto.CRandBytes(1000) + clientData := CollectedClientData{ + // purpose of this member is to prevent certain types of signature confusion attacks + //(where an attacker substitutes one legitimate signature for another). + Type: "webauthn.create", + Challenge: base64.StdEncoding.EncodeToString(msg), + Origin: "https://blue.kujira.network", + TokenBinding: nil, + Hint: "", + } + clientDataJSON, err := json.Marshal(clientData) + require.NoError(t, err) + clientDataHash := sha256.Sum256(clientDataJSON) + payload := append(authenticatorData, clientDataHash[:]...) + + h := crypto.SHA256.New() + h.Write(payload) + digest := h.Sum(nil) + + sig, err := ecdsa.SignASN1(rand.Reader, privateKey, digest) + require.NoError(t, err) + + cborSig := Signature{ + AuthenticatorData: hex.EncodeToString(authenticatorData), + ClientDataJSON: hex.EncodeToString(clientDataJSON), + Signature: hex.EncodeToString(sig), + } + + sigBytes, err := json.Marshal(cborSig) + require.NoError(t, err) + require.False(t, pk.VerifySignature(msg, sigBytes)) +} + +func TestVerifySignature_ChallengeHexEncoding(t *testing.T) { + privateKey, pk := GenerateAuthnKey(t) + authenticatorData := cometcrypto.CRandBytes(37) + msg := cometcrypto.CRandBytes(1000) + clientData := CollectedClientData{ + // purpose of this member is to prevent certain types of signature confusion attacks + //(where an attacker substitutes one legitimate signature for another). + Type: "webauthn.create", + Challenge: hex.EncodeToString(msg), + Origin: "https://blue.kujira.network", + TokenBinding: nil, + Hint: "", + } + clientDataJSON, err := json.Marshal(clientData) + require.NoError(t, err) + clientDataHash := sha256.Sum256(clientDataJSON) + payload := append(authenticatorData, clientDataHash[:]...) + + h := crypto.SHA256.New() + h.Write(payload) + digest := h.Sum(nil) + + sig, err := ecdsa.SignASN1(rand.Reader, privateKey, digest) + require.NoError(t, err) + + cborSig := Signature{ + AuthenticatorData: hex.EncodeToString(authenticatorData), + ClientDataJSON: hex.EncodeToString(clientDataJSON), + Signature: hex.EncodeToString(sig), + } + + sigBytes, err := json.Marshal(cborSig) + require.NoError(t, err) + require.False(t, pk.VerifySignature(msg, sigBytes)) +} + +func TestVerifySignature_ChallengeEmpty(t *testing.T) { + privateKey, pk := GenerateAuthnKey(t) + authenticatorData := cometcrypto.CRandBytes(37) + msg := cometcrypto.CRandBytes(1000) + clientData := CollectedClientData{ + // purpose of this member is to prevent certain types of signature confusion attacks + //(where an attacker substitutes one legitimate signature for another). + Type: "webauthn.create", + Challenge: "", + Origin: "https://blue.kujira.network", + TokenBinding: nil, + Hint: "", + } + clientDataJSON, err := json.Marshal(clientData) + require.NoError(t, err) + clientDataHash := sha256.Sum256(clientDataJSON) + payload := append(authenticatorData, clientDataHash[:]...) + + h := crypto.SHA256.New() + h.Write(payload) + digest := h.Sum(nil) + + sig, err := ecdsa.SignASN1(rand.Reader, privateKey, digest) + require.NoError(t, err) + + cborSig := Signature{ + AuthenticatorData: hex.EncodeToString(authenticatorData), + ClientDataJSON: hex.EncodeToString(clientDataJSON), + Signature: hex.EncodeToString(sig), + } + + sigBytes, err := json.Marshal(cborSig) + require.NoError(t, err) + require.False(t, pk.VerifySignature(msg, sigBytes)) +} + +func TestVerifySignature_ChallengeNil(t *testing.T) { + privateKey, pk := GenerateAuthnKey(t) + authenticatorData := cometcrypto.CRandBytes(37) + msg := cometcrypto.CRandBytes(1000) + clientData := map[string]interface{}{ + // purpose of this member is to prevent certain types of signature confusion attacks + //(where an attacker substitutes one legitimate signature for another). + "type": "webauthn.create", + "origin": "https://blue.kujira.network", + } + clientDataJSON, err := json.Marshal(clientData) + require.NoError(t, err) + clientDataHash := sha256.Sum256(clientDataJSON) + payload := append(authenticatorData, clientDataHash[:]...) + + h := crypto.SHA256.New() + h.Write(payload) + digest := h.Sum(nil) + + sig, err := ecdsa.SignASN1(rand.Reader, privateKey, digest) + require.NoError(t, err) + + cborSig := Signature{ + AuthenticatorData: hex.EncodeToString(authenticatorData), + ClientDataJSON: hex.EncodeToString(clientDataJSON), + Signature: hex.EncodeToString(sig), + } + + sigBytes, err := json.Marshal(cborSig) + require.NoError(t, err) + require.False(t, pk.VerifySignature(msg, sigBytes)) +} + +func TestVerifySignature_ChallengeInteger(t *testing.T) { + privateKey, pk := GenerateAuthnKey(t) + authenticatorData := cometcrypto.CRandBytes(37) + msg := cometcrypto.CRandBytes(1000) + clientData := map[string]interface{}{ + // purpose of this member is to prevent certain types of signature confusion attacks + //(where an attacker substitutes one legitimate signature for another). + "type": "webauthn.create", + "origin": "https://blue.kujira.network", + "challenge": 1, + } + clientDataJSON, err := json.Marshal(clientData) + require.NoError(t, err) + clientDataHash := sha256.Sum256(clientDataJSON) + payload := append(authenticatorData, clientDataHash[:]...) + + h := crypto.SHA256.New() + h.Write(payload) + digest := h.Sum(nil) + + sig, err := ecdsa.SignASN1(rand.Reader, privateKey, digest) + require.NoError(t, err) + + cborSig := Signature{ + AuthenticatorData: hex.EncodeToString(authenticatorData), + ClientDataJSON: hex.EncodeToString(clientDataJSON), + Signature: hex.EncodeToString(sig), + } + + sigBytes, err := json.Marshal(cborSig) + require.NoError(t, err) + require.False(t, pk.VerifySignature(msg, sigBytes)) +} + +func TestVerifySignature_ClientDataJSONEmpty(t *testing.T) { + privateKey, pk := GenerateAuthnKey(t) + authenticatorData := cometcrypto.CRandBytes(37) + msg := cometcrypto.CRandBytes(1000) + payload := authenticatorData + + h := crypto.SHA256.New() + h.Write(payload) + digest := h.Sum(nil) + + sig, err := ecdsa.SignASN1(rand.Reader, privateKey, digest) + require.NoError(t, err) + + type CBORSignature struct { + AuthenticatorData string `json:"authenticatorData"` + Signature string `json:"signature"` + } + cborSig := CBORSignature{ + AuthenticatorData: hex.EncodeToString(authenticatorData), + Signature: hex.EncodeToString(sig), + } + + sigBytes, err := json.Marshal(cborSig) + require.NoError(t, err) + require.False(t, pk.VerifySignature(msg, sigBytes)) +} + +func TestVerifySignature_UncompressedPubKey(t *testing.T) { + curve := elliptic.P256() + privateKey, err := ecdsa.GenerateKey(curve, rand.Reader) + require.NoError(t, err) + pkBytes := elliptic.Marshal(curve, privateKey.PublicKey.X, privateKey.PublicKey.Y) + pk := PubKey{ + KeyId: "a099eda0fb05e5783379f73a06acca726673b8e07e436edcd0d71645982af65c", + Key: pkBytes, + } + + authenticatorData := cometcrypto.CRandBytes(37) + msg := cometcrypto.CRandBytes(1000) + + clientDataJSON := GenerateClientData(t, msg) + clientDataHash := sha256.Sum256(clientDataJSON) + payload := append(authenticatorData, clientDataHash[:]...) + + h := crypto.SHA256.New() + h.Write(payload) + digest := h.Sum(nil) + + sig, err := ecdsa.SignASN1(rand.Reader, privateKey, digest) + require.NoError(t, err) + + cborSig := Signature{ + AuthenticatorData: hex.EncodeToString(authenticatorData), + ClientDataJSON: hex.EncodeToString(clientDataJSON), + Signature: hex.EncodeToString(sig), + } + + sigBytes, err := json.Marshal(cborSig) + require.NoError(t, err) + require.False(t, pk.VerifySignature(msg, sigBytes)) +} + +func TestVerifySignature_AnotherPubKey(t *testing.T) { + privateKey, _ := GenerateAuthnKey(t) + _, pk := GenerateAuthnKey(t) + + authenticatorData := cometcrypto.CRandBytes(37) + msg := cometcrypto.CRandBytes(1000) + + clientDataJSON := GenerateClientData(t, msg) + clientDataHash := sha256.Sum256(clientDataJSON) + payload := append(authenticatorData, clientDataHash[:]...) + + h := crypto.SHA256.New() + h.Write(payload) + digest := h.Sum(nil) + + sig, err := ecdsa.SignASN1(rand.Reader, privateKey, digest) + require.NoError(t, err) + + cborSig := Signature{ + AuthenticatorData: hex.EncodeToString(authenticatorData), + ClientDataJSON: hex.EncodeToString(clientDataJSON), + Signature: hex.EncodeToString(sig), + } + + sigBytes, err := json.Marshal(cborSig) + require.NoError(t, err) + require.False(t, pk.VerifySignature(msg, sigBytes)) +} + +func TestVerifySignature_SignaureNotInASN1(t *testing.T) { + privateKey, pk := GenerateAuthnKey(t) + authenticatorData := cometcrypto.CRandBytes(37) + msg := cometcrypto.CRandBytes(1000) + + clientDataJSON := GenerateClientData(t, msg) + clientDataHash := sha256.Sum256(clientDataJSON) + payload := append(authenticatorData, clientDataHash[:]...) + + h := crypto.SHA256.New() + h.Write(payload) + digest := h.Sum(nil) + + sigR, sigS, err := ecdsa.Sign(rand.Reader, privateKey, digest) + require.NoError(t, err) + sig := append(sigR.Bytes(), sigS.Bytes()...) + + cborSig := Signature{ + AuthenticatorData: hex.EncodeToString(authenticatorData), + ClientDataJSON: hex.EncodeToString(clientDataJSON), + Signature: hex.EncodeToString(sig), + } + + sigBytes, err := json.Marshal(cborSig) + require.NoError(t, err) + require.False(t, pk.VerifySignature(msg, sigBytes)) +} + +func TestVerifySignature_EmptyAuthenticatorData(t *testing.T) { + privateKey, pk := GenerateAuthnKey(t) + authenticatorData := cometcrypto.CRandBytes(37) + msg := cometcrypto.CRandBytes(1000) + + clientDataJSON := GenerateClientData(t, msg) + clientDataHash := sha256.Sum256(clientDataJSON) + payload := append(authenticatorData, clientDataHash[:]...) + + h := crypto.SHA256.New() + h.Write(payload) + digest := h.Sum(nil) + + sig, err := ecdsa.SignASN1(rand.Reader, privateKey, digest) + require.NoError(t, err) + + cborSig := Signature{ + AuthenticatorData: "", + ClientDataJSON: hex.EncodeToString(clientDataJSON), + Signature: hex.EncodeToString(sig), + } + + sigBytes, err := json.Marshal(cborSig) + require.NoError(t, err) + require.False(t, pk.VerifySignature(msg, sigBytes)) +} + +func TestVerifySignature_SignatureEncodingInBase64(t *testing.T) { + privateKey, pk := GenerateAuthnKey(t) + authenticatorData := cometcrypto.CRandBytes(37) + msg := cometcrypto.CRandBytes(1000) + + clientDataJSON := GenerateClientData(t, msg) + clientDataHash := sha256.Sum256(clientDataJSON) + payload := append(authenticatorData, clientDataHash[:]...) + + h := crypto.SHA256.New() + h.Write(payload) + digest := h.Sum(nil) + + sigR, sigS, err := ecdsa.Sign(rand.Reader, privateKey, digest) + require.NoError(t, err) + sig := append(sigR.Bytes(), sigS.Bytes()...) + + cborSig := Signature{ + AuthenticatorData: hex.EncodeToString(authenticatorData), + ClientDataJSON: hex.EncodeToString(clientDataJSON), + Signature: base64.StdEncoding.EncodeToString(sig), + } + + sigBytes, err := json.Marshal(cborSig) + require.NoError(t, err) + require.False(t, pk.VerifySignature(msg, sigBytes)) +} + +func TestVerifySignature_ClientDataJSONEncodingInBase64(t *testing.T) { + privateKey, pk := GenerateAuthnKey(t) + authenticatorData := cometcrypto.CRandBytes(37) + msg := cometcrypto.CRandBytes(1000) + clientDataJSON := GenerateClientData(t, msg) + clientDataHash := sha256.Sum256(clientDataJSON) + payload := append(authenticatorData, clientDataHash[:]...) + + h := crypto.SHA256.New() + h.Write(payload) + digest := h.Sum(nil) + + sigR, sigS, err := ecdsa.Sign(rand.Reader, privateKey, digest) + require.NoError(t, err) + sig := append(sigR.Bytes(), sigS.Bytes()...) + + cborSig := Signature{ + AuthenticatorData: hex.EncodeToString(authenticatorData), + ClientDataJSON: base64.StdEncoding.EncodeToString(clientDataJSON), + Signature: hex.EncodeToString(sig), + } + + sigBytes, err := json.Marshal(cborSig) + require.NoError(t, err) + require.False(t, pk.VerifySignature(msg, sigBytes)) +} + +func TestVerifySignature_EmptySignature(t *testing.T) { + _, pk := GenerateAuthnKey(t) + msg := cometcrypto.CRandBytes(1000) + require.False(t, pk.VerifySignature(msg, []byte{})) +} + +func TestVerifySignature_AuthenticatorDataLength(t *testing.T) { + privateKey, pk := GenerateAuthnKey(t) + authenticatorData := cometcrypto.CRandBytes(10) + msg := cometcrypto.CRandBytes(1000) + clientDataJSON := GenerateClientData(t, msg) + clientDataHash := sha256.Sum256(clientDataJSON) + payload := append(authenticatorData, clientDataHash[:]...) + + h := crypto.SHA256.New() + h.Write(payload) + digest := h.Sum(nil) + + sig, err := ecdsa.SignASN1(rand.Reader, privateKey, digest) + require.NoError(t, err) + + cborSig := Signature{ + AuthenticatorData: hex.EncodeToString(authenticatorData), + ClientDataJSON: hex.EncodeToString(clientDataJSON), + Signature: hex.EncodeToString(sig), + } + + sigBytes, err := json.Marshal(cborSig) + require.NoError(t, err) + require.False(t, pk.VerifySignature(msg, sigBytes)) +} diff --git a/go.mod b/go.mod index 5d61e799..142e5d5a 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( github.com/cosmos/cosmos-sdk v0.50.7 github.com/cosmos/gogoproto v1.4.12 github.com/cosmos/iavl v1.1.2 // indirect + github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.2.1-0.20240523101951-4b45d1822fb6 github.com/cosmos/ibc-go/v8 v8.3.2 github.com/golang/protobuf v1.5.4 github.com/google/gofuzz v1.2.0 @@ -27,7 +28,6 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de google.golang.org/grpc v1.63.2 gopkg.in/yaml.v2 v2.4.0 - ) require ( @@ -41,9 +41,9 @@ require ( cosmossdk.io/x/upgrade v0.1.1 github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/ibc-go/modules/capability v1.0.0 - github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.2.1-0.20240523101951-4b45d1822fb6 github.com/cosmos/rosetta v0.50.4 github.com/hashicorp/go-metrics v0.5.3 + google.golang.org/protobuf v1.33.0 ) require ( @@ -203,7 +203,6 @@ require ( google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect - google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect @@ -216,7 +215,7 @@ replace ( // Use the cosmos-flavored keyring library github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 - // github.com/cosmos/ibc-go/v8 => github.com/Team-Kujira/ibc-go/v7 v7.3.0-factory + github.com/cosmos/ibc-go/v8 => github.com/Team-Kujira/ibc-go/v8 v8.3.2-factory2 // dgrijalva/jwt-go is deprecated and doesn't receive security updates. // See: https://github.com/cosmos/cosmos-sdk/issues/13134 diff --git a/go.sum b/go.sum index 77fe0ef7..be5a40dd 100644 --- a/go.sum +++ b/go.sum @@ -242,6 +242,8 @@ github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/Team-Kujira/ibc-go/v8 v8.3.2-factory2 h1:ryXabic11aQN86ya29KLB+qvXNFXAwtEsJElfRL92+U= +github.com/Team-Kujira/ibc-go/v8 v8.3.2-factory2/go.mod h1:WVVIsG39jGrF9Cjggjci6LzySyWGloz194sjTxiGNIE= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= @@ -380,8 +382,6 @@ github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco= github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.2.1-0.20240523101951-4b45d1822fb6 h1:cq9xPsRYXr1DJG0h1rrxlE+JKZh7s5z/jSgnG2YmR18= github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.2.1-0.20240523101951-4b45d1822fb6/go.mod h1:ab73pB/hwAFSa98oUwtMiNF6T1NyRwo6sjLjaYrkHHI= -github.com/cosmos/ibc-go/v8 v8.3.2 h1:8X1oHHKt2Bh9hcExWS89rntLaCKZp2EjFTUSxKlPhGI= -github.com/cosmos/ibc-go/v8 v8.3.2/go.mod h1:WVVIsG39jGrF9Cjggjci6LzySyWGloz194sjTxiGNIE= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= diff --git a/legacygov/alliance/alliance.pb.go b/legacygov/alliance/alliance.pb.go new file mode 100644 index 00000000..a19aff45 --- /dev/null +++ b/legacygov/alliance/alliance.pb.go @@ -0,0 +1,1013 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: alliance/alliance/alliance.proto + +package alliance + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/durationpb" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 RewardWeightRange struct { + Min cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=min,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min"` + Max cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=max,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"max"` +} + +func (m *RewardWeightRange) Reset() { *m = RewardWeightRange{} } +func (m *RewardWeightRange) String() string { return proto.CompactTextString(m) } +func (*RewardWeightRange) ProtoMessage() {} +func (*RewardWeightRange) Descriptor() ([]byte, []int) { + return fileDescriptor_ae357bc0eb0c4178, []int{0} +} +func (m *RewardWeightRange) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RewardWeightRange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RewardWeightRange.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 *RewardWeightRange) XXX_Merge(src proto.Message) { + xxx_messageInfo_RewardWeightRange.Merge(m, src) +} +func (m *RewardWeightRange) XXX_Size() int { + return m.Size() +} +func (m *RewardWeightRange) XXX_DiscardUnknown() { + xxx_messageInfo_RewardWeightRange.DiscardUnknown(m) +} + +var xxx_messageInfo_RewardWeightRange proto.InternalMessageInfo + +// key: denom value: AllianceAsset +type AllianceAsset struct { + // Denom of the asset. It could either be a native token or an IBC token + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` + // The reward weight specifies the ratio of rewards that will be given to each alliance asset + // It does not need to sum to 1. rate = weight / total_weight + // Native asset is always assumed to have a weight of 1.s + RewardWeight cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=reward_weight,json=rewardWeight,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"reward_weight"` + // A positive take rate is used for liquid staking derivatives. It defines an rate that is applied per take_rate_interval + // that will be redirected to the distribution rewards pool + TakeRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=take_rate,json=takeRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"take_rate"` + TotalTokens cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=total_tokens,json=totalTokens,proto3,customtype=cosmossdk.io/math.Int" json:"total_tokens"` + TotalValidatorShares cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=total_validator_shares,json=totalValidatorShares,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"total_validator_shares"` + RewardStartTime time.Time `protobuf:"bytes,6,opt,name=reward_start_time,json=rewardStartTime,proto3,stdtime" json:"reward_start_time"` + RewardChangeRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=reward_change_rate,json=rewardChangeRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"reward_change_rate"` + RewardChangeInterval time.Duration `protobuf:"bytes,8,opt,name=reward_change_interval,json=rewardChangeInterval,proto3,stdduration" json:"reward_change_interval"` + LastRewardChangeTime time.Time `protobuf:"bytes,9,opt,name=last_reward_change_time,json=lastRewardChangeTime,proto3,stdtime" json:"last_reward_change_time"` + // set a bound of weight range to limit how much reward weights can scale. + RewardWeightRange RewardWeightRange `protobuf:"bytes,10,opt,name=reward_weight_range,json=rewardWeightRange,proto3" json:"reward_weight_range"` + // flag to check if an asset has completed the initialization process after the reward delay + IsInitialized bool `protobuf:"varint,11,opt,name=is_initialized,json=isInitialized,proto3" json:"is_initialized,omitempty"` +} + +func (m *AllianceAsset) Reset() { *m = AllianceAsset{} } +func (m *AllianceAsset) String() string { return proto.CompactTextString(m) } +func (*AllianceAsset) ProtoMessage() {} +func (*AllianceAsset) Descriptor() ([]byte, []int) { + return fileDescriptor_ae357bc0eb0c4178, []int{1} +} +func (m *AllianceAsset) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AllianceAsset) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AllianceAsset.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 *AllianceAsset) XXX_Merge(src proto.Message) { + xxx_messageInfo_AllianceAsset.Merge(m, src) +} +func (m *AllianceAsset) XXX_Size() int { + return m.Size() +} +func (m *AllianceAsset) XXX_DiscardUnknown() { + xxx_messageInfo_AllianceAsset.DiscardUnknown(m) +} + +var xxx_messageInfo_AllianceAsset proto.InternalMessageInfo + +func init() { + proto.RegisterType((*RewardWeightRange)(nil), "alliance.alliance.RewardWeightRange") + proto.RegisterType((*AllianceAsset)(nil), "alliance.alliance.AllianceAsset") +} + +func init() { proto.RegisterFile("alliance/alliance/alliance.proto", fileDescriptor_ae357bc0eb0c4178) } + +var fileDescriptor_ae357bc0eb0c4178 = []byte{ + // 615 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x4f, 0x4f, 0xd4, 0x4e, + 0x18, 0xc7, 0xdb, 0x1f, 0x7f, 0x7e, 0xcb, 0x00, 0xca, 0xd6, 0x15, 0x0b, 0x26, 0xed, 0x66, 0xfd, + 0x13, 0x12, 0x43, 0x9b, 0x68, 0xbc, 0x70, 0x92, 0x95, 0x03, 0x1b, 0x8d, 0xd1, 0x42, 0x34, 0xe0, + 0xa1, 0x79, 0x68, 0xc7, 0xee, 0x48, 0xdb, 0x21, 0x33, 0xb3, 0xfc, 0xf1, 0x15, 0x98, 0x78, 0xe1, + 0xe8, 0x91, 0x17, 0xe1, 0x8b, 0xe0, 0x48, 0x3c, 0x11, 0x0f, 0x68, 0xd8, 0x8b, 0x67, 0x5f, 0x81, + 0x99, 0x99, 0x2e, 0xec, 0xda, 0xcb, 0xee, 0x6d, 0xa6, 0xcf, 0x7c, 0x3f, 0xf3, 0xed, 0xb7, 0xcf, + 0x53, 0x54, 0x87, 0x34, 0x25, 0x90, 0x47, 0xd8, 0x2f, 0x2d, 0xbc, 0x3d, 0x46, 0x05, 0xb5, 0xaa, + 0x57, 0xfb, 0xde, 0x62, 0xb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 0x85, 0x9a, 0x84, 0x04, 0x7d, 0x17, 0xa8, 0x28, 0xb6, 0xd1, 0xad, 0x81, 0x9e, 0x0c, 0x99, + 0x2c, 0xd9, 0x48, 0x81, 0xef, 0x7b, 0xa5, 0xf1, 0xf7, 0x4a, 0x83, 0xd8, 0x1c, 0x97, 0x57, 0x04, + 0x55, 0x56, 0x9a, 0xd0, 0x07, 0xe8, 0x06, 0xe1, 0x21, 0xc9, 0x89, 0x20, 0x90, 0x92, 0x4f, 0x38, + 0xb6, 0xa7, 0xeb, 0xe6, 0x52, 0x25, 0x98, 0x25, 0xbc, 0x75, 0xfd, 0xf0, 0x7a, 0xb4, 0x9a, 0xeb, + 0xa7, 0x97, 0x8e, 0x79, 0x76, 0xe9, 0x98, 0xbf, 0x2e, 0x1d, 0xf3, 0xb8, 0xeb, 0x18, 0x67, 0x5d, + 0xc7, 0x38, 0xef, 0x3a, 0xc6, 0xb6, 0x97, 0x10, 0xd1, 0xee, 0xec, 0x78, 0x11, 0xcd, 0xfc, 0x4d, + 0x0c, 0xd9, 0xf2, 0x8b, 0xce, 0x47, 0xc2, 0xc0, 0x8f, 0x28, 0xc3, 0x7e, 0xaa, 0xbe, 0x4b, 0x42, + 0xf7, 0xaf, 0xfe, 0x5e, 0x3b, 0x93, 0x2a, 0x8a, 0x27, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x6b, + 0xe1, 0xd4, 0x21, 0xe2, 0x04, 0x00, 0x00, +} + +func (m *RewardWeightRange) 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 *RewardWeightRange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RewardWeightRange) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Max.Size() + i -= size + if _, err := m.Max.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAlliance(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.Min.Size() + i -= size + if _, err := m.Min.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAlliance(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *AllianceAsset) 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 *AllianceAsset) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AllianceAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsInitialized { + i-- + if m.IsInitialized { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x58 + } + { + size, err := m.RewardWeightRange.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAlliance(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + n2, err2 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.LastRewardChangeTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastRewardChangeTime):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintAlliance(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x4a + n3, err3 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.RewardChangeInterval, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.RewardChangeInterval):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintAlliance(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x42 + { + size := m.RewardChangeRate.Size() + i -= size + if _, err := m.RewardChangeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAlliance(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + n4, err4 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.RewardStartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.RewardStartTime):]) + if err4 != nil { + return 0, err4 + } + i -= n4 + i = encodeVarintAlliance(dAtA, i, uint64(n4)) + i-- + dAtA[i] = 0x32 + { + size := m.TotalValidatorShares.Size() + i -= size + if _, err := m.TotalValidatorShares.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAlliance(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.TotalTokens.Size() + i -= size + if _, err := m.TotalTokens.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAlliance(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.TakeRate.Size() + i -= size + if _, err := m.TakeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAlliance(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.RewardWeight.Size() + i -= size + if _, err := m.RewardWeight.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAlliance(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintAlliance(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintAlliance(dAtA []byte, offset int, v uint64) int { + offset -= sovAlliance(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *RewardWeightRange) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Min.Size() + n += 1 + l + sovAlliance(uint64(l)) + l = m.Max.Size() + n += 1 + l + sovAlliance(uint64(l)) + return n +} + +func (m *AllianceAsset) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovAlliance(uint64(l)) + } + l = m.RewardWeight.Size() + n += 1 + l + sovAlliance(uint64(l)) + l = m.TakeRate.Size() + n += 1 + l + sovAlliance(uint64(l)) + l = m.TotalTokens.Size() + n += 1 + l + sovAlliance(uint64(l)) + l = m.TotalValidatorShares.Size() + n += 1 + l + sovAlliance(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.RewardStartTime) + n += 1 + l + sovAlliance(uint64(l)) + l = m.RewardChangeRate.Size() + n += 1 + l + sovAlliance(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.RewardChangeInterval) + n += 1 + l + sovAlliance(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastRewardChangeTime) + n += 1 + l + sovAlliance(uint64(l)) + l = m.RewardWeightRange.Size() + n += 1 + l + sovAlliance(uint64(l)) + if m.IsInitialized { + n += 2 + } + return n +} + +func sovAlliance(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAlliance(x uint64) (n int) { + return sovAlliance(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *RewardWeightRange) 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 ErrIntOverflowAlliance + } + 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: RewardWeightRange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RewardWeightRange: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Min", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlliance + } + 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 ErrInvalidLengthAlliance + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlliance + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Min.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Max", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlliance + } + 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 ErrInvalidLengthAlliance + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlliance + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Max.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAlliance(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAlliance + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AllianceAsset) 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 ErrIntOverflowAlliance + } + 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: AllianceAsset: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AllianceAsset: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlliance + } + 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 ErrInvalidLengthAlliance + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlliance + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardWeight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlliance + } + 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 ErrInvalidLengthAlliance + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlliance + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardWeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakeRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlliance + } + 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 ErrInvalidLengthAlliance + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlliance + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TakeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalTokens", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlliance + } + 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 ErrInvalidLengthAlliance + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlliance + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalTokens.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalValidatorShares", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlliance + } + 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 ErrInvalidLengthAlliance + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlliance + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalValidatorShares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardStartTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlliance + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAlliance + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAlliance + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.RewardStartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardChangeRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlliance + } + 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 ErrInvalidLengthAlliance + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlliance + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardChangeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardChangeInterval", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlliance + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAlliance + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAlliance + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.RewardChangeInterval, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastRewardChangeTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlliance + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAlliance + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAlliance + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.LastRewardChangeTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardWeightRange", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlliance + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAlliance + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAlliance + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardWeightRange.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsInitialized", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlliance + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsInitialized = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipAlliance(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAlliance + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAlliance(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, ErrIntOverflowAlliance + } + 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, ErrIntOverflowAlliance + } + 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, ErrIntOverflowAlliance + } + 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, ErrInvalidLengthAlliance + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAlliance + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAlliance + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAlliance = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAlliance = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAlliance = fmt.Errorf("proto: unexpected end of group") +) diff --git a/legacygov/alliance/codec.go b/legacygov/alliance/codec.go new file mode 100644 index 00000000..4490d740 --- /dev/null +++ b/legacygov/alliance/codec.go @@ -0,0 +1,14 @@ +package alliance + +import ( + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" +) + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*govtypes.Content)(nil), + &MsgCreateAllianceProposal{}, + &MsgUpdateAllianceProposal{}, + &MsgDeleteAllianceProposal{}, + ) +} diff --git a/legacygov/alliance/gov.go b/legacygov/alliance/gov.go new file mode 100644 index 00000000..fe2ba9a0 --- /dev/null +++ b/legacygov/alliance/gov.go @@ -0,0 +1,163 @@ +package alliance + +import ( + "time" + + "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +const RouterKey = "alliance" + +const ( + ProposalTypeCreateAlliance = "msg_create_alliance_proposal" + ProposalTypeUpdateAlliance = "msg_update_alliance_proposal" + ProposalTypeDeleteAlliance = "msg_delete_alliance_proposal" +) + +var ( + _ govtypes.Content = &MsgCreateAllianceProposal{} + _ govtypes.Content = &MsgUpdateAllianceProposal{} + _ govtypes.Content = &MsgDeleteAllianceProposal{} +) + +func init() { + govtypes.RegisterProposalType(ProposalTypeCreateAlliance) + govtypes.RegisterProposalType(ProposalTypeUpdateAlliance) + govtypes.RegisterProposalType(ProposalTypeDeleteAlliance) +} + +func NewMsgCreateAllianceProposal(title, description, denom string, rewardWeight math.LegacyDec, rewardWeightRange RewardWeightRange, takeRate math.LegacyDec, rewardChangeRate math.LegacyDec, rewardChangeInterval time.Duration) govtypes.Content { + return &MsgCreateAllianceProposal{ + Title: title, + Description: description, + Denom: denom, + RewardWeight: rewardWeight, + RewardWeightRange: rewardWeightRange, + TakeRate: takeRate, + RewardChangeRate: rewardChangeRate, + RewardChangeInterval: rewardChangeInterval, + } +} +func (m *MsgCreateAllianceProposal) GetTitle() string { return m.Title } +func (m *MsgCreateAllianceProposal) GetDescription() string { return m.Description } +func (m *MsgCreateAllianceProposal) ProposalRoute() string { return RouterKey } +func (m *MsgCreateAllianceProposal) ProposalType() string { return ProposalTypeCreateAlliance } + +func (m *MsgCreateAllianceProposal) ValidateBasic() error { + if m.Denom == "" { + return status.Errorf(codes.InvalidArgument, "Alliance denom must have a value") + } + + if err := sdk.ValidateDenom(m.Denom); err != nil { + return err + } + + if m.RewardWeight.IsNil() || m.RewardWeight.LT(math.LegacyZeroDec()) { + return status.Errorf(codes.InvalidArgument, "Alliance rewardWeight must be zero or a positive number") + } + + if m.RewardWeightRange.Min.IsNil() || m.RewardWeightRange.Min.LT(math.LegacyZeroDec()) || + m.RewardWeightRange.Max.IsNil() || m.RewardWeightRange.Max.LT(math.LegacyZeroDec()) { + return status.Errorf(codes.InvalidArgument, "Alliance rewardWeight min and max must be zero or a positive number") + } + + if m.RewardWeightRange.Min.GT(m.RewardWeightRange.Max) { + return status.Errorf(codes.InvalidArgument, "Alliance rewardWeight min must be less or equal to rewardWeight max") + } + + if m.RewardWeight.LT(m.RewardWeightRange.Min) || m.RewardWeight.GT(m.RewardWeightRange.Max) { + return status.Errorf(codes.InvalidArgument, "Alliance rewardWeight must be bounded in RewardWeightRange") + } + + if m.TakeRate.IsNil() || m.TakeRate.IsNegative() || m.TakeRate.GTE(math.LegacyOneDec()) { + return status.Errorf(codes.InvalidArgument, "Alliance takeRate must be more or equals to 0 but strictly less than 1") + } + + if m.RewardChangeRate.IsZero() || m.RewardChangeRate.IsNegative() { + return status.Errorf(codes.InvalidArgument, "Alliance rewardChangeRate must be strictly a positive number") + } + + if m.RewardChangeInterval < 0 { + return status.Errorf(codes.InvalidArgument, "Alliance rewardChangeInterval must be strictly a positive number") + } + + return nil +} + +func NewMsgUpdateAllianceProposal(title, description, denom string, rewardWeight math.LegacyDec, rewardWeightRange RewardWeightRange, takeRate math.LegacyDec, rewardChangeRate math.LegacyDec, rewardChangeInterval time.Duration) govtypes.Content { + return &MsgUpdateAllianceProposal{ + Title: title, + Description: description, + Denom: denom, + RewardWeight: rewardWeight, + TakeRate: takeRate, + RewardChangeRate: rewardChangeRate, + RewardChangeInterval: rewardChangeInterval, + RewardWeightRange: rewardWeightRange, + } +} +func (m *MsgUpdateAllianceProposal) GetTitle() string { return m.Title } +func (m *MsgUpdateAllianceProposal) GetDescription() string { return m.Description } +func (m *MsgUpdateAllianceProposal) ProposalRoute() string { return RouterKey } +func (m *MsgUpdateAllianceProposal) ProposalType() string { return ProposalTypeUpdateAlliance } + +func (m *MsgUpdateAllianceProposal) ValidateBasic() error { + if m.Denom == "" { + return status.Errorf(codes.InvalidArgument, "Alliance denom must have a value") + } + + if m.RewardWeight.IsNil() || m.RewardWeight.LT(math.LegacyZeroDec()) { + return status.Errorf(codes.InvalidArgument, "Alliance rewardWeight must be zero or a positive number") + } + + if m.TakeRate.IsNil() || m.TakeRate.IsNegative() || m.TakeRate.GTE(math.LegacyOneDec()) { + return status.Errorf(codes.InvalidArgument, "Alliance takeRate must be more or equals to 0 but strictly less than 1") + } + + if m.RewardChangeRate.IsZero() || m.RewardChangeRate.IsNegative() { + return status.Errorf(codes.InvalidArgument, "Alliance rewardChangeRate must be strictly a positive number") + } + + if m.RewardChangeInterval < 0 { + return status.Errorf(codes.InvalidArgument, "Alliance rewardChangeInterval must be strictly a positive number") + } + + if m.RewardWeightRange.Min.IsNil() || m.RewardWeightRange.Min.LT(math.LegacyZeroDec()) || + m.RewardWeightRange.Max.IsNil() || m.RewardWeightRange.Max.LT(math.LegacyZeroDec()) { + return status.Errorf(codes.InvalidArgument, "Alliance rewardWeight min and max must be zero or a positive number") + } + + if m.RewardWeightRange.Min.GT(m.RewardWeightRange.Max) { + return status.Errorf(codes.InvalidArgument, "Alliance rewardWeight min must be less or equal to rewardWeight max") + } + + if m.RewardWeight.LT(m.RewardWeightRange.Min) || m.RewardWeight.GT(m.RewardWeightRange.Max) { + return status.Errorf(codes.InvalidArgument, "Alliance rewardWeight must be bounded in RewardWeightRange") + } + + return nil +} + +func NewMsgDeleteAllianceProposal(title, description, denom string) govtypes.Content { + return &MsgDeleteAllianceProposal{ + Title: title, + Description: description, + Denom: denom, + } +} +func (m *MsgDeleteAllianceProposal) GetTitle() string { return m.Title } +func (m *MsgDeleteAllianceProposal) GetDescription() string { return m.Description } +func (m *MsgDeleteAllianceProposal) ProposalRoute() string { return RouterKey } +func (m *MsgDeleteAllianceProposal) ProposalType() string { return ProposalTypeDeleteAlliance } + +func (m *MsgDeleteAllianceProposal) ValidateBasic() error { + if m.Denom == "" { + return status.Errorf(codes.InvalidArgument, "Alliance denom must have a value") + } + return nil +} diff --git a/legacygov/alliance/gov.pb.go b/legacygov/alliance/gov.pb.go new file mode 100644 index 00000000..4d656bdb --- /dev/null +++ b/legacygov/alliance/gov.pb.go @@ -0,0 +1,1404 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: alliance/alliance/gov.proto + +package alliance + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/durationpb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 MsgCreateAllianceProposal struct { + // the title of the update proposal + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + // the description of the proposal + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + // Denom of the asset. It could either be a native token or an IBC token + Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` + // The reward weight specifies the ratio of rewards that will be given to each alliance asset + // It does not need to sum to 1. rate = weight / total_weight + // Native asset is always assumed to have a weight of 1. + RewardWeight cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=reward_weight,json=rewardWeight,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"reward_weight"` + // A positive take rate is used for liquid staking derivatives. It defines an annualized reward rate that + // will be redirected to the distribution rewards pool + TakeRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=take_rate,json=takeRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"take_rate"` + RewardChangeRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=reward_change_rate,json=rewardChangeRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"reward_change_rate"` + RewardChangeInterval time.Duration `protobuf:"bytes,7,opt,name=reward_change_interval,json=rewardChangeInterval,proto3,stdduration" json:"reward_change_interval"` + // set a bound of weight range to limit how much reward weights can scale. + RewardWeightRange RewardWeightRange `protobuf:"bytes,8,opt,name=reward_weight_range,json=rewardWeightRange,proto3" json:"reward_weight_range"` +} + +func (m *MsgCreateAllianceProposal) Reset() { *m = MsgCreateAllianceProposal{} } +func (m *MsgCreateAllianceProposal) String() string { return proto.CompactTextString(m) } +func (*MsgCreateAllianceProposal) ProtoMessage() {} +func (*MsgCreateAllianceProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_c66988d3be8665d9, []int{0} +} +func (m *MsgCreateAllianceProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateAllianceProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateAllianceProposal.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 *MsgCreateAllianceProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateAllianceProposal.Merge(m, src) +} +func (m *MsgCreateAllianceProposal) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateAllianceProposal) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateAllianceProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateAllianceProposal proto.InternalMessageInfo + +type MsgUpdateAllianceProposal struct { + // the title of the update proposal + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + // the description of the proposal + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + // Denom of the asset. It could either be a native token or an IBC token + Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` + // The reward weight specifies the ratio of rewards that will be given to each alliance asset + // It does not need to sum to 1. rate = weight / total_weight + // Native asset is always assumed to have a weight of 1. + RewardWeight cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=reward_weight,json=rewardWeight,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"reward_weight"` + TakeRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=take_rate,json=takeRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"take_rate"` + RewardChangeRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=reward_change_rate,json=rewardChangeRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"reward_change_rate"` + RewardChangeInterval time.Duration `protobuf:"bytes,7,opt,name=reward_change_interval,json=rewardChangeInterval,proto3,stdduration" json:"reward_change_interval"` + // set a bound of weight range to limit how much reward weights can scale. + RewardWeightRange RewardWeightRange `protobuf:"bytes,8,opt,name=reward_weight_range,json=rewardWeightRange,proto3" json:"reward_weight_range"` +} + +func (m *MsgUpdateAllianceProposal) Reset() { *m = MsgUpdateAllianceProposal{} } +func (m *MsgUpdateAllianceProposal) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateAllianceProposal) ProtoMessage() {} +func (*MsgUpdateAllianceProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_c66988d3be8665d9, []int{1} +} +func (m *MsgUpdateAllianceProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateAllianceProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateAllianceProposal.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 *MsgUpdateAllianceProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateAllianceProposal.Merge(m, src) +} +func (m *MsgUpdateAllianceProposal) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateAllianceProposal) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateAllianceProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateAllianceProposal proto.InternalMessageInfo + +type MsgDeleteAllianceProposal struct { + // the title of the update proposal + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + // the description of the proposal + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` +} + +func (m *MsgDeleteAllianceProposal) Reset() { *m = MsgDeleteAllianceProposal{} } +func (m *MsgDeleteAllianceProposal) String() string { return proto.CompactTextString(m) } +func (*MsgDeleteAllianceProposal) ProtoMessage() {} +func (*MsgDeleteAllianceProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_c66988d3be8665d9, []int{2} +} +func (m *MsgDeleteAllianceProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeleteAllianceProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeleteAllianceProposal.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 *MsgDeleteAllianceProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteAllianceProposal.Merge(m, src) +} +func (m *MsgDeleteAllianceProposal) XXX_Size() int { + return m.Size() +} +func (m *MsgDeleteAllianceProposal) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteAllianceProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeleteAllianceProposal proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgCreateAllianceProposal)(nil), "alliance.alliance.MsgCreateAllianceProposal") + proto.RegisterType((*MsgUpdateAllianceProposal)(nil), "alliance.alliance.MsgUpdateAllianceProposal") + proto.RegisterType((*MsgDeleteAllianceProposal)(nil), "alliance.alliance.MsgDeleteAllianceProposal") +} + +func init() { proto.RegisterFile("alliance/alliance/gov.proto", fileDescriptor_c66988d3be8665d9) } + +var fileDescriptor_c66988d3be8665d9 = []byte{ + // 485 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x94, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xc7, 0x6d, 0x68, 0x4a, 0x7a, 0x2d, 0x52, 0x7b, 0x44, 0xc8, 0x6d, 0x25, 0x3b, 0x0a, 0x08, + 0x75, 0xe1, 0x2c, 0xc1, 0xd6, 0x09, 0xd2, 0x0c, 0x45, 0x80, 0x04, 0x16, 0x08, 0xd1, 0x25, 0xba, + 0xd8, 0x8f, 0xcb, 0xd1, 0xb3, 0x5f, 0x74, 0xbe, 0xa4, 0xea, 0x07, 0x40, 0x62, 0x64, 0x44, 0x62, + 0xe9, 0xc7, 0xe9, 0xd8, 0x11, 0x31, 0x04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x3b, 0x07, 0x4c, 0x48, 0xd3, 0x1f, 0xf6, 0x58, 0x8c, 0x69, 0xf8, 0x06, 0x78, + 0xfa, 0xf0, 0xf9, 0xf0, 0xa3, 0xd4, 0x3c, 0x8c, 0x51, 0x43, 0xa8, 0xec, 0x6e, 0x04, 0x8e, 0xe6, + 0x7f, 0xd2, 0xde, 0xb2, 0x7d, 0xea, 0xc7, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x5c, 0x3d, 0x68, + 0xc4, 0x9e, 0x05, 0x00, 0x00, +} + +func (m *MsgCreateAllianceProposal) 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 *MsgCreateAllianceProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateAllianceProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.RewardWeightRange.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.RewardChangeInterval, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.RewardChangeInterval):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintGov(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x3a + { + size := m.RewardChangeRate.Size() + i -= size + if _, err := m.RewardChangeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size := m.TakeRate.Size() + i -= size + if _, err := m.TakeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.RewardWeight.Size() + i -= size + if _, err := m.RewardWeight.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintGov(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateAllianceProposal) 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 *MsgUpdateAllianceProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateAllianceProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.RewardWeightRange.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + n4, err4 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.RewardChangeInterval, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.RewardChangeInterval):]) + if err4 != nil { + return 0, err4 + } + i -= n4 + i = encodeVarintGov(dAtA, i, uint64(n4)) + i-- + dAtA[i] = 0x3a + { + size := m.RewardChangeRate.Size() + i -= size + if _, err := m.RewardChangeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size := m.TakeRate.Size() + i -= size + if _, err := m.TakeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.RewardWeight.Size() + i -= size + if _, err := m.RewardWeight.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintGov(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDeleteAllianceProposal) 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 *MsgDeleteAllianceProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteAllianceProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintGov(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGov(dAtA []byte, offset int, v uint64) int { + offset -= sovGov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCreateAllianceProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = m.RewardWeight.Size() + n += 1 + l + sovGov(uint64(l)) + l = m.TakeRate.Size() + n += 1 + l + sovGov(uint64(l)) + l = m.RewardChangeRate.Size() + n += 1 + l + sovGov(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.RewardChangeInterval) + n += 1 + l + sovGov(uint64(l)) + l = m.RewardWeightRange.Size() + n += 1 + l + sovGov(uint64(l)) + return n +} + +func (m *MsgUpdateAllianceProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = m.RewardWeight.Size() + n += 1 + l + sovGov(uint64(l)) + l = m.TakeRate.Size() + n += 1 + l + sovGov(uint64(l)) + l = m.RewardChangeRate.Size() + n += 1 + l + sovGov(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.RewardChangeInterval) + n += 1 + l + sovGov(uint64(l)) + l = m.RewardWeightRange.Size() + n += 1 + l + sovGov(uint64(l)) + return n +} + +func (m *MsgDeleteAllianceProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + return n +} + +func sovGov(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGov(x uint64) (n int) { + return sovGov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreateAllianceProposal) 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 ErrIntOverflowGov + } + 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: MsgCreateAllianceProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateAllianceProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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 ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + 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 Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardWeight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardWeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakeRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TakeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardChangeRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardChangeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardChangeInterval", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.RewardChangeInterval, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardWeightRange", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardWeightRange.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateAllianceProposal) 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 ErrIntOverflowGov + } + 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: MsgUpdateAllianceProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateAllianceProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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 ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + 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 Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardWeight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardWeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakeRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TakeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardChangeRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardChangeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardChangeInterval", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.RewardChangeInterval, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardWeightRange", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardWeightRange.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeleteAllianceProposal) 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 ErrIntOverflowGov + } + 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: MsgDeleteAllianceProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeleteAllianceProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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 ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + 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 Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGov(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, ErrIntOverflowGov + } + 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, ErrIntOverflowGov + } + 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, ErrIntOverflowGov + } + 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, ErrInvalidLengthGov + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGov + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGov + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGov = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGov = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGov = fmt.Errorf("proto: unexpected end of group") +) diff --git a/legacygov/scheduler/codec.go b/legacygov/scheduler/codec.go new file mode 100644 index 00000000..b6523c3c --- /dev/null +++ b/legacygov/scheduler/codec.go @@ -0,0 +1,15 @@ +package scheduler + +import ( + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" +) + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + // legacy proposals + registry.RegisterImplementations((*govtypes.Content)(nil), + &CreateHookProposal{}, + &UpdateHookProposal{}, + &DeleteHookProposal{}, + ) +} diff --git a/legacygov/scheduler/legacy_proposal.go b/legacygov/scheduler/legacy_proposal.go new file mode 100644 index 00000000..02d77125 --- /dev/null +++ b/legacygov/scheduler/legacy_proposal.go @@ -0,0 +1,213 @@ +package scheduler + +import ( + "fmt" + "strings" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govtypesv1beta "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" +) + +const RouterKey = "scheduler" + +const ( + ProposalTypeCreateHook string = "CreateHook" + ProposalTypeUpdateHook string = "UpdateHook" + ProposalTypeDeleteHook string = "DeleteHook" +) + +func init() { // register new content types with the sdk + govtypesv1beta.RegisterProposalType(ProposalTypeCreateHook) + govtypesv1beta.RegisterProposalType(ProposalTypeUpdateHook) + govtypesv1beta.RegisterProposalType(ProposalTypeDeleteHook) +} + +var ( + _ govtypesv1beta.Content = &CreateHookProposal{} + _ govtypesv1beta.Content = &UpdateHookProposal{} + _ govtypesv1beta.Content = &DeleteHookProposal{} +) + +// ProposalRoute returns the routing key of a parameter change proposal. +func (p CreateHookProposal) ProposalRoute() string { return RouterKey } + +// ProposalType returns the type +func (p CreateHookProposal) ProposalType() string { return ProposalTypeCreateHook } + +// ValidateBasic validates the proposal +func (p CreateHookProposal) ValidateBasic() error { + if err := validateProposalCommons(p.Title, p.Description); err != nil { + return err + } + if _, err := sdk.AccAddressFromBech32(p.Contract); err != nil { + return errorsmod.Wrap(err, "contract") + } + if _, err := sdk.AccAddressFromBech32(p.Executor); err != nil { + return errorsmod.Wrap(err, "executor") + } + if !p.Funds.IsValid() { + return sdkerrors.ErrInvalidCoins + } + if err := p.Msg.ValidateBasic(); err != nil { + return errorsmod.Wrap(err, "payload msg") + } + return nil +} + +// String implements the Stringer interface. +func (p CreateHookProposal) String() string { + return fmt.Sprintf(`Create Hook Proposal: + Title: %s + Description: %s + Contract: %s + Executor: %s + Msg: %q + Funds: %s +`, p.Title, p.Description, p.Contract, p.Executor, p.Msg, p.Funds) +} + +// MarshalYAML pretty prints the wasm byte code +func (p CreateHookProposal) MarshalYAML() (interface{}, error) { + return struct { + Title string `yaml:"title"` + Description string `yaml:"description"` + Contract string `yaml:"contract"` + Executor string `yaml:"executor"` + Msg string `yaml:"msg"` + Funds sdk.Coins `yaml:"funds"` + }{ + Title: p.Title, + Description: p.Description, + Contract: p.Contract, + Executor: p.Executor, + Msg: string(p.Msg), + Funds: p.Funds, + }, nil +} + +// ProposalRoute returns the routing key of a parameter change proposal. +func (p UpdateHookProposal) ProposalRoute() string { return RouterKey } + +// ProposalType returns the type +func (p UpdateHookProposal) ProposalType() string { + return ProposalTypeUpdateHook +} + +// ValidateBasic validates the proposal +func (p UpdateHookProposal) ValidateBasic() error { + if err := validateProposalCommons(p.Title, p.Description); err != nil { + return err + } + + if p.Id == 0 { + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "ID is required") + } + + if _, err := sdk.AccAddressFromBech32(p.Contract); err != nil { + return errorsmod.Wrap(err, "contract") + } + if _, err := sdk.AccAddressFromBech32(p.Executor); err != nil { + return errorsmod.Wrap(err, "executor") + } + if !p.Funds.IsValid() { + return sdkerrors.ErrInvalidCoins + } + if err := p.Msg.ValidateBasic(); err != nil { + return errorsmod.Wrap(err, "payload msg") + } + return nil +} + +// String implements the Stringer interface. +func (p UpdateHookProposal) String() string { + return fmt.Sprintf(`Update Hook Proposal: + Title: %s + Description: %s + ID: %d + Contract: %s + Executor: %s + Msg: %q + Funds: %s + `, p.Title, p.Description, p.Id, p.Contract, p.Executor, p.Msg, p.Funds) +} + +// MarshalYAML pretty prints the init message +// +//nolint:revive +func (p UpdateHookProposal) MarshalYAML() (interface{}, error) { + return struct { + Id uint64 `yaml:"id"` //nolint:stylecheck + Title string `yaml:"title"` + Description string `yaml:"description"` + Contract string `yaml:"contract"` + Executor string `yaml:"executor"` + Msg string `yaml:"msg"` + Funds sdk.Coins `yaml:"funds"` + }{ + Id: p.Id, + Title: p.Title, + Description: p.Description, + Contract: p.Contract, + Executor: p.Executor, + Msg: string(p.Msg), + Funds: p.Funds, + }, nil +} + +// ProposalRoute returns the routing key of a parameter change proposal. +func (p DeleteHookProposal) ProposalRoute() string { return RouterKey } + +// ProposalType returns the type +func (p DeleteHookProposal) ProposalType() string { return ProposalTypeDeleteHook } + +// ValidateBasic validates the proposal +func (p DeleteHookProposal) ValidateBasic() error { + return validateProposalCommons(p.Title, p.Description) +} + +// String implements the Stringer interface. +func (p DeleteHookProposal) String() string { + return fmt.Sprintf(`Migrate Contract Proposal: + Title: %s + Description: %s + ID: %d +`, p.Title, p.Description, p.Id) +} + +// MarshalYAML pretty prints the migrate message +func (p DeleteHookProposal) MarshalYAML() (interface{}, error) { + return struct { + Title string `yaml:"title"` + Description string `yaml:"description"` + Id uint64 `yaml:"id"` //nolint:revive,stylecheck + }{ + Title: p.Title, + Description: p.Description, + Id: p.Id, + }, nil +} + +func validateProposalCommons(title, description string) error { + if strings.TrimSpace(title) != title { + return errorsmod.Wrap(govtypes.ErrInvalidProposalContent, "proposal title must not start/end with white spaces") + } + if len(title) == 0 { + return errorsmod.Wrap(govtypes.ErrInvalidProposalContent, "proposal title cannot be blank") + } + if len(title) > govtypesv1beta.MaxTitleLength { + return errorsmod.Wrapf(govtypes.ErrInvalidProposalContent, "proposal title is longer than max length of %d", govtypesv1beta.MaxTitleLength) + } + if strings.TrimSpace(description) != description { + return errorsmod.Wrap(govtypes.ErrInvalidProposalContent, "proposal description must not start/end with white spaces") + } + if len(description) == 0 { + return errorsmod.Wrap(govtypes.ErrInvalidProposalContent, "proposal description cannot be blank") + } + if len(description) > govtypesv1beta.MaxDescriptionLength { + return errorsmod.Wrapf(govtypes.ErrInvalidProposalContent, "proposal description is longer than max length of %d", govtypesv1beta.MaxDescriptionLength) + } + return nil +} diff --git a/legacygov/scheduler/legacy_proposal.pb.go b/legacygov/scheduler/legacy_proposal.pb.go new file mode 100644 index 00000000..fd9a4dcb --- /dev/null +++ b/legacygov/scheduler/legacy_proposal.pb.go @@ -0,0 +1,1412 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kujira/scheduler/legacy_proposal.proto + +package scheduler + +import ( + fmt "fmt" + github_com_CosmWasm_wasmd_x_wasm_types "github.com/CosmWasm/wasmd/x/wasm/types" + _ "github.com/Team-Kujira/core/x/scheduler/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type CreateHookProposal struct { + // Title is a short summary + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + // Description is a human readable text + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + // The account that will execute the msg on the schedule + Executor string `protobuf:"bytes,3,opt,name=executor,proto3" json:"executor,omitempty"` + // The contract that the msg is called on + Contract string `protobuf:"bytes,4,opt,name=contract,proto3" json:"contract,omitempty"` + Msg github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage `protobuf:"bytes,5,opt,name=msg,proto3,casttype=github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" json:"msg,omitempty"` + Frequency int64 `protobuf:"varint,6,opt,name=frequency,proto3" json:"frequency,omitempty"` + Funds github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,7,rep,name=funds,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"funds"` +} + +func (m *CreateHookProposal) Reset() { *m = CreateHookProposal{} } +func (*CreateHookProposal) ProtoMessage() {} +func (*CreateHookProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_388a0119cb7ba3a9, []int{0} +} +func (m *CreateHookProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CreateHookProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CreateHookProposal.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 *CreateHookProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_CreateHookProposal.Merge(m, src) +} +func (m *CreateHookProposal) XXX_Size() int { + return m.Size() +} +func (m *CreateHookProposal) XXX_DiscardUnknown() { + xxx_messageInfo_CreateHookProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_CreateHookProposal proto.InternalMessageInfo + +func (m *CreateHookProposal) GetTitle() string { + if m != nil { + return m.Title + } + return "" +} + +func (m *CreateHookProposal) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *CreateHookProposal) GetExecutor() string { + if m != nil { + return m.Executor + } + return "" +} + +func (m *CreateHookProposal) GetContract() string { + if m != nil { + return m.Contract + } + return "" +} + +func (m *CreateHookProposal) GetMsg() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { + if m != nil { + return m.Msg + } + return nil +} + +func (m *CreateHookProposal) GetFrequency() int64 { + if m != nil { + return m.Frequency + } + return 0 +} + +func (m *CreateHookProposal) GetFunds() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Funds + } + return nil +} + +type UpdateHookProposal struct { + // Title is a short summary + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + // Description is a human readable text + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Id uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` + Executor string `protobuf:"bytes,4,opt,name=executor,proto3" json:"executor,omitempty"` + Contract string `protobuf:"bytes,5,opt,name=contract,proto3" json:"contract,omitempty"` + Msg github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage `protobuf:"bytes,6,opt,name=msg,proto3,casttype=github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" json:"msg,omitempty"` + Frequency int64 `protobuf:"varint,7,opt,name=frequency,proto3" json:"frequency,omitempty"` + Funds github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,8,rep,name=funds,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"funds"` +} + +func (m *UpdateHookProposal) Reset() { *m = UpdateHookProposal{} } +func (*UpdateHookProposal) ProtoMessage() {} +func (*UpdateHookProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_388a0119cb7ba3a9, []int{1} +} +func (m *UpdateHookProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UpdateHookProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UpdateHookProposal.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 *UpdateHookProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateHookProposal.Merge(m, src) +} +func (m *UpdateHookProposal) XXX_Size() int { + return m.Size() +} +func (m *UpdateHookProposal) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateHookProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_UpdateHookProposal proto.InternalMessageInfo + +func (m *UpdateHookProposal) GetTitle() string { + if m != nil { + return m.Title + } + return "" +} + +func (m *UpdateHookProposal) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *UpdateHookProposal) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +func (m *UpdateHookProposal) GetExecutor() string { + if m != nil { + return m.Executor + } + return "" +} + +func (m *UpdateHookProposal) GetContract() string { + if m != nil { + return m.Contract + } + return "" +} + +func (m *UpdateHookProposal) GetMsg() github_com_CosmWasm_wasmd_x_wasm_types.RawContractMessage { + if m != nil { + return m.Msg + } + return nil +} + +func (m *UpdateHookProposal) GetFrequency() int64 { + if m != nil { + return m.Frequency + } + return 0 +} + +func (m *UpdateHookProposal) GetFunds() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Funds + } + return nil +} + +type DeleteHookProposal struct { + // Title is a short summary + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + // Description is a human readable text + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Id uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *DeleteHookProposal) Reset() { *m = DeleteHookProposal{} } +func (*DeleteHookProposal) ProtoMessage() {} +func (*DeleteHookProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_388a0119cb7ba3a9, []int{2} +} +func (m *DeleteHookProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DeleteHookProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DeleteHookProposal.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 *DeleteHookProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteHookProposal.Merge(m, src) +} +func (m *DeleteHookProposal) XXX_Size() int { + return m.Size() +} +func (m *DeleteHookProposal) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteHookProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteHookProposal proto.InternalMessageInfo + +func (m *DeleteHookProposal) GetTitle() string { + if m != nil { + return m.Title + } + return "" +} + +func (m *DeleteHookProposal) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *DeleteHookProposal) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +func init() { + proto.RegisterType((*CreateHookProposal)(nil), "kujira.scheduler.CreateHookProposal") + proto.RegisterType((*UpdateHookProposal)(nil), "kujira.scheduler.UpdateHookProposal") + proto.RegisterType((*DeleteHookProposal)(nil), "kujira.scheduler.DeleteHookProposal") +} + +func init() { + proto.RegisterFile("kujira/scheduler/legacy_proposal.proto", fileDescriptor_388a0119cb7ba3a9) +} + +var fileDescriptor_388a0119cb7ba3a9 = []byte{ + // 461 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0x4f, 0x6b, 0xd4, 0x40, + 0x18, 0xc6, 0x93, 0xec, 0x9f, 0xb6, 0x53, 0x11, 0x19, 0x7a, 0x88, 0xab, 0x64, 0x43, 0x0f, 0x92, + 0x4b, 0x33, 0x56, 0x4f, 0x1e, 0xbc, 0xec, 0x7a, 0x10, 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0x0b, 0xcf, 0xfe, 0xba, 0xf0, 0xec, 0x8f, 0x4b, 0xcf, 0x3a, + 0x5b, 0x7a, 0xd6, 0xf9, 0xd2, 0xb3, 0xde, 0xb0, 0x95, 0xb0, 0x2f, 0x81, 0xe7, 0x7b, 0xcf, 0x4c, + 0x15, 0x05, 0x4a, 0x68, 0x5b, 0x9d, 0xe0, 0xd1, 0x55, 0x33, 0x27, 0xfd, 0xa6, 0x75, 0x0f, 0x7f, + 0x06, 0x00, 0x00, 0xff, 0xff, 0xdf, 0x07, 0xef, 0x6e, 0x04, 0x04, 0x00, 0x00, +} + +func (m *CreateHookProposal) 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 *CreateHookProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CreateHookProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Funds) > 0 { + for iNdEx := len(m.Funds) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Funds[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLegacyProposal(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if m.Frequency != 0 { + i = encodeVarintLegacyProposal(dAtA, i, uint64(m.Frequency)) + i-- + dAtA[i] = 0x30 + } + if len(m.Msg) > 0 { + i -= len(m.Msg) + copy(dAtA[i:], m.Msg) + i = encodeVarintLegacyProposal(dAtA, i, uint64(len(m.Msg))) + i-- + dAtA[i] = 0x2a + } + if len(m.Contract) > 0 { + i -= len(m.Contract) + copy(dAtA[i:], m.Contract) + i = encodeVarintLegacyProposal(dAtA, i, uint64(len(m.Contract))) + i-- + dAtA[i] = 0x22 + } + if len(m.Executor) > 0 { + i -= len(m.Executor) + copy(dAtA[i:], m.Executor) + i = encodeVarintLegacyProposal(dAtA, i, uint64(len(m.Executor))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintLegacyProposal(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintLegacyProposal(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *UpdateHookProposal) 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 *UpdateHookProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UpdateHookProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Funds) > 0 { + for iNdEx := len(m.Funds) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Funds[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLegacyProposal(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } + if m.Frequency != 0 { + i = encodeVarintLegacyProposal(dAtA, i, uint64(m.Frequency)) + i-- + dAtA[i] = 0x38 + } + if len(m.Msg) > 0 { + i -= len(m.Msg) + copy(dAtA[i:], m.Msg) + i = encodeVarintLegacyProposal(dAtA, i, uint64(len(m.Msg))) + i-- + dAtA[i] = 0x32 + } + if len(m.Contract) > 0 { + i -= len(m.Contract) + copy(dAtA[i:], m.Contract) + i = encodeVarintLegacyProposal(dAtA, i, uint64(len(m.Contract))) + i-- + dAtA[i] = 0x2a + } + if len(m.Executor) > 0 { + i -= len(m.Executor) + copy(dAtA[i:], m.Executor) + i = encodeVarintLegacyProposal(dAtA, i, uint64(len(m.Executor))) + i-- + dAtA[i] = 0x22 + } + if m.Id != 0 { + i = encodeVarintLegacyProposal(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x18 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintLegacyProposal(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintLegacyProposal(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DeleteHookProposal) 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 *DeleteHookProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DeleteHookProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Id != 0 { + i = encodeVarintLegacyProposal(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x18 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintLegacyProposal(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintLegacyProposal(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintLegacyProposal(dAtA []byte, offset int, v uint64) int { + offset -= sovLegacyProposal(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *CreateHookProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovLegacyProposal(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovLegacyProposal(uint64(l)) + } + l = len(m.Executor) + if l > 0 { + n += 1 + l + sovLegacyProposal(uint64(l)) + } + l = len(m.Contract) + if l > 0 { + n += 1 + l + sovLegacyProposal(uint64(l)) + } + l = len(m.Msg) + if l > 0 { + n += 1 + l + sovLegacyProposal(uint64(l)) + } + if m.Frequency != 0 { + n += 1 + sovLegacyProposal(uint64(m.Frequency)) + } + if len(m.Funds) > 0 { + for _, e := range m.Funds { + l = e.Size() + n += 1 + l + sovLegacyProposal(uint64(l)) + } + } + return n +} + +func (m *UpdateHookProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovLegacyProposal(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovLegacyProposal(uint64(l)) + } + if m.Id != 0 { + n += 1 + sovLegacyProposal(uint64(m.Id)) + } + l = len(m.Executor) + if l > 0 { + n += 1 + l + sovLegacyProposal(uint64(l)) + } + l = len(m.Contract) + if l > 0 { + n += 1 + l + sovLegacyProposal(uint64(l)) + } + l = len(m.Msg) + if l > 0 { + n += 1 + l + sovLegacyProposal(uint64(l)) + } + if m.Frequency != 0 { + n += 1 + sovLegacyProposal(uint64(m.Frequency)) + } + if len(m.Funds) > 0 { + for _, e := range m.Funds { + l = e.Size() + n += 1 + l + sovLegacyProposal(uint64(l)) + } + } + return n +} + +func (m *DeleteHookProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovLegacyProposal(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovLegacyProposal(uint64(l)) + } + if m.Id != 0 { + n += 1 + sovLegacyProposal(uint64(m.Id)) + } + return n +} + +func sovLegacyProposal(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozLegacyProposal(x uint64) (n int) { + return sovLegacyProposal(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *CreateHookProposal) 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 ErrIntOverflowLegacyProposal + } + 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: CreateHookProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CreateHookProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + 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 ErrInvalidLengthLegacyProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLegacyProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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 ErrIntOverflowLegacyProposal + } + 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 ErrInvalidLengthLegacyProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLegacyProposal + } + 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 Executor", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + 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 ErrInvalidLengthLegacyProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLegacyProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Executor = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + 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 ErrInvalidLengthLegacyProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLegacyProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Contract = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthLegacyProposal + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthLegacyProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Msg = append(m.Msg[:0], dAtA[iNdEx:postIndex]...) + if m.Msg == nil { + m.Msg = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Frequency", wireType) + } + m.Frequency = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Frequency |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Funds", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLegacyProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLegacyProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Funds = append(m.Funds, types.Coin{}) + if err := m.Funds[len(m.Funds)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLegacyProposal(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLegacyProposal + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UpdateHookProposal) 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 ErrIntOverflowLegacyProposal + } + 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: UpdateHookProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UpdateHookProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + 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 ErrInvalidLengthLegacyProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLegacyProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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 ErrIntOverflowLegacyProposal + } + 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 ErrInvalidLengthLegacyProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLegacyProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Executor", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + 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 ErrInvalidLengthLegacyProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLegacyProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Executor = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + 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 ErrInvalidLengthLegacyProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLegacyProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Contract = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthLegacyProposal + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthLegacyProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Msg = append(m.Msg[:0], dAtA[iNdEx:postIndex]...) + if m.Msg == nil { + m.Msg = []byte{} + } + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Frequency", wireType) + } + m.Frequency = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Frequency |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Funds", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLegacyProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLegacyProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Funds = append(m.Funds, types.Coin{}) + if err := m.Funds[len(m.Funds)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLegacyProposal(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLegacyProposal + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeleteHookProposal) 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 ErrIntOverflowLegacyProposal + } + 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: DeleteHookProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeleteHookProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + 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 ErrInvalidLengthLegacyProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLegacyProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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 ErrIntOverflowLegacyProposal + } + 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 ErrInvalidLengthLegacyProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLegacyProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipLegacyProposal(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLegacyProposal + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipLegacyProposal(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, ErrIntOverflowLegacyProposal + } + 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, ErrIntOverflowLegacyProposal + } + 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, ErrIntOverflowLegacyProposal + } + 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, ErrInvalidLengthLegacyProposal + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupLegacyProposal + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthLegacyProposal + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthLegacyProposal = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowLegacyProposal = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupLegacyProposal = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/alliance/alliance/alliance.proto b/proto/alliance/alliance/alliance.proto new file mode 100644 index 00000000..49765446 --- /dev/null +++ b/proto/alliance/alliance/alliance.proto @@ -0,0 +1,73 @@ +syntax = "proto3"; +package alliance.alliance; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/Team-Kujira/core/legacygov/alliance"; + +message RewardWeightRange { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string min = 1 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + string max = 2 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; +} +// key: denom value: AllianceAsset +message AllianceAsset { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // Denom of the asset. It could either be a native token or an IBC token + string denom = 1 [(gogoproto.moretags) = "yaml:\"denom\""]; + // The reward weight specifies the ratio of rewards that will be given to each alliance asset + // It does not need to sum to 1. rate = weight / total_weight + // Native asset is always assumed to have a weight of 1.s + string reward_weight = 2 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + // A positive take rate is used for liquid staking derivatives. It defines an rate that is applied per take_rate_interval + // that will be redirected to the distribution rewards pool + string take_rate = 3 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + string total_tokens = 4 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + string total_validator_shares = 5 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + google.protobuf.Timestamp reward_start_time = 6 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false + ]; + string reward_change_rate = 7 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + google.protobuf.Duration reward_change_interval = 8 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true + ]; + google.protobuf.Timestamp last_reward_change_time = 9 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false + ]; + // set a bound of weight range to limit how much reward weights can scale. + RewardWeightRange reward_weight_range = 10 [(gogoproto.nullable) = false]; + // flag to check if an asset has completed the initialization process after the reward delay + bool is_initialized = 11; +} \ No newline at end of file diff --git a/proto/alliance/alliance/gov.proto b/proto/alliance/alliance/gov.proto new file mode 100644 index 00000000..ea99901d --- /dev/null +++ b/proto/alliance/alliance/gov.proto @@ -0,0 +1,98 @@ +syntax = "proto3"; +package alliance.alliance; + +import "alliance/alliance/alliance.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "github.com/Team-Kujira/core/legacygov/alliance"; + +message MsgCreateAllianceProposal { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // the title of the update proposal + string title = 1; + // the description of the proposal + string description = 2; + // Denom of the asset. It could either be a native token or an IBC token + string denom = 3 [(gogoproto.moretags) = "yaml:\"denom\""]; + // The reward weight specifies the ratio of rewards that will be given to each alliance asset + // It does not need to sum to 1. rate = weight / total_weight + // Native asset is always assumed to have a weight of 1. + string reward_weight = 4 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + // A positive take rate is used for liquid staking derivatives. It defines an annualized reward rate that + // will be redirected to the distribution rewards pool + string take_rate = 5 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + + string reward_change_rate = 6 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + + google.protobuf.Duration reward_change_interval = 7 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true + ]; + + // set a bound of weight range to limit how much reward weights can scale. + RewardWeightRange reward_weight_range = 8 [ + (gogoproto.nullable) = false + ]; +} + +message MsgUpdateAllianceProposal { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // the title of the update proposal + string title = 1; + // the description of the proposal + string description = 2; + // Denom of the asset. It could either be a native token or an IBC token + string denom = 3 [(gogoproto.moretags) = "yaml:\"denom\""]; + // The reward weight specifies the ratio of rewards that will be given to each alliance asset + // It does not need to sum to 1. rate = weight / total_weight + // Native asset is always assumed to have a weight of 1. + string reward_weight = 4 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + + string take_rate = 5 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + + string reward_change_rate = 6 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + + google.protobuf.Duration reward_change_interval = 7 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true + ]; + + // set a bound of weight range to limit how much reward weights can scale. + RewardWeightRange reward_weight_range = 8 [ + (gogoproto.nullable) = false + ]; +} + +message MsgDeleteAllianceProposal { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // the title of the update proposal + string title = 1; + // the description of the proposal + string description = 2; + string denom = 3 [(gogoproto.moretags) = "yaml:\"denom\""]; +} \ No newline at end of file diff --git a/proto/kujira/crypto/authn/keys.proto b/proto/kujira/crypto/authn/keys.proto new file mode 100644 index 00000000..11fa9e8d --- /dev/null +++ b/proto/kujira/crypto/authn/keys.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package kujira.crypto.authn; + +import "amino/amino.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/Team-Kujira/core/crypto/keys/authn"; + +// PubKey defines a authn public key +message PubKey { + option (amino.name) = "tendermint/PubKeyAuthn"; + + option (amino.message_encoding) = "key_field"; + option (gogoproto.goproto_stringer) = false; + + string key_id = 1; + bytes key = 2; +} diff --git a/proto/kujira/denom/genesis.proto b/proto/kujira/denom/genesis.proto index 1bd46fd6..bd9b1bb8 100644 --- a/proto/kujira/denom/genesis.proto +++ b/proto/kujira/denom/genesis.proto @@ -16,6 +16,9 @@ message GenesisState { (gogoproto.moretags) = "yaml:\"factory_denoms\"", (gogoproto.nullable) = false ]; + + // whitelisted accounts that do not require paying creation fees + repeated string no_fee_accounts = 3; } message GenesisDenom { diff --git a/proto/kujira/denom/query.proto b/proto/kujira/denom/query.proto index bf233df3..d4deaa87 100644 --- a/proto/kujira/denom/query.proto +++ b/proto/kujira/denom/query.proto @@ -27,6 +27,20 @@ service Query { option (google.api.http).get = "/kujira/denoms/by_creator/{creator}"; } + + // NoFeeAccounts returns accounts whitelisted to create denom without fee + rpc NoFeeAccounts(QueryNoFeeAccountsRequest) returns (QueryNoFeeAccountsResponse) { + option (google.api.http).get = "/kujira/denoms/no_fee_accounts"; + } +} + +// QueryNoFeeAccountsRequest is the request type for the Query/NoFeeAccounts RPC method. +message QueryNoFeeAccountsRequest {} + +// QueryNoFeeAccountsResponse is the response type for the Query/NoFeeAccounts RPC method. +message QueryNoFeeAccountsResponse { + // params defines the parameters of the module. + repeated string accounts = 1; } // QueryParamsRequest is the request type for the Query/Params RPC method. diff --git a/proto/kujira/denom/tx.proto b/proto/kujira/denom/tx.proto index d481c5af..77eb044f 100644 --- a/proto/kujira/denom/tx.proto +++ b/proto/kujira/denom/tx.proto @@ -10,6 +10,8 @@ option go_package = "github.com/Team-Kujira/core/x/denom/types"; // Msg defines the Msg service. service Msg { + rpc AddNoFeeAccounts(MsgAddNoFeeAccounts) returns (MsgAddNoFeeAccountsResponse); + rpc RemoveNoFeeAccounts(MsgRemoveNoFeeAccounts) returns (MsgRemoveNoFeeAccountsResponse); rpc CreateDenom(MsgCreateDenom) returns (MsgCreateDenomResponse); rpc Mint(MsgMint) returns (MsgMintResponse); rpc Burn(MsgBurn) returns (MsgBurnResponse); @@ -22,6 +24,18 @@ service Msg { rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } +message MsgAddNoFeeAccounts { + string authority = 1; + repeated string accounts = 2; +} +message MsgAddNoFeeAccountsResponse {} + +message MsgRemoveNoFeeAccounts { + string authority = 1; + repeated string accounts = 2; +} +message MsgRemoveNoFeeAccountsResponse {} + // MsgCreateDenom is the sdk.Msg type for allowing an account to create // a new denom. It requires a sender address and a unique nonce // (to allow accounts to create multiple denoms) diff --git a/proto/kujira/oracle/oracle.proto b/proto/kujira/oracle/oracle.proto index df12424f..3cb36af2 100644 --- a/proto/kujira/oracle/oracle.proto +++ b/proto/kujira/oracle/oracle.proto @@ -11,29 +11,28 @@ message Params { option (gogoproto.equal) = true; option (gogoproto.goproto_stringer) = false; - uint64 vote_period = 1 [(gogoproto.moretags) = "yaml:\"vote_period\""]; - string vote_threshold = 2 [ + string vote_threshold = 1 [ (gogoproto.moretags) = "yaml:\"vote_threshold\"", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; - string max_deviation = 3 [ + string max_deviation = 2 [ (gogoproto.moretags) = "yaml:\"max_deviation\"", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; - repeated Symbol required_symbols = 4 [ + repeated Symbol required_symbols = 3 [ (gogoproto.moretags) = "yaml:\"required_symbols\"", (gogoproto.nullable) = false ]; - uint32 last_symbol_id = 5; - string slash_fraction = 6 [ + uint32 last_symbol_id = 4; + string slash_fraction = 5 [ (gogoproto.moretags) = "yaml:\"slash_fraction\"", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; - uint64 slash_window = 7 [(gogoproto.moretags) = "yaml:\"slash_window\""]; - string min_valid_per_window = 8 [ + uint64 slash_window = 6 [(gogoproto.moretags) = "yaml:\"slash_window\""]; + string min_valid_per_window = 7 [ (gogoproto.moretags) = "yaml:\"min_valid_per_window\"", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false diff --git a/proto/kujira/oracle/query.proto b/proto/kujira/oracle/query.proto index 927a0d6a..f1bd9fef 100644 --- a/proto/kujira/oracle/query.proto +++ b/proto/kujira/oracle/query.proto @@ -101,7 +101,6 @@ message QueryMissCounterResponse { uint64 miss_counter = 1; } - // QueryParamsRequest is the request type for the Query/Params RPC method. message QueryParamsRequest {} @@ -109,4 +108,4 @@ message QueryParamsRequest {} message QueryParamsResponse { // params defines the parameters of the module. Params params = 1 [(gogoproto.nullable) = false]; -} \ No newline at end of file +} diff --git a/proto/kujira/scheduler/legacy_proposal.proto b/proto/kujira/scheduler/legacy_proposal.proto new file mode 100644 index 00000000..b427b6a6 --- /dev/null +++ b/proto/kujira/scheduler/legacy_proposal.proto @@ -0,0 +1,59 @@ +syntax = "proto3"; +package kujira.scheduler; + +import "gogoproto/gogo.proto"; +import "kujira/scheduler/hook.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/Team-Kujira/core/legacygov/scheduler"; +option (gogoproto.goproto_stringer_all) = false; + + +message CreateHookProposal { + // Title is a short summary + string title = 1; + // Description is a human readable text + string description = 2; + + // The account that will execute the msg on the schedule + string executor = 3; + + // The contract that the msg is called on + string contract = 4; + + bytes msg = 5 [ (gogoproto.casttype) = "github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" ]; + int64 frequency = 6; + repeated cosmos.base.v1beta1.Coin funds = 7 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + +} + +message UpdateHookProposal { + // Title is a short summary + string title = 1; + + // Description is a human readable text + string description = 2; + + uint64 id = 3; + string executor = 4; + string contract = 5; + bytes msg = 6 [ (gogoproto.casttype) = "github.com/CosmWasm/wasmd/x/wasm/types.RawContractMessage" ]; + int64 frequency = 7; + repeated cosmos.base.v1beta1.Coin funds = 8 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +message DeleteHookProposal { + // Title is a short summary + string title = 1; + + // Description is a human readable text + string description = 2; + + uint64 id = 3; +} diff --git a/wasmbinding/bindings/ibc.go b/wasmbinding/bindings/ibc.go index 137f1818..610f14bb 100644 --- a/wasmbinding/bindings/ibc.go +++ b/wasmbinding/bindings/ibc.go @@ -20,7 +20,7 @@ type VerifyMembershipQuery struct { Proof []byte `json:"proof"` Value []byte `json:"value"` PathPrefix string `json:"path_prefix"` - PathKey string `json:"path_key"` + PathKey []byte `json:"path_key"` } type VerifyNonMembershipQuery struct { @@ -29,7 +29,7 @@ type VerifyNonMembershipQuery struct { RevisionHeight uint64 `json:"revision_height"` Proof []byte `json:"proof"` PathPrefix string `json:"path_prefix"` - PathKey string `json:"path_key"` + PathKey []byte `json:"path_key"` } type IbcVerifyResponse struct{} @@ -119,7 +119,7 @@ func HandleIBCQuery(ctx sdk.Context, keeper ibckeeper.Keeper, ibcStoreKey *store } height := clienttypes.NewHeight(q.VerifyMembership.RevisionNumber, q.VerifyMembership.RevisionHeight) - consState, merklePath, err := getConsStateAndMerklePath(keeper, clientState, clientStore, height, q.VerifyMembership.PathPrefix, q.VerifyMembership.PathKey) + consState, merklePath, err := getConsStateAndMerklePath(keeper, clientState, clientStore, height, q.VerifyMembership.PathPrefix, string(q.VerifyMembership.PathKey)) if err != nil { return err } @@ -148,7 +148,7 @@ func HandleIBCQuery(ctx sdk.Context, keeper ibckeeper.Keeper, ibcStoreKey *store } height := clienttypes.NewHeight(q.VerifyNonMembership.RevisionNumber, q.VerifyNonMembership.RevisionHeight) - consState, merklePath, err := getConsStateAndMerklePath(keeper, clientState, clientStore, height, q.VerifyMembership.PathPrefix, q.VerifyMembership.PathKey) + consState, merklePath, err := getConsStateAndMerklePath(keeper, clientState, clientStore, height, q.VerifyMembership.PathPrefix, string(q.VerifyMembership.PathKey)) if err != nil { return err } diff --git a/wasmbinding/message_plugin.go b/wasmbinding/message_plugin.go index 27f8dc7f..542c84ba 100644 --- a/wasmbinding/message_plugin.go +++ b/wasmbinding/message_plugin.go @@ -13,6 +13,7 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/Team-Kujira/core/wasmbinding/bindings" + ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" batchkeeper "github.com/Team-Kujira/core/x/batch/keeper" batch "github.com/Team-Kujira/core/x/batch/wasm" @@ -27,27 +28,32 @@ import ( func CustomMessageDecorator( bank bankkeeper.Keeper, denom denomkeeper.Keeper, + batch batchkeeper.Keeper, cwica cwicakeeper.Keeper, ica icacontrollerkeeper.Keeper, + transfer ibctransferkeeper.Keeper, ) func(wasmkeeper.Messenger) wasmkeeper.Messenger { return func(old wasmkeeper.Messenger) wasmkeeper.Messenger { return &CustomMessenger{ - wrapped: old, - bank: bank, - denom: denom, - cwica: cwica, - ica: ica, + wrapped: old, + bank: bank, + denom: denom, + cwica: cwica, + ica: ica, + batch: batch, + transfer: transfer, } } } type CustomMessenger struct { - wrapped wasmkeeper.Messenger - bank bankkeeper.Keeper - denom denomkeeper.Keeper - cwica cwicakeeper.Keeper - ica icacontrollerkeeper.Keeper - batch batchkeeper.Keeper + wrapped wasmkeeper.Messenger + bank bankkeeper.Keeper + denom denomkeeper.Keeper + cwica cwicakeeper.Keeper + ica icacontrollerkeeper.Keeper + batch batchkeeper.Keeper + transfer ibctransferkeeper.Keeper } var _ wasmkeeper.Messenger = (*CustomMessenger)(nil) @@ -76,7 +82,7 @@ func (m *CustomMessenger) DispatchMsg( } if contractMsg.CwIca != nil { - return cwica.HandleMsg(ctx, m.cwica, m.ica, contractAddr, contractMsg.CwIca) + return cwica.HandleMsg(ctx, m.cwica, m.ica, m.transfer, contractAddr, contractMsg.CwIca) } return nil, nil, nil, wasmvmtypes.UnsupportedRequest{Kind: "unknown Custom variant"} diff --git a/wasmbinding/test/wasm_test.go b/wasmbinding/test/wasm_test.go index 178183a3..04617782 100644 --- a/wasmbinding/test/wasm_test.go +++ b/wasmbinding/test/wasm_test.go @@ -70,7 +70,7 @@ func TestQueryExchangeRates(t *testing.T) { }) require.NoError(t, err) - res, err = querier(ctx, bz) + _, err = querier(ctx, bz) require.NoError(t, err) queryParams = wasm.ExchangeRateQueryParams{ @@ -118,6 +118,7 @@ func TestSupply(t *testing.T) { var x banktypes.QuerySupplyOfResponse res, err := querier(ctx, bz) + require.NoError(t, err) err = json.Unmarshal(res, &x) require.NoError(t, err) @@ -138,14 +139,14 @@ func TestVerifyMembership(t *testing.T) { Proof: []byte{}, Value: []byte{}, PathPrefix: "ibc", - PathKey: "connections/connection-0", + PathKey: []byte("connections/connection-0"), }, } bz, err := json.Marshal(queryMsg) require.NoError(t, err) - bz, err = app.WasmKeeper.QuerySmart(ctx, contractAddr, bz) + _, err = app.WasmKeeper.QuerySmart(ctx, contractAddr, bz) require.Error(t, err) } @@ -163,13 +164,13 @@ func TestVerifyNonMembership(t *testing.T) { RevisionHeight: 0, Proof: []byte{}, PathPrefix: "ibc", - PathKey: "connections/connection-0", + PathKey: []byte("connections/connection-0"), }, } bz, err := json.Marshal(queryMsg) require.NoError(t, err) - bz, err = app.WasmKeeper.QuerySmart(ctx, contractAddr, bz) + _, err = app.WasmKeeper.QuerySmart(ctx, contractAddr, bz) require.Error(t, err) } diff --git a/wasmbinding/wasm.go b/wasmbinding/wasm.go index b6d2b8d9..561b703f 100644 --- a/wasmbinding/wasm.go +++ b/wasmbinding/wasm.go @@ -2,6 +2,7 @@ package wasmbinding import ( storetypes "cosmossdk.io/store/types" + batchkeeper "github.com/Team-Kujira/core/x/batch/keeper" denomkeeper "github.com/Team-Kujira/core/x/denom/keeper" oraclekeeper "github.com/Team-Kujira/core/x/oracle/keeper" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" @@ -12,15 +13,18 @@ import ( cwicakeeper "github.com/Team-Kujira/core/x/cw-ica/keeper" icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper" + ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" ) func RegisterCustomPlugins( bank bankkeeper.Keeper, oracle oraclekeeper.Keeper, denom denomkeeper.Keeper, + batch batchkeeper.Keeper, ibc ibckeeper.Keeper, cwica cwicakeeper.Keeper, ica icacontrollerkeeper.Keeper, + transfer ibctransferkeeper.Keeper, ibcStoreKey *storetypes.KVStoreKey, ) []wasmkeeper.Option { wasmQueryPlugin := NewQueryPlugin(bank, oracle, denom, ibc, cwica, ibcStoreKey) @@ -30,7 +34,7 @@ func RegisterCustomPlugins( }) messengerDecoratorOpt := wasmkeeper.WithMessageHandlerDecorator( - CustomMessageDecorator(bank, denom, cwica, ica), + CustomMessageDecorator(bank, denom, batch, cwica, ica, transfer), ) return []wasmkeeper.Option{ diff --git a/x/batch/keeper/delegation_test.go b/x/batch/keeper/delegation_test.go index 19e05666..787ecc72 100644 --- a/x/batch/keeper/delegation_test.go +++ b/x/batch/keeper/delegation_test.go @@ -52,26 +52,26 @@ func (suite *KeeperTestSuite) TestWithdrawAllDelegationRewards() { validator, _ = validator.SetInitialCommission(stakingtypes.NewCommission(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))) validator, _ = validator.AddTokensFromDel(valTokens) - err = suite.app.StakingKeeper.SetValidator(sdk.WrapSDKContext(suite.ctx), validator) + err = suite.app.StakingKeeper.SetValidator(suite.ctx, validator) suite.NoError(err) - err = suite.app.StakingKeeper.SetValidatorByConsAddr(sdk.WrapSDKContext(suite.ctx), validator) + err = suite.app.StakingKeeper.SetValidatorByConsAddr(suite.ctx, validator) suite.NoError(err) - err = suite.app.StakingKeeper.SetValidatorByPowerIndex(sdk.WrapSDKContext(suite.ctx), validator) + err = suite.app.StakingKeeper.SetValidatorByPowerIndex(suite.ctx, validator) suite.NoError(err) // Call the after-creation hook valAddr, err := sdk.ValAddressFromBech32(validator.GetOperator()) suite.Require().NoError(err) - err = suite.app.StakingKeeper.Hooks().AfterValidatorCreated(sdk.WrapSDKContext(suite.ctx), valAddr) + err = suite.app.StakingKeeper.Hooks().AfterValidatorCreated(suite.ctx, valAddr) suite.NoError(err) // Delegate to the validator delAmount := sdk.NewCoin(sdk.DefaultBondDenom, delTokens) - err = suite.app.BankKeeper.MintCoins(sdk.WrapSDKContext(suite.ctx), minttypes.ModuleName, sdk.Coins{delAmount}) - suite.app.BankKeeper.SendCoinsFromModuleToAccount(sdk.WrapSDKContext(suite.ctx), minttypes.ModuleName, delAddr, sdk.Coins{delAmount}) + err = suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, sdk.Coins{delAmount}) + suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, delAddr, sdk.Coins{delAmount}) suite.Require().NoError(err) - _, err = suite.app.StakingKeeper.Delegate(sdk.WrapSDKContext(suite.ctx), delAddr, delAmount.Amount, stakingtypes.Unbonded, validator, true) + _, err = suite.app.StakingKeeper.Delegate(suite.ctx, delAddr, delAmount.Amount, stakingtypes.Unbonded, validator, true) suite.Require().NoError(err) } @@ -85,8 +85,8 @@ func (suite *KeeperTestSuite) TestWithdrawAllDelegationRewards() { } distrModuleTokens = distrModuleTokens.Sort() - err := suite.app.BankKeeper.MintCoins(sdk.WrapSDKContext(suite.ctx), minttypes.ModuleName, distrModuleTokens) - suite.app.BankKeeper.SendCoinsFromModuleToModule(sdk.WrapSDKContext(suite.ctx), minttypes.ModuleName, distrtypes.ModuleName, distrModuleTokens) + err := suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, distrModuleTokens) + suite.app.BankKeeper.SendCoinsFromModuleToModule(suite.ctx, minttypes.ModuleName, distrtypes.ModuleName, distrModuleTokens) suite.Require().NoError(err) // Allocate rewards to validators @@ -98,14 +98,14 @@ func (suite *KeeperTestSuite) TestWithdrawAllDelegationRewards() { } for i := 0; i < totalVals; i++ { valAddr := sdk.ValAddress(valConsAddrs[i]) - validator, err := suite.app.StakingKeeper.Validator(sdk.WrapSDKContext(suite.ctx), valAddr) + validator, err := suite.app.StakingKeeper.Validator(suite.ctx, valAddr) suite.Require().NoError(err) - suite.app.DistrKeeper.AllocateTokensToValidator(sdk.WrapSDKContext(suite.ctx), validator, valRewardTokens) + suite.app.DistrKeeper.AllocateTokensToValidator(suite.ctx, validator, valRewardTokens) } // Withdraw all rewards using a single batch transaction gasForBatchWithdrawal := suite.ctx.GasMeter().GasConsumed() - res, err := batchMsgServer.WithdrawAllDelegatorRewards(sdk.WrapSDKContext(suite.ctx), batchtypes.NewMsgWithdrawAllDelegatorRewards(delAddr)) + res, err := batchMsgServer.WithdrawAllDelegatorRewards(suite.ctx, batchtypes.NewMsgWithdrawAllDelegatorRewards(delAddr)) gasForBatchWithdrawal = suite.ctx.GasMeter().GasConsumed() - gasForBatchWithdrawal suite.Require().NoError(err) suite.Require().False(res.Amount.IsZero()) @@ -114,13 +114,13 @@ func (suite *KeeperTestSuite) TestWithdrawAllDelegationRewards() { // check if there are no pending rewards for any validator for i := 0; i < totalVals; i++ { valAddr := sdk.ValAddress(valConsAddrs[i]) - val, err := suite.app.StakingKeeper.Validator(sdk.WrapSDKContext(suite.ctx), valAddr) + val, err := suite.app.StakingKeeper.Validator(suite.ctx, valAddr) suite.Require().NoError(err) - delegation, err := suite.app.StakingKeeper.Delegation(sdk.WrapSDKContext(suite.ctx), delAddr, valAddr) + delegation, err := suite.app.StakingKeeper.Delegation(suite.ctx, delAddr, valAddr) suite.Require().NoError(err) - endingPeriod, err := suite.app.DistrKeeper.IncrementValidatorPeriod(sdk.WrapSDKContext(suite.ctx), val) + endingPeriod, err := suite.app.DistrKeeper.IncrementValidatorPeriod(suite.ctx, val) suite.Require().NoError(err) - rewards, err := suite.app.DistrKeeper.CalculateDelegationRewards(sdk.WrapSDKContext(suite.ctx), val, delegation, endingPeriod) + rewards, err := suite.app.DistrKeeper.CalculateDelegationRewards(suite.ctx, val, delegation, endingPeriod) suite.Require().NoError(err) suite.Require().True(rewards.IsZero()) } @@ -131,9 +131,9 @@ func (suite *KeeperTestSuite) TestWithdrawAllDelegationRewards() { // Allocate rewards to validators for i := 0; i < totalVals; i++ { valAddr := sdk.ValAddress(valConsAddrs[i]) - validator, err := suite.app.StakingKeeper.Validator(sdk.WrapSDKContext(suite.ctx), valAddr) + validator, err := suite.app.StakingKeeper.Validator(suite.ctx, valAddr) suite.Require().NoError(err) - suite.app.DistrKeeper.AllocateTokensToValidator(sdk.WrapSDKContext(suite.ctx), validator, valRewardTokens) + suite.app.DistrKeeper.AllocateTokensToValidator(suite.ctx, validator, valRewardTokens) suite.Require().NoError(err) } @@ -143,7 +143,7 @@ func (suite *KeeperTestSuite) TestWithdrawAllDelegationRewards() { for i := 0; i < totalVals; i++ { valAddr := sdk.ValAddress(valConsAddrs[i]) // Withdraw rewards - res, err := distrMsgServer.WithdrawDelegatorReward(sdk.WrapSDKContext(suite.ctx), distrtypes.NewMsgWithdrawDelegatorReward(delAddr.String(), valAddr.String())) + res, err := distrMsgServer.WithdrawDelegatorReward(suite.ctx, distrtypes.NewMsgWithdrawDelegatorReward(delAddr.String(), valAddr.String())) suite.Require().NoError(err) suite.Require().False(res.Amount.IsZero()) // check individual rewards are accurate @@ -185,14 +185,14 @@ func (suite *KeeperTestSuite) TestBatchResetDelegation() { validator, _ = validator.SetInitialCommission(stakingtypes.NewCommission(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))) validator, _ = validator.AddTokensFromDel(valTokens) - suite.app.StakingKeeper.SetValidator(sdk.WrapSDKContext(suite.ctx), validator) - suite.app.StakingKeeper.SetValidatorByConsAddr(sdk.WrapSDKContext(suite.ctx), validator) - suite.app.StakingKeeper.SetValidatorByPowerIndex(sdk.WrapSDKContext(suite.ctx), validator) + suite.app.StakingKeeper.SetValidator(suite.ctx, validator) + suite.app.StakingKeeper.SetValidatorByConsAddr(suite.ctx, validator) + suite.app.StakingKeeper.SetValidatorByPowerIndex(suite.ctx, validator) // Call the after-creation hook valAddr, err := sdk.ValAddressFromBech32(validator.GetOperator()) suite.Require().NoError(err) - err = suite.app.StakingKeeper.Hooks().AfterValidatorCreated(sdk.WrapSDKContext(suite.ctx), valAddr) + err = suite.app.StakingKeeper.Hooks().AfterValidatorCreated(suite.ctx, valAddr) suite.Require().NoError(err) validators = append(validators, validator.GetOperator()) @@ -200,12 +200,12 @@ func (suite *KeeperTestSuite) TestBatchResetDelegation() { // Mint coins for delegation delAmount := sdk.NewCoin(sdk.DefaultBondDenom, delTokens) - err = suite.app.BankKeeper.MintCoins(sdk.WrapSDKContext(suite.ctx), minttypes.ModuleName, sdk.Coins{delAmount}) - suite.app.BankKeeper.SendCoinsFromModuleToAccount(sdk.WrapSDKContext(suite.ctx), minttypes.ModuleName, delAddr, sdk.Coins{delAmount}) + err = suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, sdk.Coins{delAmount}) + suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, delAddr, sdk.Coins{delAmount}) suite.Require().NoError(err) // setup initial delegation - _, err = suite.app.StakingKeeper.Delegate(sdk.WrapSDKContext(suite.ctx), delAddr, math.NewInt(1000), stakingtypes.Unbonded, validator, true) + _, err = suite.app.StakingKeeper.Delegate(suite.ctx, delAddr, math.NewInt(1000), stakingtypes.Unbonded, validator, true) suite.Require().NoError(err) } @@ -214,7 +214,7 @@ func (suite *KeeperTestSuite) TestBatchResetDelegation() { // Set all delegations using a single batch transaction gasForBatchDelegation := cacheCtx1.GasMeter().GasConsumed() - _, err := batchMsgServer.BatchResetDelegation(sdk.WrapSDKContext(cacheCtx1), batchtypes.NewMsgBatchResetDelegation(delAddr, validators, amounts)) + _, err := batchMsgServer.BatchResetDelegation(cacheCtx1, batchtypes.NewMsgBatchResetDelegation(delAddr, validators, amounts)) gasForBatchDelegation = cacheCtx1.GasMeter().GasConsumed() - gasForBatchDelegation suite.Require().NoError(err) @@ -228,7 +228,7 @@ func (suite *KeeperTestSuite) TestBatchResetDelegation() { existingDelegation := math.NewInt(1000) if amounts[i].GT(existingDelegation) { _, err := stakingMsgServer.Delegate( - sdk.WrapSDKContext(cacheCtx2), + cacheCtx2, stakingtypes.NewMsgDelegate( delAddr.String(), valAddr.String(), @@ -238,7 +238,7 @@ func (suite *KeeperTestSuite) TestBatchResetDelegation() { suite.Require().NoError(err) } else if amounts[i].LT(existingDelegation) { _, err := stakingMsgServer.Undelegate( - sdk.WrapSDKContext(cacheCtx2), + cacheCtx2, stakingtypes.NewMsgUndelegate( delAddr.String(), valAddr.String(), diff --git a/x/batch/wasm/interface_msg.go b/x/batch/wasm/interface_msg.go index a32c19d9..a91da048 100644 --- a/x/batch/wasm/interface_msg.go +++ b/x/batch/wasm/interface_msg.go @@ -12,7 +12,7 @@ import ( type BatchMsg struct { // Contracts can withdraw all rewards for the delegations from the contract. - WithdrawAllDelegatorRewards *WithdrawAllDelegatorRewards `json:"withdrawAllDelegatorRewards,omitempty"` + WithdrawAllDelegatorRewards *WithdrawAllDelegatorRewards `json:"withdraw_all_delegator_rewards,omitempty"` } type WithdrawAllDelegatorRewards struct{} diff --git a/x/cw-ica/keeper/ibc_handlers.go b/x/cw-ica/keeper/ibc_handlers.go index 2fe7adf4..1d218112 100644 --- a/x/cw-ica/keeper/ibc_handlers.go +++ b/x/cw-ica/keeper/ibc_handlers.go @@ -5,11 +5,11 @@ import ( "strings" "cosmossdk.io/errors" + "github.com/Team-Kujira/core/x/cw-ica/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" storetypes "cosmossdk.io/store/types" - "github.com/Team-Kujira/core/x/cw-ica/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ) @@ -64,6 +64,8 @@ func (k *Keeper) createCachedContext(ctx sdk.Context) (sdk.Context, func(), stor } gasMeter = storetypes.NewGasMeter(newLimit) + } else { + gasMeter = storetypes.NewInfiniteGasMeter() } cacheCtx = cacheCtx.WithGasMeter(gasMeter) @@ -102,7 +104,20 @@ func (k *Keeper) HandleAcknowledgement(ctx sdk.Context, packet channeltypes.Pack } if err != nil { - k.Logger(ctx).Debug("HandleAcknowledgement: failed to Sudo contract on packet acknowledgement", "error", err) + k.Logger(ctx).Debug( + "HandleAcknowledgement: failed to Sudo contract on packet acknowledgement", + "source_port", packet.SourcePort, + "source_channel", packet.SourceChannel, + "sequence", packet.Sequence, + "error", err) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeICATxCallbackFailure, + sdk.NewAttribute(types.AttributePacketSourcePort, packet.SourcePort), + sdk.NewAttribute(types.AttributePacketSourceChannel, packet.SourceChannel), + sdk.NewAttribute(types.AttributePacketSequence, fmt.Sprintf("%d", packet.Sequence)), + ), + }) } else { ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events()) writeFn() @@ -125,7 +140,20 @@ func (k *Keeper) HandleTimeout(ctx sdk.Context, packet channeltypes.Packet, _ sd Timeout: &types.IcaCallbackTimeout{}, }) if err != nil { - k.Logger(ctx).Error("HandleTimeout: failed to Sudo contract on packet timeout", "port", packet.SourcePort, "error", err) + k.Logger(ctx).Debug( + "HandleTimeout: failed to Sudo contract on packet timeout", + "source_port", packet.SourcePort, + "source_channel", packet.SourceChannel, + "sequence", packet.Sequence, + "error", err) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeICATimeoutCallbackFailure, + sdk.NewAttribute(types.AttributePacketSourcePort, packet.SourcePort), + sdk.NewAttribute(types.AttributePacketSourceChannel, packet.SourceChannel), + sdk.NewAttribute(types.AttributePacketSequence, fmt.Sprintf("%d", packet.Sequence)), + ), + }) } else { ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events()) writeFn() @@ -166,10 +194,23 @@ func (k *Keeper) HandleChanOpenAck( }, }) if err != nil { - k.Logger(ctx).Error("SudoCallback failure", "error", err) + k.Logger(ctx).Error( + "HandleChanOpenAck: failed to Sudo contract on packet ChanOpenAck", + "port", portID, + "channel", channelID, + "error", err) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeICARegisterCallbackFailure, + sdk.NewAttribute(types.AttributePacketSourcePort, portID), + sdk.NewAttribute(types.AttributePacketSourceChannel, channelID), + ), + }) } else { + ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events()) writeFn() } + ctx.GasMeter().ConsumeGas(newGasMeter.GasConsumed(), "consume from cached context") // remove the callback data k.RemoveCallbackData(ctx, callbackDataKey) diff --git a/x/cw-ica/keeper/sudo.go b/x/cw-ica/keeper/sudo.go index f9e10f76..9266e91c 100644 --- a/x/cw-ica/keeper/sudo.go +++ b/x/cw-ica/keeper/sudo.go @@ -7,7 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/Team-Kujira/core/x/cw-ica/types" - ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ) func (k Keeper) HasContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) bool { @@ -22,7 +23,7 @@ func (k Keeper) SudoIcaRegisterCallback( contractAddr := sdk.MustAccAddressFromBech32(callbackData.Contract) if !k.wasmKeeper.HasContractInfo(ctx, contractAddr) { - if callbackData.PortId == ibctransfertypes.PortID { + if callbackData.PortId == transfertypes.PortID { // we want to allow non contract account to send the assets via IBC Transfer module // we can determine the originating module by the source port of the request packet return nil, nil @@ -60,7 +61,7 @@ func (k Keeper) SudoIcaTxCallback( contractAddr := sdk.MustAccAddressFromBech32(callbackData.Contract) if !k.wasmKeeper.HasContractInfo(ctx, contractAddr) { - if callbackData.PortId == ibctransfertypes.PortID { + if callbackData.PortId == transfertypes.PortID { // we want to allow non contract account to send the assets via IBC Transfer module // we can determine the originating module by the source port of the request packet return nil, nil @@ -90,3 +91,93 @@ func (k Keeper) SudoIcaTxCallback( return resp, nil } + +func (k Keeper) SudoIbcTransferCallback( + ctx sdk.Context, + packet channeltypes.Packet, + data transfertypes.FungibleTokenPacketData, + callbackData types.CallbackData, + result types.IcaCallbackResult, +) error { + contractAddr, err := sdk.AccAddressFromBech32(data.Sender) + if err != nil { + return err + } + + if !k.wasmKeeper.HasContractInfo(ctx, contractAddr) { + return nil + } + + if callbackData.Callback == nil { + callbackData.Callback = []byte{} + } + + x := types.MessageTransferCallback{} + x.TransferCallback.Port = packet.SourcePort + x.TransferCallback.Channel = packet.SourceChannel + x.TransferCallback.Sequence = packet.Sequence + x.TransferCallback.Receiver = data.Receiver + x.TransferCallback.Denom = data.Denom + x.TransferCallback.Amount = data.Amount + x.TransferCallback.Memo = data.Memo + x.TransferCallback.Result = result + x.TransferCallback.Callback = callbackData.Callback + + m, err := json.Marshal(x) + if err != nil { + k.Logger(ctx).Error("SudoCallback: failed to marshal MessageResponse message", "error", err, "contractAddress", contractAddr) + return err + } + + _, err = k.wasmKeeper.Sudo(ctx, contractAddr, m) + if err != nil { + k.Logger(ctx).Debug("SudoResponse: failed to Sudo", "error", err, "contractAddress", contractAddr) + } + return err +} + +func (k Keeper) SudoIbcTransferReceipt( + ctx sdk.Context, + packet channeltypes.Packet, + data transfertypes.FungibleTokenPacketData, +) error { + contractAddr, err := sdk.AccAddressFromBech32(data.Receiver) + if err != nil { + return err + } + + if !k.wasmKeeper.HasContractInfo(ctx, contractAddr) { + return nil + } + + denom := "" + if transfertypes.ReceiverChainIsSource(packet.GetSourcePort(), packet.GetSourceChannel(), data.Denom) { + voucherPrefix := transfertypes.GetDenomPrefix(packet.GetSourcePort(), packet.GetSourceChannel()) + denom = data.Denom[len(voucherPrefix):] + } else { + sourcePrefix := transfertypes.GetDenomPrefix(packet.GetDestPort(), packet.GetDestChannel()) + prefixedDenom := sourcePrefix + data.Denom + denom = transfertypes.ParseDenomTrace(prefixedDenom).IBCDenom() + } + + x := types.MessageTransferReceipt{} + x.TransferReceipt.Port = packet.DestinationPort + x.TransferReceipt.Channel = packet.DestinationChannel + x.TransferReceipt.Sequence = packet.Sequence + x.TransferReceipt.Sender = data.Sender + x.TransferReceipt.Denom = denom + x.TransferReceipt.Amount = data.Amount + x.TransferReceipt.Memo = data.Memo + + m, err := json.Marshal(x) + if err != nil { + k.Logger(ctx).Error("SudoCallback: failed to marshal MessageResponse message", "error", err, "contractAddress", contractAddr) + return err + } + + _, err = k.wasmKeeper.Sudo(ctx, contractAddr, m) + if err != nil { + k.Logger(ctx).Debug("SudoResponse: failed to Sudo", "error", err, "contractAddress", contractAddr) + } + return err +} diff --git a/x/cw-ica/keeper/transfer_handlers.go b/x/cw-ica/keeper/transfer_handlers.go new file mode 100644 index 00000000..6f6ed8c4 --- /dev/null +++ b/x/cw-ica/keeper/transfer_handlers.go @@ -0,0 +1,155 @@ +package keeper + +import ( + "fmt" + + "github.com/Team-Kujira/core/x/cw-ica/types" + sdk "github.com/cosmos/cosmos-sdk/types" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" +) + +// HandleAcknowledgement passes the acknowledgement data to the appropriate contract via a Sudo call. +func (k *Keeper) HandleTransferAcknowledgement(ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, _ sdk.AccAddress) { + k.Logger(ctx).Debug("Handling transfer acknowledgement") + var data transfertypes.FungibleTokenPacketData + if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err != nil { + return + } + + var ack channeltypes.Acknowledgement + if err := channeltypes.SubModuleCdc.UnmarshalJSON(acknowledgement, &ack); err != nil { + k.Logger(ctx).Error("HandleTransferAcknowledgement: cannot unmarshal IBC transfer packet acknowledgement", "error", err) + return + } + + cacheCtx, writeFn, newGasMeter := k.createCachedContext(ctx) + defer k.outOfGasRecovery(ctx, newGasMeter) + + callbackDataKey := types.PacketID(packet.GetSourcePort(), packet.GetSourceChannel(), packet.Sequence) + callbackData, found := k.GetCallbackData(ctx, callbackDataKey) + + // Actually we have only one kind of error returned from acknowledgement + // maybe later we'll retrieve actual errors from events + errorText := ack.GetError() + var err error + if errorText != "" { + err = k.SudoIbcTransferCallback(cacheCtx, packet, data, callbackData, types.IcaCallbackResult{ + Error: &types.IcaCallbackError{ + Error: errorText, + }, + }) + } else { + err = k.SudoIbcTransferCallback(cacheCtx, packet, data, callbackData, types.IcaCallbackResult{ + Success: &types.IcaCallbackSuccess{ + Data: ack.GetResult(), + }, + }) + } + + if err != nil { + k.Logger(ctx).Debug( + "HandleTransferAcknowledgement: failed to Sudo contract on transfer packet acknowledgement", + "source_port", packet.SourcePort, + "source_channel", packet.SourceChannel, + "sequence", packet.Sequence, + "error", err) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeICATxCallbackFailure, + sdk.NewAttribute(types.AttributePacketSourcePort, packet.SourcePort), + sdk.NewAttribute(types.AttributePacketSourceChannel, packet.SourceChannel), + sdk.NewAttribute(types.AttributePacketSequence, fmt.Sprintf("%d", packet.Sequence)), + ), + }) + } else { + ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events()) + writeFn() + } + + ctx.GasMeter().ConsumeGas(newGasMeter.GasConsumed(), "consume from cached context") + + // remove the callback data + if found { + k.RemoveCallbackData(ctx, callbackDataKey) + } +} + +func (k *Keeper) HandleTransferTimeout(ctx sdk.Context, packet channeltypes.Packet, _ sdk.AccAddress) { + k.Logger(ctx).Debug("Transfer HandleTimeout") + + var data transfertypes.FungibleTokenPacketData + if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err != nil { + return + } + + cacheCtx, writeFn, newGasMeter := k.createCachedContext(ctx) + defer k.outOfGasRecovery(ctx, newGasMeter) + + callbackDataKey := types.PacketID(packet.GetSourcePort(), packet.GetSourceChannel(), packet.Sequence) + callbackData, found := k.GetCallbackData(ctx, callbackDataKey) + err := k.SudoIbcTransferCallback(ctx, packet, data, callbackData, types.IcaCallbackResult{ + Timeout: &types.IcaCallbackTimeout{}, + }) + if err != nil { + k.Logger(ctx).Debug( + "HandleTransferTimeout: failed to Sudo contract on transfer packet timeout", + "source_port", packet.SourcePort, + "source_channel", packet.SourceChannel, + "sequence", packet.Sequence, + "error", err) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeICATimeoutCallbackFailure, + sdk.NewAttribute(types.AttributePacketSourcePort, packet.SourcePort), + sdk.NewAttribute(types.AttributePacketSourceChannel, packet.SourceChannel), + sdk.NewAttribute(types.AttributePacketSequence, fmt.Sprintf("%d", packet.Sequence)), + ), + }) + } else { + ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events()) + writeFn() + } + + ctx.GasMeter().ConsumeGas(newGasMeter.GasConsumed(), "consume from cached context") + + // remove the callback data + if found { + k.RemoveCallbackData(ctx, callbackDataKey) + } +} + +func (k *Keeper) HandleTransferReceipt(ctx sdk.Context, packet channeltypes.Packet, _ sdk.AccAddress) { + k.Logger(ctx).Debug("Transfer Receipt") + + var data transfertypes.FungibleTokenPacketData + if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err != nil { + return + } + + cacheCtx, writeFn, newGasMeter := k.createCachedContext(ctx) + defer k.outOfGasRecovery(ctx, newGasMeter) + + err := k.SudoIbcTransferReceipt(ctx, packet, data) + if err != nil { + k.Logger(ctx).Debug( + "HandleTransferReceipt: failed to Sudo contract on transfer receipt", + "destination_port", packet.DestinationPort, + "destination_channel", packet.DestinationChannel, + "sequence", packet.Sequence, + "error", err) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeICATimeoutCallbackFailure, + sdk.NewAttribute(types.AttributePacketSourcePort, packet.SourcePort), + sdk.NewAttribute(types.AttributePacketSourceChannel, packet.SourceChannel), + sdk.NewAttribute(types.AttributePacketSequence, fmt.Sprintf("%d", packet.Sequence)), + ), + }) + } else { + ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events()) + writeFn() + } + + ctx.GasMeter().ConsumeGas(newGasMeter.GasConsumed(), "consume from cached context") +} diff --git a/x/cw-ica/transfer_middleware.go b/x/cw-ica/transfer_middleware.go new file mode 100644 index 00000000..71fe3502 --- /dev/null +++ b/x/cw-ica/transfer_middleware.go @@ -0,0 +1,159 @@ +package cwica + +import ( + "github.com/Team-Kujira/core/x/cw-ica/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" +) + +var _ porttypes.Middleware = &IBCMiddleware{} + +type IBCMiddleware struct { + App porttypes.IBCModule + keeper keeper.Keeper + ICS4Middleware porttypes.ICS4Wrapper +} + +func NewIBCMiddleware(app porttypes.IBCModule, keeper keeper.Keeper, ics4 porttypes.ICS4Wrapper) IBCMiddleware { + return IBCMiddleware{ + App: app, + keeper: keeper, + ICS4Middleware: ics4, + } +} + +// OnChanOpenInit implements the IBCMiddleware interface +func (im IBCMiddleware) OnChanOpenInit( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID string, + channelID string, + channelCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version string, +) (string, error) { + return im.App.OnChanOpenInit(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, version) +} + +// OnChanOpenTry implements the IBCMiddleware interface +func (im IBCMiddleware) OnChanOpenTry( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID, + channelID string, + channelCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + counterpartyVersion string, +) (string, error) { + return im.App.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, counterpartyVersion) +} + +// OnChanOpenAck implements the IBCMiddleware interface +func (im IBCMiddleware) OnChanOpenAck( + ctx sdk.Context, + portID, + channelID string, + counterpartyChannelID string, + counterpartyVersion string, +) error { + return im.App.OnChanOpenAck(ctx, portID, channelID, counterpartyChannelID, counterpartyVersion) +} + +// OnChanOpenConfirm implements the IBCMiddleware interface +func (im IBCMiddleware) OnChanOpenConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return im.App.OnChanOpenConfirm(ctx, portID, channelID) +} + +// OnChanCloseInit implements the IBCMiddleware interface +func (im IBCMiddleware) OnChanCloseInit( + ctx sdk.Context, + portID, + channelID string, +) error { + return im.App.OnChanCloseInit(ctx, portID, channelID) +} + +// OnChanCloseConfirm implements the IBCMiddleware interface +func (im IBCMiddleware) OnChanCloseConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return im.App.OnChanCloseConfirm(ctx, portID, channelID) +} + +// OnRecvPacket implements the IBCMiddleware interface +func (im IBCMiddleware) OnRecvPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) ibcexported.Acknowledgement { + ack := im.App.OnRecvPacket(ctx, packet, relayer) + im.keeper.HandleTransferReceipt(ctx, packet, relayer) + return ack +} + +// OnAcknowledgementPacket implements the IBCMiddleware interface +func (im IBCMiddleware) OnAcknowledgementPacket( + ctx sdk.Context, + packet channeltypes.Packet, + acknowledgement []byte, + relayer sdk.AccAddress, +) error { + err := im.App.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) + if err != nil { + return err + } + im.keeper.HandleTransferAcknowledgement(ctx, packet, acknowledgement, relayer) + return nil +} + +// OnTimeoutPacket implements the IBCMiddleware interface +func (im IBCMiddleware) OnTimeoutPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) error { + err := im.App.OnTimeoutPacket(ctx, packet, relayer) + if err != nil { + return err + } + im.keeper.HandleTransferTimeout(ctx, packet, relayer) + return nil +} + +// SendPacket implements the ICS4 Wrapper interface +func (im IBCMiddleware) SendPacket( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + sourcePort string, sourceChannel string, + timeoutHeight clienttypes.Height, + timeoutTimestamp uint64, + data []byte, +) (sequence uint64, err error) { + return im.ICS4Middleware.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) +} + +// WriteAcknowledgement implements the ICS4 Wrapper interface +func (im IBCMiddleware) WriteAcknowledgement( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + packet ibcexported.PacketI, + ack ibcexported.Acknowledgement, +) error { + return im.ICS4Middleware.WriteAcknowledgement(ctx, chanCap, packet, ack) +} + +func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) { + return im.ICS4Middleware.GetAppVersion(ctx, portID, channelID) +} diff --git a/x/cw-ica/types/events.go b/x/cw-ica/types/events.go new file mode 100644 index 00000000..246fb871 --- /dev/null +++ b/x/cw-ica/types/events.go @@ -0,0 +1,14 @@ +package types + +const ( + EventTypeICATxCallbackFailure = "ica_tx_callback_failure" + EventTypeICARegisterCallbackFailure = "ica_register_callback_failure" + EventTypeICATimeoutCallbackFailure = "ica_timeout_callback_failure" +) + +// event attributes returned +const ( + AttributePacketSourcePort = "source_port" + AttributePacketSourceChannel = "source_channel" + AttributePacketSequence = "sequence" +) diff --git a/x/cw-ica/types/sudo.go b/x/cw-ica/types/sudo.go index f3b06bef..41bf158d 100644 --- a/x/cw-ica/types/sudo.go +++ b/x/cw-ica/types/sudo.go @@ -38,3 +38,33 @@ type IcaCallbackError struct { } type IcaCallbackTimeout struct{} + +type MessageTransferCallback struct { + TransferCallback TransferCallbackData `json:"transfer_callback"` +} + +type TransferCallbackData struct { + Port string `json:"port"` + Channel string `json:"channel"` + Sequence uint64 `json:"sequence"` + Receiver string `json:"receiver"` + Denom string `json:"denom"` + Amount string `json:"amount"` + Memo string `json:"memo"` + Result IcaCallbackResult `json:"result"` + Callback []byte `json:"callback"` +} + +type MessageTransferReceipt struct { + TransferReceipt TransferReceiptData `json:"transfer_receipt"` +} + +type TransferReceiptData struct { + Port string `json:"port"` + Channel string `json:"channel"` + Sequence uint64 `json:"sequence"` + Sender string `json:"sender"` + Denom string `json:"denom"` + Amount string `json:"amount"` + Memo string `json:"memo"` +} diff --git a/x/cw-ica/wasm/interface_msg.go b/x/cw-ica/wasm/interface_msg.go index b5b7e5ba..454351cf 100644 --- a/x/cw-ica/wasm/interface_msg.go +++ b/x/cw-ica/wasm/interface_msg.go @@ -11,8 +11,11 @@ import ( icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" cwicakeeper "github.com/Team-Kujira/core/x/cw-ica/keeper" "github.com/Team-Kujira/core/x/cw-ica/types" + ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ) // ProtobufAny is a hack-struct to serialize protobuf Any message into JSON object @@ -28,6 +31,9 @@ type CwIcaMsg struct { /// Contracts can submit transactions to the ICA /// associated with the given information. Submit *Submit `json:"submit,omitempty"` + /// Transfer submits ibc-transfer msg with + /// optional callback field + Transfer *Transfer `json:"transfer,omitempty"` } // / Register creates a new interchain account. @@ -55,6 +61,15 @@ type Submit struct { Callback []byte `json:"callback"` } +type Transfer struct { + ChannelID string `json:"channel_id"` + ToAddress string `json:"to_address"` + Amount wasmvmtypes.Coin `json:"amount"` + Timeout wasmvmtypes.IBCTimeout `json:"timeout"` + Callback []byte `json:"callback"` + Memo string `json:"memo"` +} + func register( ctx sdk.Context, contractAddr sdk.AccAddress, @@ -197,10 +212,57 @@ func PerformSubmitTxs( return res, nil } +func transfer(ctx sdk.Context, contractAddr sdk.AccAddress, transferTx *Transfer, cwicak cwicakeeper.Keeper, tk ibctransferkeeper.Keeper) (*ibctransfertypes.MsgTransferResponse, error) { + res, err := PerformTransfer(tk, cwicak, ctx, contractAddr, transferTx) + if err != nil { + return nil, errors.Wrap(err, "perform submit txs") + } + return res, nil +} + +// PerformTransfer is used to perform ibc transfer through wasmbinding. +func PerformTransfer(f ibctransferkeeper.Keeper, cwicak cwicakeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, transferTx *Transfer) (*ibctransfertypes.MsgTransferResponse, error) { + if transferTx == nil { + return nil, wasmvmtypes.InvalidRequest{Err: "transfer txs null message"} + } + + amount, err := wasmkeeper.ConvertWasmCoinToSdkCoin(transferTx.Amount) + if err != nil { + return nil, errors.Wrap(err, "amount") + } + msg := &ibctransfertypes.MsgTransfer{ + SourcePort: ibctransfertypes.PortID, + SourceChannel: transferTx.ChannelID, + Token: amount, + Sender: contractAddr.String(), + Receiver: transferTx.ToAddress, + TimeoutHeight: wasmkeeper.ConvertWasmIBCTimeoutHeightToCosmosHeight(transferTx.Timeout.Block), + TimeoutTimestamp: transferTx.Timeout.Timestamp, + Memo: transferTx.Memo, + } + + res, err := f.Transfer(ctx, msg) + if err != nil { + return nil, errors.Wrap(err, "submitting transfer tx") + } + + cwicak.SetCallbackData(ctx, types.CallbackData{ + PortId: msg.SourcePort, + ChannelId: msg.SourceChannel, + Sequence: res.Sequence, + Contract: contractAddr.String(), + ConnectionId: "", + AccountId: "", + Callback: transferTx.Callback, + }) + return res, nil +} + func HandleMsg( ctx sdk.Context, cwicak cwicakeeper.Keeper, icak icacontrollerkeeper.Keeper, + transferk ibctransferkeeper.Keeper, contractAddr sdk.AccAddress, msg *CwIcaMsg, ) ([]sdk.Event, [][]byte, [][]*codectypes.Any, error) { @@ -215,6 +277,10 @@ func HandleMsg( res, err = submit(ctx, contractAddr, msg.Submit, cwicak, icak) } + if msg.Transfer != nil { + res, err = transfer(ctx, contractAddr, msg.Transfer, cwicak, transferk) + } + if err != nil { return nil, nil, nil, err } diff --git a/x/denom/client/cli/query.go b/x/denom/client/cli/query.go index 59f4b33e..cbf9c233 100644 --- a/x/denom/client/cli/query.go +++ b/x/denom/client/cli/query.go @@ -31,6 +31,7 @@ func GetQueryCmd() *cobra.Command { GetParams(), GetCmdDenomAuthorityMetadata(), GetCmdDenomsFromCreator(), + GetCmdNoFeeAccounts(), ) return cmd @@ -120,3 +121,30 @@ func GetCmdDenomsFromCreator() *cobra.Command { return cmd } + +// GetCmdNoFeeAccounts a command to get a list of no fee accounts +func GetCmdNoFeeAccounts() *cobra.Command { + cmd := &cobra.Command{ + Use: "no-fee-accounts [flags]", + Short: "Returns a list of no fee accounts", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.NoFeeAccounts(cmd.Context(), &types.QueryNoFeeAccountsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/denom/genesis.go b/x/denom/genesis.go index 5be885cb..a113fdea 100644 --- a/x/denom/genesis.go +++ b/x/denom/genesis.go @@ -34,6 +34,10 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) panic(err) } } + + for _, addr := range genState.NoFeeAccounts { + k.SetNoFeeAccount(ctx, addr) + } } // ExportGenesis returns the denom module's exported genesis. @@ -58,5 +62,6 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { return &types.GenesisState{ FactoryDenoms: genDenoms, Params: k.GetParams(ctx), + NoFeeAccounts: k.GetNoFeeAccounts(ctx), } } diff --git a/x/denom/keeper/createdenom.go b/x/denom/keeper/createdenom.go index 1404dc79..705d56b1 100644 --- a/x/denom/keeper/createdenom.go +++ b/x/denom/keeper/createdenom.go @@ -7,10 +7,18 @@ import ( "github.com/Team-Kujira/core/x/denom/types" ) +func (k Keeper) GetCreationFee(ctx sdk.Context, creatorAddr string) sdk.Coins { + if k.IsNoFeeAccount(ctx, creatorAddr) { + return sdk.Coins{} + } + params := k.GetParams(ctx) + return params.CreationFee +} + // ConvertToBaseToken converts a fee amount in a whitelisted fee token to the base fee token amount func (k Keeper) CreateDenom(ctx sdk.Context, creatorAddr string, denomNonce string) (newTokenDenom string, err error) { // Send creation fee to community pool - creationFee := k.GetParams(ctx).CreationFee + creationFee := k.GetCreationFee(ctx, creatorAddr) accAddr, err := sdk.AccAddressFromBech32(creatorAddr) if err != nil { return "", err diff --git a/x/denom/keeper/grpc_query.go b/x/denom/keeper/grpc_query.go index 419ef75f..c227d7e3 100644 --- a/x/denom/keeper/grpc_query.go +++ b/x/denom/keeper/grpc_query.go @@ -33,3 +33,10 @@ func (k Keeper) DenomsFromCreator(ctx context.Context, req *types.QueryDenomsFro denoms := k.getDenomsFromCreator(sdkCtx, req.GetCreator()) return &types.QueryDenomsFromCreatorResponse{Denoms: denoms}, nil } + +func (k Keeper) NoFeeAccounts(ctx context.Context, _ *types.QueryNoFeeAccountsRequest) (*types.QueryNoFeeAccountsResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + return &types.QueryNoFeeAccountsResponse{ + Accounts: k.GetNoFeeAccounts(sdkCtx), + }, nil +} diff --git a/x/denom/keeper/keeper.go b/x/denom/keeper/keeper.go index 79397c5a..c4057cef 100644 --- a/x/denom/keeper/keeper.go +++ b/x/denom/keeper/keeper.go @@ -19,9 +19,8 @@ import ( type ( Keeper struct { - cdc codec.Codec - storeKey storetypes.StoreKey - + cdc codec.Codec + storeKey storetypes.StoreKey paramSpace paramstypes.Subspace accountKeeper types.AccountKeeper diff --git a/x/denom/keeper/keeper_test.go b/x/denom/keeper/keeper_test.go index d12af92d..2a360f4c 100644 --- a/x/denom/keeper/keeper_test.go +++ b/x/denom/keeper/keeper_test.go @@ -1,34 +1,27 @@ package keeper_test -// import ( -// "testing" +import ( + "testing" -// "github.com/Team-Kujira/core/x/denom/types" + app "github.com/Team-Kujira/core/app" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" +) -// sdk "github.com/cosmos/cosmos-sdk/types" -// "github.com/stretchr/testify/suite" -// ) +type KeeperTestSuite struct { + suite.Suite -// type KeeperTestSuite struct { -// apptesting.KeeperTestHelper + App *app.App + Ctx sdk.Context +} -// queryClient types.QueryClient -// } +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} -// func TestKeeperTestSuite(t *testing.T) { -// suite.Run(t, new(KeeperTestSuite)) -// } +func (suite *KeeperTestSuite) SetupTest() { + app := app.Setup(suite.T(), false) -// func (suite *KeeperTestSuite) SetupTest() { -// suite.Setup() - -// // Fund every TestAcc with 100 denom creation fees. -// fundAccsAmount := sdk.NewCoins(sdk.NewCoin(types.DefaultParams().CreationFee[0].Denom, types.DefaultParams().CreationFee[0].Amount.MulRaw(100))) -// for _, acc := range suite.TestAccs { -// suite.FundAcc(acc, fundAccsAmount) -// } - -// suite.Setupdenom() - -// suite.queryClient = types.NewQueryClient(suite.QueryHelper) -// } + suite.Ctx = app.BaseApp.NewContext(false) + suite.App = app +} diff --git a/x/denom/keeper/msg_server.go b/x/denom/keeper/msg_server.go index d8273090..58f55296 100644 --- a/x/denom/keeper/msg_server.go +++ b/x/denom/keeper/msg_server.go @@ -22,6 +22,52 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { var _ types.MsgServer = msgServer{} +func (server msgServer) AddNoFeeAccounts(goCtx context.Context, msg *types.MsgAddNoFeeAccounts) (*types.MsgAddNoFeeAccountsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if msg.Authority != server.authority { + return nil, types.ErrInvalidAuthority + } + + for _, address := range msg.Accounts { + if server.IsNoFeeAccount(ctx, address) { + continue + } + server.SetNoFeeAccount(ctx, address) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.TypeMsgAddNoFeeAccounts, + sdk.NewAttribute(types.AttributeAddress, address), + ), + }) + } + + return &types.MsgAddNoFeeAccountsResponse{}, nil +} + +func (server msgServer) RemoveNoFeeAccounts(goCtx context.Context, msg *types.MsgRemoveNoFeeAccounts) (*types.MsgRemoveNoFeeAccountsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if msg.Authority != server.authority { + return nil, types.ErrInvalidAuthority + } + + for _, address := range msg.Accounts { + if !server.IsNoFeeAccount(ctx, address) { + continue + } + server.RemoveNoFeeAccount(ctx, address) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.TypeMsgRemoveNoFeeAccounts, + sdk.NewAttribute(types.AttributeAddress, address), + ), + }) + } + + return &types.MsgRemoveNoFeeAccountsResponse{}, nil +} + func (server msgServer) CreateDenom(goCtx context.Context, msg *types.MsgCreateDenom) (*types.MsgCreateDenomResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/denom/keeper/msg_server_test.go b/x/denom/keeper/msg_server_test.go new file mode 100644 index 00000000..67db6c56 --- /dev/null +++ b/x/denom/keeper/msg_server_test.go @@ -0,0 +1,84 @@ +package keeper_test + +import ( + "github.com/Team-Kujira/core/x/denom/keeper" + "github.com/Team-Kujira/core/x/denom/types" + "github.com/cometbft/cometbft/crypto/ed25519" + sdk "github.com/cosmos/cosmos-sdk/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +func (suite *KeeperTestSuite) TestMsgServerCreateDenom() { + for _, tc := range []struct { + desc string + balance sdk.Coins + whitelisted bool + balanceAfter sdk.Coins + expPass bool + }{ + { + desc: "successful denom creation: positive fee payment", + balance: sdk.Coins{sdk.NewInt64Coin("ukuji", 10_000_000)}, + whitelisted: false, + balanceAfter: sdk.Coins{}, + expPass: true, + }, + { + desc: "insufficient balance for fee payment", + balance: sdk.Coins{}, + whitelisted: false, + balanceAfter: sdk.Coins{}, + expPass: false, + }, + { + desc: "successful denom creation: whitelisted address", + balance: sdk.Coins{}, + whitelisted: true, + balanceAfter: sdk.Coins{}, + expPass: true, + }, + } { + suite.Run(tc.desc, func() { + suite.SetupTest() + + // bootstrap accounts + sender := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + + if tc.whitelisted { + suite.App.DenomKeeper.SetNoFeeAccount(suite.Ctx, sender.String()) + } + + if tc.balance.IsAllPositive() { + err := suite.App.BankKeeper.MintCoins(suite.Ctx, minttypes.ModuleName, tc.balance) + suite.Require().NoError(err) + err = suite.App.BankKeeper.SendCoinsFromModuleToAccount(suite.Ctx, minttypes.ModuleName, sender, tc.balance) + suite.Require().NoError(err) + } + + msgServer := keeper.NewMsgServerImpl(*suite.App.DenomKeeper) + resp, err := msgServer.CreateDenom( + suite.Ctx, + &types.MsgCreateDenom{ + Sender: sender.String(), + Nonce: "1", + }, + ) + if !tc.expPass { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + denom, err := types.GetTokenDenom(sender.String(), "1") + suite.Require().NoError(err) + suite.Require().Equal(resp.NewTokenDenom, denom) + + // check balance after + balances := suite.App.BankKeeper.GetAllBalances(suite.Ctx, sender) + suite.Require().Equal(balances.String(), tc.balanceAfter.String()) + + metadata, err := suite.App.DenomKeeper.GetAuthorityMetadata(suite.Ctx, denom) + suite.Require().NoError(err) + suite.Require().Equal(metadata.Admin, sender.String()) + } + }) + } +} diff --git a/x/denom/keeper/no_fee_accounts.go b/x/denom/keeper/no_fee_accounts.go new file mode 100644 index 00000000..0b814b9e --- /dev/null +++ b/x/denom/keeper/no_fee_accounts.go @@ -0,0 +1,44 @@ +package keeper + +import ( + "cosmossdk.io/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + + storetypes "cosmossdk.io/store/types" + "github.com/Team-Kujira/core/x/denom/types" +) + +// IsNoFeeAccount returns if an address is no fee account +func (k Keeper) IsNoFeeAccount(ctx sdk.Context, address string) bool { + store := ctx.KVStore(k.storeKey) + prefixStore := prefix.NewStore(store, types.GetNoFeeAccountPrefix()) + bz := prefixStore.Get([]byte(address)) + return bz != nil +} + +// SetNoFeeAccount sets an address as no fee account +func (k Keeper) SetNoFeeAccount(ctx sdk.Context, address string) { + store := ctx.KVStore(k.storeKey) + prefixStore := prefix.NewStore(store, types.GetNoFeeAccountPrefix()) + prefixStore.Set([]byte(address), []byte(address)) +} + +// RemoveNoFeeAccount removes an address from no fee account list +func (k Keeper) RemoveNoFeeAccount(ctx sdk.Context, address string) { + store := ctx.KVStore(k.storeKey) + prefixStore := prefix.NewStore(store, types.GetNoFeeAccountPrefix()) + prefixStore.Delete([]byte(address)) +} + +// GetNoFeeAccounts returns all no fee accounts +func (k Keeper) GetNoFeeAccounts(ctx sdk.Context) []string { + store := ctx.KVStore(k.storeKey) + iterator := storetypes.KVStorePrefixIterator(store, types.GetNoFeeAccountPrefix()) + defer iterator.Close() + + accounts := []string{} + for ; iterator.Valid(); iterator.Next() { + accounts = append(accounts, string(iterator.Value())) + } + return accounts +} diff --git a/x/denom/keeper/no_fee_accounts_test.go b/x/denom/keeper/no_fee_accounts_test.go new file mode 100644 index 00000000..01ddc6ba --- /dev/null +++ b/x/denom/keeper/no_fee_accounts_test.go @@ -0,0 +1,31 @@ +package keeper_test + +import ( + "github.com/cometbft/cometbft/crypto/ed25519" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (suite *KeeperTestSuite) TestNoFeeAccounts() { + // Set accounts + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + addr2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + addr3 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + suite.App.DenomKeeper.SetNoFeeAccount(suite.Ctx, addr1.String()) + suite.App.DenomKeeper.SetNoFeeAccount(suite.Ctx, addr2.String()) + + // Check queries + suite.Require().True(suite.App.DenomKeeper.IsNoFeeAccount(suite.Ctx, addr1.String())) + suite.Require().True(suite.App.DenomKeeper.IsNoFeeAccount(suite.Ctx, addr2.String())) + suite.Require().False(suite.App.DenomKeeper.IsNoFeeAccount(suite.Ctx, addr3.String())) + suite.Require().Len(suite.App.DenomKeeper.GetNoFeeAccounts(suite.Ctx), 2) + + // Remove accounts + suite.App.DenomKeeper.RemoveNoFeeAccount(suite.Ctx, addr2.String()) + suite.App.DenomKeeper.RemoveNoFeeAccount(suite.Ctx, addr3.String()) + + // Check queries + suite.Require().True(suite.App.DenomKeeper.IsNoFeeAccount(suite.Ctx, addr1.String())) + suite.Require().False(suite.App.DenomKeeper.IsNoFeeAccount(suite.Ctx, addr2.String())) + suite.Require().False(suite.App.DenomKeeper.IsNoFeeAccount(suite.Ctx, addr3.String())) + suite.Require().Len(suite.App.DenomKeeper.GetNoFeeAccounts(suite.Ctx), 1) +} diff --git a/x/denom/types/codec.go b/x/denom/types/codec.go index 9bb3de3b..03bb6493 100644 --- a/x/denom/types/codec.go +++ b/x/denom/types/codec.go @@ -14,6 +14,8 @@ func RegisterCodec(cdc *codec.LegacyAmino) { // cdc.RegisterConcrete(&MsgForceTransfer{}, "github.com/Team-Kujira/core/denom/force-transfer", nil) cdc.RegisterConcrete(&MsgChangeAdmin{}, "github.com/Team-Kujira/core/denom/change-admin", nil) cdc.RegisterConcrete(&MsgUpdateParams{}, "github.com/Team-Kujira/core/denom/update-params", nil) + cdc.RegisterConcrete(&MsgAddNoFeeAccounts{}, "github.com/Team-Kujira/core/denom/add-no-fee-accounts", nil) + cdc.RegisterConcrete(&MsgRemoveNoFeeAccounts{}, "github.com/Team-Kujira/core/denom/remove-no-fee-accounts", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -25,6 +27,8 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { // &MsgForceTransfer{}, &MsgChangeAdmin{}, &MsgUpdateParams{}, + &MsgAddNoFeeAccounts{}, + &MsgRemoveNoFeeAccounts{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/denom/types/errors.go b/x/denom/types/errors.go index 18976926..d09c390c 100644 --- a/x/denom/types/errors.go +++ b/x/denom/types/errors.go @@ -14,4 +14,5 @@ var ( ErrInvalidCreator = errors.Register(ModuleName, 5, "invalid creator") ErrInvalidAuthorityMetadata = errors.Register(ModuleName, 6, "invalid authority metadata") ErrInvalidGenesis = errors.Register(ModuleName, 7, "invalid genesis") + ErrInvalidAuthority = errors.Register(ModuleName, 8, "not a governance address") ) diff --git a/x/denom/types/events.go b/x/denom/types/events.go index 9ccd13da..9d3d4d37 100644 --- a/x/denom/types/events.go +++ b/x/denom/types/events.go @@ -14,4 +14,5 @@ const ( AttributeTransferToAddress = "transfer_to_address" AttributeDenom = "denom" AttributeNewAdmin = "new_admin" + AttributeAddress = "address" ) diff --git a/x/denom/types/genesis.pb.go b/x/denom/types/genesis.pb.go index c6719f18..a0b767b0 100644 --- a/x/denom/types/genesis.pb.go +++ b/x/denom/types/genesis.pb.go @@ -28,6 +28,8 @@ type GenesisState struct { // params defines the paramaters of the module. Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` FactoryDenoms []GenesisDenom `protobuf:"bytes,2,rep,name=factory_denoms,json=factoryDenoms,proto3" json:"factory_denoms" yaml:"factory_denoms"` + // whitelisted accounts that do not require paying creation fees + NoFeeAccounts []string `protobuf:"bytes,3,rep,name=no_fee_accounts,json=noFeeAccounts,proto3" json:"no_fee_accounts,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -77,6 +79,13 @@ func (m *GenesisState) GetFactoryDenoms() []GenesisDenom { return nil } +func (m *GenesisState) GetNoFeeAccounts() []string { + if m != nil { + return m.NoFeeAccounts + } + return nil +} + type GenesisDenom struct { Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` AuthorityMetadata DenomAuthorityMetadata `protobuf:"bytes,2,opt,name=authority_metadata,json=authorityMetadata,proto3" json:"authority_metadata" yaml:"authority_metadata"` @@ -137,29 +146,31 @@ func init() { func init() { proto.RegisterFile("kujira/denom/genesis.proto", fileDescriptor_a1b1d94429cdf595) } var fileDescriptor_a1b1d94429cdf595 = []byte{ - // 344 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xca, 0x2e, 0xcd, 0xca, - 0x2c, 0x4a, 0xd4, 0x4f, 0x49, 0xcd, 0xcb, 0xcf, 0xd5, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, - 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x81, 0xc8, 0xe9, 0x81, 0xe5, 0xa4, 0x44, 0xd2, - 0xf3, 0xd3, 0xf3, 0xc1, 0x12, 0xfa, 0x20, 0x16, 0x44, 0x8d, 0x94, 0x0a, 0x8a, 0xfe, 0xc4, 0xd2, - 0x92, 0x8c, 0xfc, 0xa2, 0xcc, 0x92, 0x4a, 0xdf, 0xd4, 0x92, 0xc4, 0x94, 0xc4, 0x92, 0x44, 0xa8, - 0x2a, 0x49, 0x14, 0x55, 0x05, 0x89, 0x45, 0x89, 0xb9, 0x50, 0x4b, 0x94, 0x96, 0x30, 0x72, 0xf1, - 0xb8, 0x43, 0xac, 0x0d, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0x32, 0xe2, 0x62, 0x83, 0x28, 0x90, 0x60, - 0x54, 0x60, 0xd4, 0xe0, 0x36, 0x12, 0xd1, 0x43, 0x76, 0x86, 0x5e, 0x00, 0x58, 0xce, 0x89, 0xe5, - 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x4a, 0xa1, 0x04, 0x2e, 0xbe, 0xb4, 0xc4, 0xe4, 0x92, 0xfc, - 0xa2, 0xca, 0x78, 0xb0, 0xaa, 0x62, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x29, 0x54, 0xbd, - 0x50, 0x7b, 0x5c, 0x40, 0x1c, 0x27, 0x59, 0x90, 0x09, 0x9f, 0xee, 0xc9, 0x8b, 0x56, 0x26, 0xe6, - 0xe6, 0x58, 0x29, 0xa1, 0xea, 0x57, 0x0a, 0xe2, 0x85, 0x0a, 0xb8, 0x40, 0xf8, 0x5b, 0x10, 0xce, - 0x04, 0x8b, 0x08, 0xa9, 0x71, 0xb1, 0x82, 0x95, 0x82, 0x5d, 0xc9, 0xe9, 0x24, 0xf0, 0xe9, 0x9e, - 0x3c, 0x0f, 0xc4, 0x24, 0xb0, 0xb0, 0x52, 0x10, 0x44, 0x5a, 0xa8, 0x8c, 0x4b, 0x08, 0x1e, 0x2a, - 0xf1, 0xb9, 0xd0, 0x60, 0x91, 0x60, 0x02, 0x7b, 0x4d, 0x05, 0xd5, 0x79, 0x60, 0x83, 0x1d, 0xd1, - 0x83, 0xd0, 0x49, 0x11, 0xea, 0x50, 0x49, 0x88, 0xf1, 0x98, 0xa6, 0x29, 0x05, 0x09, 0x62, 0x04, - 0xbc, 0x15, 0xcb, 0x8b, 0x05, 0xf2, 0x8c, 0x4e, 0xce, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, - 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, - 0x2c, 0xc7, 0x10, 0xa5, 0x99, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x1f, - 0x92, 0x9a, 0x98, 0xab, 0xeb, 0x0d, 0x89, 0xa2, 0xe4, 0xfc, 0xa2, 0x54, 0xfd, 0x0a, 0x68, 0x4c, - 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x63, 0xca, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, - 0x52, 0x75, 0xe4, 0xb7, 0x2c, 0x02, 0x00, 0x00, + // 380 bytes of a gzipped FileDescriptor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e8, 0xc1, 0x47, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xc3, 0x49, 0xbb, 0x00, 0x54, 0x02, 0x00, 0x00, } func (this *GenesisDenom) Equal(that interface{}) bool { @@ -209,6 +220,15 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.NoFeeAccounts) > 0 { + for iNdEx := len(m.NoFeeAccounts) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.NoFeeAccounts[iNdEx]) + copy(dAtA[i:], m.NoFeeAccounts[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.NoFeeAccounts[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } if len(m.FactoryDenoms) > 0 { for iNdEx := len(m.FactoryDenoms) - 1; iNdEx >= 0; iNdEx-- { { @@ -301,6 +321,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.NoFeeAccounts) > 0 { + for _, s := range m.NoFeeAccounts { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -421,6 +447,38 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NoFeeAccounts", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NoFeeAccounts = append(m.NoFeeAccounts, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/denom/types/keys.go b/x/denom/types/keys.go index 2e1bb54c..395ec069 100644 --- a/x/denom/types/keys.go +++ b/x/denom/types/keys.go @@ -29,6 +29,7 @@ var ( DenomsPrefixKey = "denoms" CreatorPrefixKey = "creator" AdminPrefixKey = "admin" + NoFeeAccountPrefixKey = "nofeeaccount" ParamsKey = []byte("params") ) @@ -48,3 +49,8 @@ func GetCreatorPrefix(creator string) []byte { func GetCreatorsPrefix() []byte { return []byte(strings.Join([]string{CreatorPrefixKey, ""}, KeySeparator)) } + +// GetNoFeeAccountPrefix returns the store prefix where a list of all no fee spending accounts in denom creation +func GetNoFeeAccountPrefix() []byte { + return []byte(strings.Join([]string{NoFeeAccountPrefixKey, ""}, KeySeparator)) +} diff --git a/x/denom/types/msgs.go b/x/denom/types/msgs.go index 8eeec8b3..e79259ab 100644 --- a/x/denom/types/msgs.go +++ b/x/denom/types/msgs.go @@ -8,12 +8,14 @@ import ( // constants const ( - TypeMsgCreateDenom = "create_denom" - TypeMsgMint = "mint" - TypeMsgBurn = "burn" - TypeMsgForceTransfer = "force_transfer" - TypeMsgChangeAdmin = "change_admin" - TypeMsgUpdateParams = "update_params" + TypeMsgCreateDenom = "create_denom" + TypeMsgMint = "mint" + TypeMsgBurn = "burn" + TypeMsgForceTransfer = "force_transfer" + TypeMsgChangeAdmin = "change_admin" + TypeMsgUpdateParams = "update_params" + TypeMsgAddNoFeeAccounts = "add_no_fee_accounts" + TypeMsgRemoveNoFeeAccounts = "remove_no_fee_accounts" ) var ( @@ -221,3 +223,55 @@ func (m MsgUpdateParams) ValidateBasic() error { return nil } + +var _ sdk.Msg = &MsgAddNoFeeAccounts{} + +// NewMsgAddNoFeeAccounts creates a message to add no fee accounts +func NewMsgAddNoFeeAccounts(authority string, accounts []string) *MsgAddNoFeeAccounts { + return &MsgAddNoFeeAccounts{ + Authority: authority, + Accounts: accounts, + } +} + +func (m MsgAddNoFeeAccounts) Route() string { return RouterKey } +func (m MsgAddNoFeeAccounts) Type() string { return TypeMsgAddNoFeeAccounts } +func (m MsgAddNoFeeAccounts) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Authority) + if err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + return nil +} + +func (m MsgAddNoFeeAccounts) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.Authority) + return []sdk.AccAddress{sender} +} + +var _ sdk.Msg = &MsgRemoveNoFeeAccounts{} + +// NewMsgRemoveNoFeeAccounts creates a message to add no fee accounts +func NewMsgRemoveNoFeeAccounts(authority string, accounts []string) *MsgRemoveNoFeeAccounts { + return &MsgRemoveNoFeeAccounts{ + Authority: authority, + Accounts: accounts, + } +} + +func (m MsgRemoveNoFeeAccounts) Route() string { return RouterKey } +func (m MsgRemoveNoFeeAccounts) Type() string { return TypeMsgRemoveNoFeeAccounts } +func (m MsgRemoveNoFeeAccounts) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Authority) + if err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + return nil +} + +func (m MsgRemoveNoFeeAccounts) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.Authority) + return []sdk.AccAddress{sender} +} diff --git a/x/denom/types/params.go b/x/denom/types/params.go index f4021749..5e7bd00f 100644 --- a/x/denom/types/params.go +++ b/x/denom/types/params.go @@ -9,7 +9,8 @@ import ( // Parameter store keys. var ( - KeyCreationFee = []byte("CreationFee") + KeyCreationFee = []byte("CreationFee") + KeyNoFeeAccounts = []byte("NoFeeAccounts") ) // ParamTable for gamm module. diff --git a/x/denom/types/query.pb.go b/x/denom/types/query.pb.go index 25b49e45..96f3f14a 100644 --- a/x/denom/types/query.pb.go +++ b/x/denom/types/query.pb.go @@ -30,6 +30,89 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// QueryNoFeeAccountsRequest is the request type for the Query/NoFeeAccounts RPC method. +type QueryNoFeeAccountsRequest struct { +} + +func (m *QueryNoFeeAccountsRequest) Reset() { *m = QueryNoFeeAccountsRequest{} } +func (m *QueryNoFeeAccountsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryNoFeeAccountsRequest) ProtoMessage() {} +func (*QueryNoFeeAccountsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b3d0e02d4d7e16e6, []int{0} +} +func (m *QueryNoFeeAccountsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNoFeeAccountsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNoFeeAccountsRequest.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 *QueryNoFeeAccountsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNoFeeAccountsRequest.Merge(m, src) +} +func (m *QueryNoFeeAccountsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryNoFeeAccountsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNoFeeAccountsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNoFeeAccountsRequest proto.InternalMessageInfo + +// QueryNoFeeAccountsResponse is the response type for the Query/NoFeeAccounts RPC method. +type QueryNoFeeAccountsResponse struct { + // params defines the parameters of the module. + Accounts []string `protobuf:"bytes,1,rep,name=accounts,proto3" json:"accounts,omitempty"` +} + +func (m *QueryNoFeeAccountsResponse) Reset() { *m = QueryNoFeeAccountsResponse{} } +func (m *QueryNoFeeAccountsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryNoFeeAccountsResponse) ProtoMessage() {} +func (*QueryNoFeeAccountsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b3d0e02d4d7e16e6, []int{1} +} +func (m *QueryNoFeeAccountsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNoFeeAccountsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNoFeeAccountsResponse.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 *QueryNoFeeAccountsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNoFeeAccountsResponse.Merge(m, src) +} +func (m *QueryNoFeeAccountsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryNoFeeAccountsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNoFeeAccountsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNoFeeAccountsResponse proto.InternalMessageInfo + +func (m *QueryNoFeeAccountsResponse) GetAccounts() []string { + if m != nil { + return m.Accounts + } + return nil +} + // QueryParamsRequest is the request type for the Query/Params RPC method. type QueryParamsRequest struct { } @@ -38,7 +121,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b3d0e02d4d7e16e6, []int{0} + return fileDescriptor_b3d0e02d4d7e16e6, []int{2} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -77,7 +160,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b3d0e02d4d7e16e6, []int{1} + return fileDescriptor_b3d0e02d4d7e16e6, []int{3} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -121,7 +204,7 @@ func (m *QueryDenomAuthorityMetadataRequest) Reset() { *m = QueryDenomAu func (m *QueryDenomAuthorityMetadataRequest) String() string { return proto.CompactTextString(m) } func (*QueryDenomAuthorityMetadataRequest) ProtoMessage() {} func (*QueryDenomAuthorityMetadataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b3d0e02d4d7e16e6, []int{2} + return fileDescriptor_b3d0e02d4d7e16e6, []int{4} } func (m *QueryDenomAuthorityMetadataRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -165,7 +248,7 @@ func (m *QueryDenomAuthorityMetadataResponse) Reset() { *m = QueryDenomA func (m *QueryDenomAuthorityMetadataResponse) String() string { return proto.CompactTextString(m) } func (*QueryDenomAuthorityMetadataResponse) ProtoMessage() {} func (*QueryDenomAuthorityMetadataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b3d0e02d4d7e16e6, []int{3} + return fileDescriptor_b3d0e02d4d7e16e6, []int{5} } func (m *QueryDenomAuthorityMetadataResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -209,7 +292,7 @@ func (m *QueryDenomsFromCreatorRequest) Reset() { *m = QueryDenomsFromCr func (m *QueryDenomsFromCreatorRequest) String() string { return proto.CompactTextString(m) } func (*QueryDenomsFromCreatorRequest) ProtoMessage() {} func (*QueryDenomsFromCreatorRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b3d0e02d4d7e16e6, []int{4} + return fileDescriptor_b3d0e02d4d7e16e6, []int{6} } func (m *QueryDenomsFromCreatorRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -253,7 +336,7 @@ func (m *QueryDenomsFromCreatorResponse) Reset() { *m = QueryDenomsFromC func (m *QueryDenomsFromCreatorResponse) String() string { return proto.CompactTextString(m) } func (*QueryDenomsFromCreatorResponse) ProtoMessage() {} func (*QueryDenomsFromCreatorResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b3d0e02d4d7e16e6, []int{5} + return fileDescriptor_b3d0e02d4d7e16e6, []int{7} } func (m *QueryDenomsFromCreatorResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -290,6 +373,8 @@ func (m *QueryDenomsFromCreatorResponse) GetDenoms() []string { } func init() { + proto.RegisterType((*QueryNoFeeAccountsRequest)(nil), "kujira.denom.QueryNoFeeAccountsRequest") + proto.RegisterType((*QueryNoFeeAccountsResponse)(nil), "kujira.denom.QueryNoFeeAccountsResponse") proto.RegisterType((*QueryParamsRequest)(nil), "kujira.denom.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "kujira.denom.QueryParamsResponse") proto.RegisterType((*QueryDenomAuthorityMetadataRequest)(nil), "kujira.denom.QueryDenomAuthorityMetadataRequest") @@ -301,42 +386,46 @@ func init() { func init() { proto.RegisterFile("kujira/denom/query.proto", fileDescriptor_b3d0e02d4d7e16e6) } var fileDescriptor_b3d0e02d4d7e16e6 = []byte{ - // 554 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcf, 0x6e, 0xd3, 0x4a, - 0x14, 0xc6, 0xe3, 0xdb, 0xdb, 0xa0, 0x0e, 0x05, 0x91, 0x21, 0x40, 0x1b, 0x51, 0xa7, 0x9d, 0x16, - 0xd4, 0x90, 0xe2, 0x21, 0x61, 0xc7, 0x0e, 0x17, 0x21, 0xa1, 0x52, 0x09, 0x2c, 0x56, 0x6c, 0xaa, - 0x71, 0x3a, 0x72, 0x0d, 0xb1, 0xc7, 0xf5, 0x8c, 0x2b, 0xac, 0xaa, 0x1b, 0x9e, 0x00, 0x89, 0x25, - 0xe2, 0x1d, 0x78, 0x0a, 0xd4, 0x65, 0x25, 0x36, 0xac, 0x2c, 0x94, 0xf0, 0x04, 0x79, 0x02, 0xe4, - 0x99, 0x29, 0xc4, 0x71, 0x1a, 0xc1, 0xca, 0xd6, 0x39, 0x9f, 0xbf, 0xf3, 0x3b, 0x7f, 0x0c, 0x96, - 0xde, 0x26, 0x6f, 0xfc, 0x98, 0xe0, 0x7d, 0x1a, 0xb2, 0x00, 0x1f, 0x26, 0x34, 0x4e, 0xad, 0x28, - 0x66, 0x82, 0xc1, 0x45, 0x95, 0xb1, 0x64, 0xa6, 0x51, 0xf7, 0x98, 0xc7, 0x64, 0x02, 0xe7, 0x6f, - 0x4a, 0xd3, 0xb8, 0xed, 0x31, 0xe6, 0xf5, 0x29, 0x26, 0x91, 0x8f, 0x49, 0x18, 0x32, 0x41, 0x84, - 0xcf, 0x42, 0xae, 0xb3, 0xf7, 0x7a, 0x8c, 0x07, 0x8c, 0x63, 0x97, 0x70, 0xaa, 0xac, 0xf1, 0x51, - 0xc7, 0xa5, 0x82, 0x74, 0x70, 0x44, 0x3c, 0x3f, 0x94, 0x62, 0xad, 0xdd, 0x28, 0x70, 0x90, 0x44, - 0x1c, 0xb0, 0xd8, 0x17, 0xe9, 0x2e, 0x15, 0x64, 0x9f, 0x08, 0xa2, 0x55, 0xcb, 0x05, 0x55, 0x44, - 0x62, 0x12, 0xe8, 0x62, 0xa8, 0x0e, 0xe0, 0xcb, 0xbc, 0xc4, 0x0b, 0x19, 0x74, 0xe8, 0x61, 0x42, - 0xb9, 0x40, 0xcf, 0xc0, 0xf5, 0x42, 0x94, 0x47, 0x2c, 0xe4, 0x14, 0x76, 0x41, 0x55, 0x7d, 0xbc, - 0x64, 0xac, 0x1a, 0x9b, 0x97, 0xbb, 0x75, 0x6b, 0xbc, 0x59, 0x4b, 0xa9, 0xed, 0xff, 0x4f, 0xb3, - 0x66, 0xc5, 0xd1, 0x4a, 0xf4, 0x1c, 0x20, 0x69, 0xf5, 0x24, 0x97, 0x3c, 0x9e, 0x04, 0xd4, 0x05, - 0xe1, 0x5d, 0x30, 0x2f, 0x3d, 0xa4, 0xf1, 0x82, 0x7d, 0x6d, 0x94, 0x35, 0x17, 0x53, 0x12, 0xf4, - 0x1f, 0x21, 0x19, 0x46, 0x8e, 0x4a, 0xa3, 0xcf, 0x06, 0x58, 0x9f, 0x69, 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xac, 0x19, 0xdb, 0x92, 0xf1, 0x0e, 0x5c, 0x9f, 0x60, 0x74, 0xd3, 0x3d, 0x7d, 0x0b, - 0xf8, 0x58, 0xbf, 0x9c, 0xd8, 0xdb, 0xa7, 0x03, 0xd3, 0x38, 0x1b, 0x98, 0xc6, 0x8f, 0x81, 0x69, - 0x7c, 0x18, 0x9a, 0x95, 0xb3, 0xa1, 0x59, 0xf9, 0x3e, 0x34, 0x2b, 0xaf, 0x5b, 0x9e, 0x2f, 0x0e, - 0x12, 0xd7, 0xea, 0xb1, 0x00, 0xbf, 0xa2, 0x24, 0xb8, 0xbf, 0xa3, 0xdc, 0x7a, 0x2c, 0xa6, 0xf8, - 0x9d, 0xfe, 0xff, 0x45, 0x1a, 0x51, 0xee, 0x56, 0xe5, 0xff, 0xff, 0xf0, 0x57, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xb3, 0x61, 0x5b, 0x53, 0xca, 0x04, 0x00, 0x00, + // 622 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x4f, 0x4f, 0x13, 0x41, + 0x18, 0xc6, 0xbb, 0x0a, 0x55, 0x46, 0x30, 0x32, 0xa2, 0xc2, 0x2a, 0xdb, 0x32, 0x20, 0x52, 0x8b, + 0x1d, 0x5b, 0x2f, 0xc6, 0x1b, 0xc5, 0x90, 0x18, 0xc4, 0xe8, 0xc6, 0x93, 0x97, 0x66, 0xba, 0x8c, + 0xcb, 0x6a, 0x77, 0x67, 0xd9, 0x99, 0x25, 0x36, 0x84, 0x8b, 0x47, 0x4f, 0x26, 0x1e, 0x8d, 0xdf, + 0xc1, 0x8f, 0xc1, 0x91, 0x84, 0x8b, 0xa7, 0xc6, 0xb4, 0x7e, 0x82, 0x7e, 0x02, 0xd3, 0x99, 0x29, + 0x76, 0xdb, 0xa5, 0xea, 0xa9, 0xdb, 0x79, 0x9f, 0x7d, 0xde, 0xdf, 0xfb, 0x67, 0x07, 0xcc, 0xbf, + 0x8f, 0xdf, 0x79, 0x11, 0xc1, 0xbb, 0x34, 0x60, 0x3e, 0xde, 0x8f, 0x69, 0xd4, 0x2c, 0x85, 0x11, + 0x13, 0x0c, 0x4e, 0xab, 0x48, 0x49, 0x46, 0xcc, 0x39, 0x97, 0xb9, 0x4c, 0x06, 0x70, 0xef, 0x49, + 0x69, 0xcc, 0x3b, 0x2e, 0x63, 0x6e, 0x83, 0x62, 0x12, 0x7a, 0x98, 0x04, 0x01, 0x13, 0x44, 0x78, + 0x2c, 0xe0, 0x3a, 0x7a, 0xdf, 0x61, 0xdc, 0x67, 0x1c, 0xd7, 0x09, 0xa7, 0xca, 0x1a, 0x1f, 0x94, + 0xeb, 0x54, 0x90, 0x32, 0x0e, 0x89, 0xeb, 0x05, 0x52, 0xac, 0xb5, 0x2b, 0x09, 0x0e, 0x12, 0x8b, + 0x3d, 0x16, 0x79, 0xa2, 0xb9, 0x43, 0x05, 0xd9, 0x25, 0x82, 0x68, 0xd5, 0x42, 0x42, 0x15, 0x92, + 0x88, 0xf8, 0x3a, 0x19, 0xba, 0x0d, 0x16, 0x5e, 0xf5, 0x52, 0xbc, 0x60, 0x5b, 0x94, 0x6e, 0x38, + 0x0e, 0x8b, 0x03, 0xc1, 0x6d, 0xba, 0x1f, 0x53, 0x2e, 0xd0, 0x63, 0x60, 0xa6, 0x05, 0x79, 0xc8, + 0x02, 0x4e, 0xa1, 0x09, 0x2e, 0x13, 0x7d, 0x36, 0x6f, 0xe4, 0x2f, 0xae, 0x4d, 0xd9, 0x67, 0xff, + 0xd1, 0x1c, 0x80, 0xf2, 0xcd, 0x97, 0x32, 0x57, 0xdf, 0xef, 0x19, 0xb8, 0x9e, 0x38, 0xd5, 0x46, + 0x15, 0x90, 0x55, 0x4c, 0xf3, 0x46, 0xde, 0x58, 0xbb, 0x52, 0x99, 0x2b, 0x0d, 0xf6, 0xb0, 0xa4, + 0xd4, 0xd5, 0x89, 0xe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f8, 0x30, 0xc5, 0x7c, 0xec, 0xa2, + 0x98, 0xe5, 0xff, 0x78, 0x43, 0xe3, 0x95, 0x25, 0x5e, 0x11, 0x16, 0x86, 0xf0, 0x0e, 0xe5, 0xef, + 0x11, 0x1e, 0x1d, 0x2d, 0xfc, 0x6a, 0x80, 0xd9, 0x91, 0x9e, 0xc3, 0xe2, 0x79, 0xb9, 0x53, 0x06, + 0x6d, 0xae, 0xff, 0x9b, 0x58, 0x33, 0x16, 0x25, 0xe3, 0x5d, 0xb8, 0x3c, 0xc4, 0x58, 0x6f, 0xd6, + 0xf4, 0x2e, 0xe0, 0x43, 0xfd, 0x70, 0x04, 0x3f, 0x19, 0x60, 0x26, 0xf1, 0xa5, 0xc3, 0x7b, 0x29, + 0xc9, 0xd2, 0x2e, 0x0a, 0x73, 0xed, 0xef, 0x42, 0x4d, 0xb4, 0x2a, 0x89, 0xf2, 0xd0, 0x1a, 0x22, + 0x0a, 0x58, 0xed, 0x2d, 0xa5, 0xb5, 0xfe, 0x05, 0x52, 0xdd, 0x3c, 0x6e, 0x5b, 0xc6, 0x49, 0xdb, + 0x32, 0x7e, 0xb6, 0x2d, 0xe3, 0x73, 0xc7, 0xca, 0x9c, 0x74, 0xac, 0xcc, 0x8f, 0x8e, 0x95, 0x79, + 0x53, 0x70, 0x3d, 0xb1, 0x17, 0xd7, 0x4b, 0x0e, 0xf3, 0xf1, 0x6b, 0x4a, 0xfc, 0x07, 0xdb, 0xca, + 0xc8, 0x61, 0x11, 0xc5, 0x1f, 0xf4, 0x1d, 0x27, 0x9a, 0x21, 0xe5, 0xf5, 0xac, 0xbc, 0xe3, 0x1e, + 0xfd, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x68, 0xd3, 0x32, 0xf7, 0xae, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -355,6 +444,8 @@ type QueryClient interface { Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) DenomAuthorityMetadata(ctx context.Context, in *QueryDenomAuthorityMetadataRequest, opts ...grpc.CallOption) (*QueryDenomAuthorityMetadataResponse, error) DenomsFromCreator(ctx context.Context, in *QueryDenomsFromCreatorRequest, opts ...grpc.CallOption) (*QueryDenomsFromCreatorResponse, error) + // NoFeeAccounts returns accounts whitelisted to create denom without fee + NoFeeAccounts(ctx context.Context, in *QueryNoFeeAccountsRequest, opts ...grpc.CallOption) (*QueryNoFeeAccountsResponse, error) } type queryClient struct { @@ -392,12 +483,23 @@ func (c *queryClient) DenomsFromCreator(ctx context.Context, in *QueryDenomsFrom return out, nil } +func (c *queryClient) NoFeeAccounts(ctx context.Context, in *QueryNoFeeAccountsRequest, opts ...grpc.CallOption) (*QueryNoFeeAccountsResponse, error) { + out := new(QueryNoFeeAccountsResponse) + err := c.cc.Invoke(ctx, "/kujira.denom.Query/NoFeeAccounts", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Params returns the total set of minting parameters. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) DenomAuthorityMetadata(context.Context, *QueryDenomAuthorityMetadataRequest) (*QueryDenomAuthorityMetadataResponse, error) DenomsFromCreator(context.Context, *QueryDenomsFromCreatorRequest) (*QueryDenomsFromCreatorResponse, error) + // NoFeeAccounts returns accounts whitelisted to create denom without fee + NoFeeAccounts(context.Context, *QueryNoFeeAccountsRequest) (*QueryNoFeeAccountsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -413,6 +515,9 @@ func (*UnimplementedQueryServer) DenomAuthorityMetadata(ctx context.Context, req func (*UnimplementedQueryServer) DenomsFromCreator(ctx context.Context, req *QueryDenomsFromCreatorRequest) (*QueryDenomsFromCreatorResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DenomsFromCreator not implemented") } +func (*UnimplementedQueryServer) NoFeeAccounts(ctx context.Context, req *QueryNoFeeAccountsRequest) (*QueryNoFeeAccountsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NoFeeAccounts not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -472,6 +577,24 @@ func _Query_DenomsFromCreator_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Query_NoFeeAccounts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryNoFeeAccountsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).NoFeeAccounts(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kujira.denom.Query/NoFeeAccounts", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).NoFeeAccounts(ctx, req.(*QueryNoFeeAccountsRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "kujira.denom.Query", HandlerType: (*QueryServer)(nil), @@ -488,11 +611,70 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "DenomsFromCreator", Handler: _Query_DenomsFromCreator_Handler, }, + { + MethodName: "NoFeeAccounts", + Handler: _Query_NoFeeAccounts_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "kujira/denom/query.proto", } +func (m *QueryNoFeeAccountsRequest) 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 *QueryNoFeeAccountsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNoFeeAccountsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryNoFeeAccountsResponse) 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 *QueryNoFeeAccountsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNoFeeAccountsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Accounts) > 0 { + for iNdEx := len(m.Accounts) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Accounts[iNdEx]) + copy(dAtA[i:], m.Accounts[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Accounts[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -685,6 +867,30 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *QueryNoFeeAccountsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryNoFeeAccountsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Accounts) > 0 { + for _, s := range m.Accounts { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func (m *QueryParamsRequest) Size() (n int) { if m == nil { return 0 @@ -763,6 +969,138 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *QueryNoFeeAccountsRequest) 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: QueryNoFeeAccountsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNoFeeAccountsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryNoFeeAccountsResponse) 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: QueryNoFeeAccountsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNoFeeAccountsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Accounts", 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.Accounts = append(m.Accounts, 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 *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/denom/types/query.pb.gw.go b/x/denom/types/query.pb.gw.go index f93044eb..5045cc92 100644 --- a/x/denom/types/query.pb.gw.go +++ b/x/denom/types/query.pb.gw.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -31,7 +30,6 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -159,17 +157,33 @@ func local_request_Query_DenomsFromCreator_0(ctx context.Context, marshaler runt } +func request_Query_NoFeeAccounts_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNoFeeAccountsRequest + var metadata runtime.ServerMetadata + + msg, err := client.NoFeeAccounts(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_NoFeeAccounts_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNoFeeAccountsRequest + var metadata runtime.ServerMetadata + + msg, err := server.NoFeeAccounts(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -177,7 +191,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -191,8 +204,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_DenomAuthorityMetadata_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 { @@ -200,7 +211,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_DenomAuthorityMetadata_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) @@ -214,8 +224,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_DenomsFromCreator_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 { @@ -223,7 +231,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_DenomsFromCreator_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) @@ -234,6 +241,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_NoFeeAccounts_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_NoFeeAccounts_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_NoFeeAccounts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -335,6 +362,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_NoFeeAccounts_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_NoFeeAccounts_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_NoFeeAccounts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -344,6 +391,8 @@ var ( pattern_Query_DenomAuthorityMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"kujira", "denoms", "denom", "authority_metadata"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_DenomsFromCreator_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"kujira", "denoms", "by_creator", "creator"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_NoFeeAccounts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"kujira", "denoms", "no_fee_accounts"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -352,4 +401,6 @@ var ( forward_Query_DenomAuthorityMetadata_0 = runtime.ForwardResponseMessage forward_Query_DenomsFromCreator_0 = runtime.ForwardResponseMessage + + forward_Query_NoFeeAccounts_0 = runtime.ForwardResponseMessage ) diff --git a/x/denom/types/tx.pb.go b/x/denom/types/tx.pb.go index cf708963..daf2e0a2 100644 --- a/x/denom/types/tx.pb.go +++ b/x/denom/types/tx.pb.go @@ -30,6 +30,182 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type MsgAddNoFeeAccounts struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Accounts []string `protobuf:"bytes,2,rep,name=accounts,proto3" json:"accounts,omitempty"` +} + +func (m *MsgAddNoFeeAccounts) Reset() { *m = MsgAddNoFeeAccounts{} } +func (m *MsgAddNoFeeAccounts) String() string { return proto.CompactTextString(m) } +func (*MsgAddNoFeeAccounts) ProtoMessage() {} +func (*MsgAddNoFeeAccounts) Descriptor() ([]byte, []int) { + return fileDescriptor_4060456503c2ab45, []int{0} +} +func (m *MsgAddNoFeeAccounts) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddNoFeeAccounts) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddNoFeeAccounts.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 *MsgAddNoFeeAccounts) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddNoFeeAccounts.Merge(m, src) +} +func (m *MsgAddNoFeeAccounts) XXX_Size() int { + return m.Size() +} +func (m *MsgAddNoFeeAccounts) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddNoFeeAccounts.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddNoFeeAccounts proto.InternalMessageInfo + +func (m *MsgAddNoFeeAccounts) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgAddNoFeeAccounts) GetAccounts() []string { + if m != nil { + return m.Accounts + } + return nil +} + +type MsgAddNoFeeAccountsResponse struct { +} + +func (m *MsgAddNoFeeAccountsResponse) Reset() { *m = MsgAddNoFeeAccountsResponse{} } +func (m *MsgAddNoFeeAccountsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAddNoFeeAccountsResponse) ProtoMessage() {} +func (*MsgAddNoFeeAccountsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4060456503c2ab45, []int{1} +} +func (m *MsgAddNoFeeAccountsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddNoFeeAccountsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddNoFeeAccountsResponse.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 *MsgAddNoFeeAccountsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddNoFeeAccountsResponse.Merge(m, src) +} +func (m *MsgAddNoFeeAccountsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAddNoFeeAccountsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddNoFeeAccountsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddNoFeeAccountsResponse proto.InternalMessageInfo + +type MsgRemoveNoFeeAccounts struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Accounts []string `protobuf:"bytes,2,rep,name=accounts,proto3" json:"accounts,omitempty"` +} + +func (m *MsgRemoveNoFeeAccounts) Reset() { *m = MsgRemoveNoFeeAccounts{} } +func (m *MsgRemoveNoFeeAccounts) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveNoFeeAccounts) ProtoMessage() {} +func (*MsgRemoveNoFeeAccounts) Descriptor() ([]byte, []int) { + return fileDescriptor_4060456503c2ab45, []int{2} +} +func (m *MsgRemoveNoFeeAccounts) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveNoFeeAccounts) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveNoFeeAccounts.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 *MsgRemoveNoFeeAccounts) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveNoFeeAccounts.Merge(m, src) +} +func (m *MsgRemoveNoFeeAccounts) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveNoFeeAccounts) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveNoFeeAccounts.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveNoFeeAccounts proto.InternalMessageInfo + +func (m *MsgRemoveNoFeeAccounts) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgRemoveNoFeeAccounts) GetAccounts() []string { + if m != nil { + return m.Accounts + } + return nil +} + +type MsgRemoveNoFeeAccountsResponse struct { +} + +func (m *MsgRemoveNoFeeAccountsResponse) Reset() { *m = MsgRemoveNoFeeAccountsResponse{} } +func (m *MsgRemoveNoFeeAccountsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveNoFeeAccountsResponse) ProtoMessage() {} +func (*MsgRemoveNoFeeAccountsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4060456503c2ab45, []int{3} +} +func (m *MsgRemoveNoFeeAccountsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveNoFeeAccountsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveNoFeeAccountsResponse.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 *MsgRemoveNoFeeAccountsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveNoFeeAccountsResponse.Merge(m, src) +} +func (m *MsgRemoveNoFeeAccountsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveNoFeeAccountsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveNoFeeAccountsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveNoFeeAccountsResponse proto.InternalMessageInfo + // MsgCreateDenom is the sdk.Msg type for allowing an account to create // a new denom. It requires a sender address and a unique nonce // (to allow accounts to create multiple denoms) @@ -42,7 +218,7 @@ func (m *MsgCreateDenom) Reset() { *m = MsgCreateDenom{} } func (m *MsgCreateDenom) String() string { return proto.CompactTextString(m) } func (*MsgCreateDenom) ProtoMessage() {} func (*MsgCreateDenom) Descriptor() ([]byte, []int) { - return fileDescriptor_4060456503c2ab45, []int{0} + return fileDescriptor_4060456503c2ab45, []int{4} } func (m *MsgCreateDenom) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -95,7 +271,7 @@ func (m *MsgCreateDenomResponse) Reset() { *m = MsgCreateDenomResponse{} func (m *MsgCreateDenomResponse) String() string { return proto.CompactTextString(m) } func (*MsgCreateDenomResponse) ProtoMessage() {} func (*MsgCreateDenomResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4060456503c2ab45, []int{1} + return fileDescriptor_4060456503c2ab45, []int{5} } func (m *MsgCreateDenomResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -143,7 +319,7 @@ func (m *MsgMint) Reset() { *m = MsgMint{} } func (m *MsgMint) String() string { return proto.CompactTextString(m) } func (*MsgMint) ProtoMessage() {} func (*MsgMint) Descriptor() ([]byte, []int) { - return fileDescriptor_4060456503c2ab45, []int{2} + return fileDescriptor_4060456503c2ab45, []int{6} } func (m *MsgMint) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -200,7 +376,7 @@ func (m *MsgMintResponse) Reset() { *m = MsgMintResponse{} } func (m *MsgMintResponse) String() string { return proto.CompactTextString(m) } func (*MsgMintResponse) ProtoMessage() {} func (*MsgMintResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4060456503c2ab45, []int{3} + return fileDescriptor_4060456503c2ab45, []int{7} } func (m *MsgMintResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -240,7 +416,7 @@ func (m *MsgBurn) Reset() { *m = MsgBurn{} } func (m *MsgBurn) String() string { return proto.CompactTextString(m) } func (*MsgBurn) ProtoMessage() {} func (*MsgBurn) Descriptor() ([]byte, []int) { - return fileDescriptor_4060456503c2ab45, []int{4} + return fileDescriptor_4060456503c2ab45, []int{8} } func (m *MsgBurn) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -290,7 +466,7 @@ func (m *MsgBurnResponse) Reset() { *m = MsgBurnResponse{} } func (m *MsgBurnResponse) String() string { return proto.CompactTextString(m) } func (*MsgBurnResponse) ProtoMessage() {} func (*MsgBurnResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4060456503c2ab45, []int{5} + return fileDescriptor_4060456503c2ab45, []int{9} } func (m *MsgBurnResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -331,7 +507,7 @@ func (m *MsgChangeAdmin) Reset() { *m = MsgChangeAdmin{} } func (m *MsgChangeAdmin) String() string { return proto.CompactTextString(m) } func (*MsgChangeAdmin) ProtoMessage() {} func (*MsgChangeAdmin) Descriptor() ([]byte, []int) { - return fileDescriptor_4060456503c2ab45, []int{6} + return fileDescriptor_4060456503c2ab45, []int{10} } func (m *MsgChangeAdmin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -388,7 +564,7 @@ func (m *MsgChangeAdminResponse) Reset() { *m = MsgChangeAdminResponse{} func (m *MsgChangeAdminResponse) String() string { return proto.CompactTextString(m) } func (*MsgChangeAdminResponse) ProtoMessage() {} func (*MsgChangeAdminResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4060456503c2ab45, []int{7} + return fileDescriptor_4060456503c2ab45, []int{11} } func (m *MsgChangeAdminResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -426,7 +602,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_4060456503c2ab45, []int{8} + return fileDescriptor_4060456503c2ab45, []int{12} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -477,7 +653,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4060456503c2ab45, []int{9} + return fileDescriptor_4060456503c2ab45, []int{13} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -507,6 +683,10 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo func init() { + proto.RegisterType((*MsgAddNoFeeAccounts)(nil), "kujira.denom.MsgAddNoFeeAccounts") + proto.RegisterType((*MsgAddNoFeeAccountsResponse)(nil), "kujira.denom.MsgAddNoFeeAccountsResponse") + proto.RegisterType((*MsgRemoveNoFeeAccounts)(nil), "kujira.denom.MsgRemoveNoFeeAccounts") + proto.RegisterType((*MsgRemoveNoFeeAccountsResponse)(nil), "kujira.denom.MsgRemoveNoFeeAccountsResponse") proto.RegisterType((*MsgCreateDenom)(nil), "kujira.denom.MsgCreateDenom") proto.RegisterType((*MsgCreateDenomResponse)(nil), "kujira.denom.MsgCreateDenomResponse") proto.RegisterType((*MsgMint)(nil), "kujira.denom.MsgMint") @@ -522,47 +702,53 @@ func init() { func init() { proto.RegisterFile("kujira/denom/tx.proto", fileDescriptor_4060456503c2ab45) } var fileDescriptor_4060456503c2ab45 = []byte{ - // 629 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x54, 0x4d, 0x6b, 0x13, 0x41, - 0x18, 0xce, 0xb6, 0x1a, 0xed, 0xf4, 0x7b, 0xe9, 0x47, 0xba, 0xe8, 0x46, 0x06, 0x15, 0x2b, 0xb8, - 0x6b, 0xeb, 0xad, 0x08, 0x62, 0xe2, 0x41, 0x90, 0x80, 0x2e, 0xf1, 0x22, 0x42, 0x99, 0x6c, 0x86, - 0xcd, 0x5a, 0x77, 0x66, 0xd9, 0x99, 0x34, 0xcd, 0xd5, 0xab, 0x17, 0x4f, 0xfe, 0x00, 0x7f, 0x81, - 0xff, 0xc0, 0x6b, 0x8f, 0x3d, 0x7a, 0x0a, 0x92, 0x1c, 0xbc, 0xe7, 0x2e, 0xc8, 0x7c, 0x64, 0x3f, - 0xdc, 0x50, 0xe8, 0xc9, 0x53, 0xc2, 0xfb, 0x3c, 0xef, 0x3b, 0xcf, 0xf3, 0x7e, 0x2c, 0xd8, 0x3e, - 0xe9, 0x7f, 0x08, 0x13, 0xe4, 0x76, 0x31, 0xa1, 0x91, 0xcb, 0xcf, 0x9c, 0x38, 0xa1, 0x9c, 0x9a, - 0x2b, 0x2a, 0xec, 0xc8, 0xb0, 0xb5, 0x15, 0xd0, 0x80, 0x4a, 0xc0, 0x15, 0xff, 0x14, 0xc7, 0xda, - 0xf5, 0x29, 0x8b, 0x28, 0x73, 0x23, 0x16, 0xb8, 0xa7, 0x07, 0xe2, 0x47, 0x03, 0xb6, 0x06, 0x3a, - 0x88, 0x61, 0xf7, 0xf4, 0xa0, 0x83, 0x39, 0x3a, 0x70, 0x7d, 0x1a, 0x12, 0x8d, 0xef, 0x15, 0xde, - 0x8c, 0x51, 0x82, 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xc2, 0x73, - 0xb2, 0xf3, 0x9b, 0x24, 0xed, 0xe4, 0xb6, 0x68, 0x8e, 0x9d, 0x0c, 0x9d, 0x67, 0xa7, 0x3c, 0x5d, - 0xb3, 0x0d, 0x56, 0x0a, 0x93, 0x2d, 0x2b, 0xc8, 0xc3, 0xd6, 0xbd, 0x4b, 0xe1, 0x59, 0xd5, 0x46, - 0xf3, 0x7c, 0x6c, 0x1b, 0x17, 0x63, 0xdb, 0xf8, 0x35, 0xb6, 0x8d, 0x2f, 0x13, 0xbb, 0x72, 0x31, - 0xb1, 0x2b, 0x3f, 0x27, 0x76, 0xe5, 0xdd, 0x7e, 0x10, 0xf2, 0x5e, 0xbf, 0xe3, 0xf8, 0x34, 0x72, - 0xdb, 0x18, 0x45, 0x8f, 0x5e, 0xa9, 0xaf, 0xaf, 0x4f, 0x13, 0xec, 0x9e, 0xcd, 0x3e, 0xfc, 0xc3, - 0x18, 0xb3, 0x4e, 0x55, 0x7e, 0x84, 0x9f, 0xfc, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xdd, 0x5d, 0x27, - 0x25, 0x15, 0x06, 0x00, 0x00, + // 736 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0x4b, 0x6f, 0xd3, 0x4e, + 0x10, 0x8f, 0xdb, 0xfe, 0xf3, 0x6f, 0xb6, 0x6f, 0xf7, 0x95, 0x9a, 0xd6, 0x29, 0xab, 0x82, 0x5a, + 0x04, 0x36, 0x2d, 0xb7, 0x0a, 0x09, 0x35, 0x45, 0x08, 0x09, 0x85, 0x87, 0x55, 0x2e, 0x08, 0xa9, + 0x6c, 0x9c, 0x95, 0x6b, 0x8a, 0x77, 0x2d, 0xaf, 0xd3, 0xc7, 0x95, 0x2b, 0x17, 0x4e, 0x7c, 0x00, + 0x3e, 0x01, 0xdf, 0x80, 0x6b, 0xc5, 0xa9, 0x47, 0x4e, 0x11,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, 0x2a, 0x34, + 0xa7, 0xbd, 0xc5, 0xd6, 0xe5, 0xbd, 0xb9, 0xb9, 0xc0, 0x3b, 0xbd, 0x16, 0xa2, 0x9c, 0xd4, 0x4a, + 0x14, 0x94, 0xd3, 0x47, 0x8b, 0xca, 0xc9, 0x8f, 0xaa, 0xbe, 0x03, 0x46, 0x33, 0x63, 0x9a, 0x57, + 0x90, 0x86, 0x8d, 0x1b, 0x97, 0xc2, 0xbd, 0xa8, 0xf5, 0xed, 0x93, 0x33, 0x53, 0x3b, 0x3d, 0x33, + 0xb5, 0x1f, 0x67, 0xa6, 0xf6, 0xf1, 0xdc, 0x2c, 0x9d, 0x9e, 0x9b, 0xa5, 0xef, 0xe7, 0x66, 0xe9, + 0xd5, 0x9a, 0xe7, 0xc7, 0x7b, 0xed, 0xa6, 0xe5, 0xd2, 0xc0, 0xde, 0xc1, 0x28, 0xb8, 0xf3, 0x44, + 0x7e, 0x30, 0x5d, 0x1a, 0x61, 0xfb, 0xa8, 0xf7, 0xad, 0x3e, 0x0e, 0x31, 0x6b, 0x96, 0xc5, 0x77, + 0xf3, 0xde, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8c, 0x2c, 0x49, 0xaf, 0xc8, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -577,6 +763,8 @@ const _ = grpc.SupportPackageIsVersion4 // // 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 { + AddNoFeeAccounts(ctx context.Context, in *MsgAddNoFeeAccounts, opts ...grpc.CallOption) (*MsgAddNoFeeAccountsResponse, error) + RemoveNoFeeAccounts(ctx context.Context, in *MsgRemoveNoFeeAccounts, opts ...grpc.CallOption) (*MsgRemoveNoFeeAccountsResponse, error) CreateDenom(ctx context.Context, in *MsgCreateDenom, opts ...grpc.CallOption) (*MsgCreateDenomResponse, error) Mint(ctx context.Context, in *MsgMint, opts ...grpc.CallOption) (*MsgMintResponse, error) Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) @@ -596,6 +784,24 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) AddNoFeeAccounts(ctx context.Context, in *MsgAddNoFeeAccounts, opts ...grpc.CallOption) (*MsgAddNoFeeAccountsResponse, error) { + out := new(MsgAddNoFeeAccountsResponse) + err := c.cc.Invoke(ctx, "/kujira.denom.Msg/AddNoFeeAccounts", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RemoveNoFeeAccounts(ctx context.Context, in *MsgRemoveNoFeeAccounts, opts ...grpc.CallOption) (*MsgRemoveNoFeeAccountsResponse, error) { + out := new(MsgRemoveNoFeeAccountsResponse) + err := c.cc.Invoke(ctx, "/kujira.denom.Msg/RemoveNoFeeAccounts", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) CreateDenom(ctx context.Context, in *MsgCreateDenom, opts ...grpc.CallOption) (*MsgCreateDenomResponse, error) { out := new(MsgCreateDenomResponse) err := c.cc.Invoke(ctx, "/kujira.denom.Msg/CreateDenom", in, out, opts...) @@ -643,6 +849,8 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts // MsgServer is the server API for Msg service. type MsgServer interface { + AddNoFeeAccounts(context.Context, *MsgAddNoFeeAccounts) (*MsgAddNoFeeAccountsResponse, error) + RemoveNoFeeAccounts(context.Context, *MsgRemoveNoFeeAccounts) (*MsgRemoveNoFeeAccountsResponse, error) CreateDenom(context.Context, *MsgCreateDenom) (*MsgCreateDenomResponse, error) Mint(context.Context, *MsgMint) (*MsgMintResponse, error) Burn(context.Context, *MsgBurn) (*MsgBurnResponse, error) @@ -658,6 +866,12 @@ type MsgServer interface { type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) AddNoFeeAccounts(ctx context.Context, req *MsgAddNoFeeAccounts) (*MsgAddNoFeeAccountsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddNoFeeAccounts not implemented") +} +func (*UnimplementedMsgServer) RemoveNoFeeAccounts(ctx context.Context, req *MsgRemoveNoFeeAccounts) (*MsgRemoveNoFeeAccountsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveNoFeeAccounts not implemented") +} func (*UnimplementedMsgServer) CreateDenom(ctx context.Context, req *MsgCreateDenom) (*MsgCreateDenomResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateDenom not implemented") } @@ -678,6 +892,42 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_AddNoFeeAccounts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAddNoFeeAccounts) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AddNoFeeAccounts(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kujira.denom.Msg/AddNoFeeAccounts", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AddNoFeeAccounts(ctx, req.(*MsgAddNoFeeAccounts)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RemoveNoFeeAccounts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRemoveNoFeeAccounts) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RemoveNoFeeAccounts(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kujira.denom.Msg/RemoveNoFeeAccounts", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RemoveNoFeeAccounts(ctx, req.(*MsgRemoveNoFeeAccounts)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_CreateDenom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgCreateDenom) if err := dec(in); err != nil { @@ -772,6 +1022,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "kujira.denom.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "AddNoFeeAccounts", + Handler: _Msg_AddNoFeeAccounts_Handler, + }, + { + MethodName: "RemoveNoFeeAccounts", + Handler: _Msg_RemoveNoFeeAccounts_Handler, + }, { MethodName: "CreateDenom", Handler: _Msg_CreateDenom_Handler, @@ -797,7 +1055,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "kujira/denom/tx.proto", } -func (m *MsgCreateDenom) Marshal() (dAtA []byte, err error) { +func (m *MsgAddNoFeeAccounts) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -807,34 +1065,36 @@ func (m *MsgCreateDenom) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateDenom) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAddNoFeeAccounts) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAddNoFeeAccounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Nonce) > 0 { - i -= len(m.Nonce) - copy(dAtA[i:], m.Nonce) - i = encodeVarintTx(dAtA, i, uint64(len(m.Nonce))) - i-- - dAtA[i] = 0x12 + if len(m.Accounts) > 0 { + for iNdEx := len(m.Accounts) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Accounts[iNdEx]) + copy(dAtA[i:], m.Accounts[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Accounts[iNdEx]))) + i-- + dAtA[i] = 0x12 + } } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgCreateDenomResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgAddNoFeeAccountsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -844,27 +1104,20 @@ func (m *MsgCreateDenomResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateDenomResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAddNoFeeAccountsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAddNoFeeAccountsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.NewTokenDenom) > 0 { - i -= len(m.NewTokenDenom) - copy(dAtA[i:], m.NewTokenDenom) - i = encodeVarintTx(dAtA, i, uint64(len(m.NewTokenDenom))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } -func (m *MsgMint) Marshal() (dAtA []byte, err error) { +func (m *MsgRemoveNoFeeAccounts) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -874,44 +1127,36 @@ func (m *MsgMint) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgMint) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRemoveNoFeeAccounts) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgMint) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRemoveNoFeeAccounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Recipient) > 0 { - i -= len(m.Recipient) - copy(dAtA[i:], m.Recipient) - i = encodeVarintTx(dAtA, i, uint64(len(m.Recipient))) - i-- - dAtA[i] = 0x1a - } - { - size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.Accounts) > 0 { + for iNdEx := len(m.Accounts) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Accounts[iNdEx]) + copy(dAtA[i:], m.Accounts[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Accounts[iNdEx]))) + i-- + dAtA[i] = 0x12 } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0x12 - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgMintResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgRemoveNoFeeAccountsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -921,12 +1166,12 @@ func (m *MsgMintResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgMintResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRemoveNoFeeAccountsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgMintResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRemoveNoFeeAccountsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -934,7 +1179,7 @@ func (m *MsgMintResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgBurn) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateDenom) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -944,26 +1189,23 @@ func (m *MsgBurn) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgBurn) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateDenom) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgBurn) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - { - size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + if len(m.Nonce) > 0 { + i -= len(m.Nonce) + copy(dAtA[i:], m.Nonce) + i = encodeVarintTx(dAtA, i, uint64(len(m.Nonce))) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 if len(m.Sender) > 0 { i -= len(m.Sender) copy(dAtA[i:], m.Sender) @@ -974,7 +1216,7 @@ func (m *MsgBurn) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgBurnResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateDenomResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -984,18 +1226,158 @@ func (m *MsgBurnResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgBurnResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateDenomResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgBurnResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - return len(dAtA) - i, nil -} + if len(m.NewTokenDenom) > 0 { + i -= len(m.NewTokenDenom) + copy(dAtA[i:], m.NewTokenDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.NewTokenDenom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgMint) 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 *MsgMint) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMint) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintTx(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + 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))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgMintResponse) 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 *MsgMintResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgBurn) 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 *MsgBurn) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBurn) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + 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))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgBurnResponse) 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 *MsgBurnResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBurnResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} func (m *MsgChangeAdmin) Marshal() (dAtA []byte, err error) { size := m.Size() @@ -1140,6 +1522,62 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *MsgAddNoFeeAccounts) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Accounts) > 0 { + for _, s := range m.Accounts { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgAddNoFeeAccountsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRemoveNoFeeAccounts) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Accounts) > 0 { + for _, s := range m.Accounts { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgRemoveNoFeeAccountsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgCreateDenom) Size() (n int) { if m == nil { return 0 @@ -1284,6 +1722,334 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *MsgAddNoFeeAccounts) 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: MsgAddNoFeeAccounts: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddNoFeeAccounts: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Accounts", 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.Accounts = append(m.Accounts, 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 *MsgAddNoFeeAccountsResponse) 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: MsgAddNoFeeAccountsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddNoFeeAccountsResponse: 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 *MsgRemoveNoFeeAccounts) 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: MsgRemoveNoFeeAccounts: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveNoFeeAccounts: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Accounts", 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.Accounts = append(m.Accounts, 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 *MsgRemoveNoFeeAccountsResponse) 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: MsgRemoveNoFeeAccountsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveNoFeeAccountsResponse: 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 *MsgCreateDenom) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/common_test.go b/x/oracle/common_test.go index fd53248e..b9d5f31a 100644 --- a/x/oracle/common_test.go +++ b/x/oracle/common_test.go @@ -24,7 +24,6 @@ var ( func setupWithSmallVotingPower(t *testing.T) (keeper.TestInput, types.MsgServer) { input := keeper.CreateTestInput(t) params := input.OracleKeeper.GetParams(input.Ctx) - params.VotePeriod = 1 params.SlashWindow = 100 input.OracleKeeper.SetParams(input.Ctx, params) h := keeper.NewMsgServerImpl(input.OracleKeeper) @@ -46,7 +45,6 @@ func setupWithSmallVotingPower(t *testing.T) (keeper.TestInput, types.MsgServer) func setup(t *testing.T) (keeper.TestInput, types.MsgServer) { input := keeper.CreateTestInput(t) params := input.OracleKeeper.GetParams(input.Ctx) - params.VotePeriod = 1 params.SlashWindow = 100 params.RequiredSymbols = []types.Symbol{ {Symbol: types.TestDenomA, Id: 1}, @@ -72,7 +70,6 @@ func setup(t *testing.T) (keeper.TestInput, types.MsgServer) { func setupVal5(t *testing.T) (keeper.TestInput, types.MsgServer) { input := keeper.CreateTestInput(t) params := input.OracleKeeper.GetParams(input.Ctx) - params.VotePeriod = 1 params.SlashWindow = 100 input.OracleKeeper.SetParams(input.Ctx, params) h := keeper.NewMsgServerImpl(input.OracleKeeper) diff --git a/x/oracle/keeper/keeper_test.go b/x/oracle/keeper/keeper_test.go index fdc84f9f..c9920af3 100644 --- a/x/oracle/keeper/keeper_test.go +++ b/x/oracle/keeper/keeper_test.go @@ -105,7 +105,6 @@ func TestParams(t *testing.T) { require.NotNil(t, params) // Test custom params setting - votePeriod := uint64(10) voteThreshold := math.LegacyNewDecWithPrec(70, 2) maxDeviation := math.LegacyNewDecWithPrec(1, 1) slashFraction := math.LegacyNewDecWithPrec(1, 2) @@ -118,7 +117,6 @@ func TestParams(t *testing.T) { // Should really test validateParams, but skipping because obvious newParams := types.Params{ - VotePeriod: votePeriod, VoteThreshold: voteThreshold, MaxDeviation: maxDeviation, RequiredSymbols: requiredSymbols, diff --git a/x/oracle/keeper/msg_server_test.go b/x/oracle/keeper/msg_server_test.go index 30bdacce..b4765e7b 100644 --- a/x/oracle/keeper/msg_server_test.go +++ b/x/oracle/keeper/msg_server_test.go @@ -19,7 +19,6 @@ var ( func setup(t *testing.T) (TestInput, types.MsgServer) { input := CreateTestInput(t) params := input.OracleKeeper.GetParams(input.Ctx) - params.VotePeriod = 1 params.SlashWindow = 100 input.OracleKeeper.SetParams(input.Ctx, params) msgServer := NewMsgServerImpl(input.OracleKeeper) diff --git a/x/oracle/keeper/params.go b/x/oracle/keeper/params.go index 93d18285..f81427ff 100644 --- a/x/oracle/keeper/params.go +++ b/x/oracle/keeper/params.go @@ -7,11 +7,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// VotePeriod returns the number of blocks during which voting takes place. -func (k Keeper) VotePeriod(ctx sdk.Context) (res uint64) { - return k.GetParams(ctx).VotePeriod -} - // VoteThreshold returns the minimum percentage of votes that must be received for a ballot to pass. func (k Keeper) VoteThreshold(ctx sdk.Context) (res math.LegacyDec) { return k.GetParams(ctx).VoteThreshold diff --git a/x/oracle/keeper/reward.go b/x/oracle/keeper/reward.go deleted file mode 100644 index bccbd377..00000000 --- a/x/oracle/keeper/reward.go +++ /dev/null @@ -1,81 +0,0 @@ -package keeper - -import ( - "cosmossdk.io/errors" - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/Team-Kujira/core/x/oracle/types" -) - -// RewardBallotWinners implements -// at the end of every VotePeriod, give out a portion of spread fees collected in the oracle reward pool -// -// to the oracle voters that voted faithfully. -func (k Keeper) RewardBallotWinners( - ctx sdk.Context, - votePeriod int64, - rewardDistributionWindow int64, - voteTargets []string, - ballotWinners map[string]types.Claim, -) error { - rewardDenoms := voteTargets - - // Sum weight of the claims - ballotPowerSum := int64(0) - for _, winner := range ballotWinners { - ballotPowerSum += winner.Weight - } - - // Exit if the ballot is empty - if ballotPowerSum == 0 { - return nil - } - - // The Reward distributionRatio = votePeriod/rewardDistributionWindow - distributionRatio := math.LegacyNewDec(votePeriod).QuoInt64(rewardDistributionWindow) - - var periodRewards sdk.DecCoins - for _, denom := range rewardDenoms { - rewardPool := k.GetRewardPool(ctx, denom) - - // return if there's no rewards to give out - if rewardPool.IsZero() { - continue - } - - periodRewards = periodRewards.Add(sdk.NewDecCoinFromDec( - denom, - math.LegacyNewDecFromInt(rewardPool.Amount).Mul(distributionRatio), - )) - } - - // Dole out rewards - var distributedReward sdk.Coins - for _, winner := range ballotWinners { - receiverVal, err := k.StakingKeeper.Validator(ctx, winner.Recipient) - if err != nil { - return err - } - - // Reflects contribution - rewardCoins, _ := periodRewards.MulDec(math.LegacyNewDec(winner.Weight).QuoInt64(ballotPowerSum)).TruncateDecimal() - - // In case absence of the validator, we just skip distribution - if receiverVal != nil && !rewardCoins.IsZero() { - err = k.distrKeeper.AllocateTokensToValidator(ctx, receiverVal, sdk.NewDecCoinsFromCoins(rewardCoins...)) - if err != nil { - return err - } - distributedReward = distributedReward.Add(rewardCoins...) - } - } - - // Move distributed reward to distribution module - err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, k.distrName, distributedReward) - if err != nil { - return errors.Wrap(err, "[oracle] Failed to send coins to distribution module") - } - - return nil -} diff --git a/x/oracle/keeper/slash.go b/x/oracle/keeper/slash.go index d76dfc28..4a3503a4 100644 --- a/x/oracle/keeper/slash.go +++ b/x/oracle/keeper/slash.go @@ -10,12 +10,7 @@ func (k Keeper) SlashAndResetMissCounters(ctx sdk.Context) { height := ctx.BlockHeight() distributionHeight := height - sdk.ValidatorUpdateDelay - 1 - // slash_window / vote_period - votePeriodsPerWindow := uint64( - math.LegacyNewDec(int64(k.SlashWindow(ctx))). - QuoInt64(int64(k.VotePeriod(ctx))). - TruncateInt64(), - ) + slashWindow := k.SlashWindow(ctx) minValidPerWindow := k.MinValidPerWindow(ctx) slashFraction := k.SlashFraction(ctx) powerReduction := k.StakingKeeper.PowerReduction(ctx) @@ -23,8 +18,8 @@ func (k Keeper) SlashAndResetMissCounters(ctx sdk.Context) { k.IterateMissCounters(ctx, func(operator sdk.ValAddress, missCounter uint64) bool { // Calculate valid vote rate; (SlashWindow - MissCounter)/SlashWindow validVoteRate := math.LegacyNewDecFromInt( - math.NewInt(int64(votePeriodsPerWindow - missCounter))). - QuoInt64(int64(votePeriodsPerWindow)) + math.NewInt(int64(slashWindow - missCounter))). + QuoInt64(int64(slashWindow)) // Penalize the validator whose the valid vote rate is smaller than min threshold if validVoteRate.LT(minValidPerWindow) { diff --git a/x/oracle/keeper/slash_test.go b/x/oracle/keeper/slash_test.go index 2443bbe5..051eef39 100644 --- a/x/oracle/keeper/slash_test.go +++ b/x/oracle/keeper/slash_test.go @@ -3,7 +3,6 @@ package keeper import ( "testing" - "cosmossdk.io/math" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" @@ -41,16 +40,13 @@ func TestSlashAndResetMissCounters(t *testing.T) { validatorI1, _ := input.StakingKeeper.Validator(ctx, addr) require.Equal(t, amt, validatorI1.GetBondedTokens()) - votePeriodsPerWindow := math.LegacyNewDec(int64(input.OracleKeeper.SlashWindow(input.Ctx))). - QuoInt64(int64(input.OracleKeeper.VotePeriod(input.Ctx))). - TruncateInt64() - + slashWindow := int64(input.OracleKeeper.SlashWindow(input.Ctx)) slashFraction := input.OracleKeeper.SlashFraction(input.Ctx) - minValidVotes := input.OracleKeeper.MinValidPerWindow(input.Ctx).MulInt64(votePeriodsPerWindow).TruncateInt64() + minValidVotes := input.OracleKeeper.MinValidPerWindow(input.Ctx).MulInt64(slashWindow).TruncateInt64() // Case 1, no slash input.OracleKeeper.SetMissCounter(input.Ctx, ValAddrs[0], - uint64(votePeriodsPerWindow-minValidVotes-1), + uint64(slashWindow-minValidVotes-1), ) input.OracleKeeper.SlashAndResetMissCounters(input.Ctx) input.StakingKeeper.EndBlocker(input.Ctx) @@ -59,7 +55,7 @@ func TestSlashAndResetMissCounters(t *testing.T) { require.Equal(t, amt, validator.GetBondedTokens()) // Case 2, slash - input.OracleKeeper.SetMissCounter(input.Ctx, ValAddrs[0], uint64(votePeriodsPerWindow-minValidVotes+1)) + input.OracleKeeper.SetMissCounter(input.Ctx, ValAddrs[0], uint64(slashWindow-minValidVotes+1)) input.OracleKeeper.SlashAndResetMissCounters(input.Ctx) validator, _ = input.StakingKeeper.GetValidator(input.Ctx, ValAddrs[0]) require.Equal(t, amt.Sub(slashFraction.MulInt(amt).TruncateInt()), validator.GetBondedTokens()) @@ -72,7 +68,7 @@ func TestSlashAndResetMissCounters(t *testing.T) { validator.Tokens = amt input.StakingKeeper.SetValidator(input.Ctx, validator) - input.OracleKeeper.SetMissCounter(input.Ctx, ValAddrs[0], uint64(votePeriodsPerWindow-minValidVotes+1)) + input.OracleKeeper.SetMissCounter(input.Ctx, ValAddrs[0], uint64(slashWindow-minValidVotes+1)) input.OracleKeeper.SlashAndResetMissCounters(input.Ctx) validator, _ = input.StakingKeeper.GetValidator(input.Ctx, ValAddrs[0]) require.Equal(t, amt, validator.Tokens) @@ -85,7 +81,7 @@ func TestSlashAndResetMissCounters(t *testing.T) { validator.Tokens = amt input.StakingKeeper.SetValidator(input.Ctx, validator) - input.OracleKeeper.SetMissCounter(input.Ctx, ValAddrs[0], uint64(votePeriodsPerWindow-minValidVotes+1)) + input.OracleKeeper.SetMissCounter(input.Ctx, ValAddrs[0], uint64(slashWindow-minValidVotes+1)) input.OracleKeeper.SlashAndResetMissCounters(input.Ctx) validator, _ = input.StakingKeeper.GetValidator(input.Ctx, ValAddrs[0]) require.Equal(t, amt, validator.Tokens) diff --git a/x/oracle/migrations/v1/migrate.go b/x/oracle/migrations/v1/migrate.go index 041aa036..61882888 100644 --- a/x/oracle/migrations/v1/migrate.go +++ b/x/oracle/migrations/v1/migrate.go @@ -16,7 +16,6 @@ func MigrateParams( cdc codec.BinaryCodec, ) error { var ( - votePeriod uint64 voteThreshold math.LegacyDec rewardBand math.LegacyDec whitelist oracletypes.DenomList @@ -25,7 +24,6 @@ func MigrateParams( minValidPerWindow math.LegacyDec ) - subspace.Get(ctx, []byte("VotePeriod"), &votePeriod) subspace.Get(ctx, []byte("VoteThreshold"), &voteThreshold) subspace.Get(ctx, []byte("RewardBand"), &rewardBand) subspace.Get(ctx, []byte("Whitelist"), &whitelist) @@ -42,10 +40,10 @@ func MigrateParams( } oracleParams := oracletypes.Params{ - VotePeriod: votePeriod, VoteThreshold: voteThreshold, MaxDeviation: rewardBand, RequiredSymbols: symbols, + LastSymbolId: uint32(len(symbols)), SlashFraction: slashFraction, SlashWindow: slashWindow, MinValidPerWindow: minValidPerWindow, diff --git a/x/oracle/simulation/genesis.go b/x/oracle/simulation/genesis.go index 7e062743..75441ec7 100644 --- a/x/oracle/simulation/genesis.go +++ b/x/oracle/simulation/genesis.go @@ -99,7 +99,6 @@ func RandomizedGenState(simState *module.SimulationState) { oracleGenesis := types.NewGenesisState( types.Params{ - VotePeriod: votePeriod, VoteThreshold: voteThreshold, MaxDeviation: maxDeviation, RequiredSymbols: []types.Symbol{}, diff --git a/x/oracle/simulation/params.go b/x/oracle/simulation/params.go index 0b077c09..2568e4f8 100644 --- a/x/oracle/simulation/params.go +++ b/x/oracle/simulation/params.go @@ -16,11 +16,6 @@ import ( // on the simulation func ParamChanges(_ *rand.Rand) []simtypes.LegacyParamChange { return []simtypes.LegacyParamChange{ - simulation.NewSimLegacyParamChange(types.ModuleName, string(types.KeyVotePeriod), - func(r *rand.Rand) string { - return fmt.Sprintf("\"%d\"", GenVotePeriod(r)) - }, - ), simulation.NewSimLegacyParamChange(types.ModuleName, string(types.KeyVoteThreshold), func(r *rand.Rand) string { return fmt.Sprintf("\"%s\"", GenVoteThreshold(r)) diff --git a/x/oracle/types/genesis_test.go b/x/oracle/types/genesis_test.go index 73e9648e..2ac99221 100644 --- a/x/oracle/types/genesis_test.go +++ b/x/oracle/types/genesis_test.go @@ -13,7 +13,7 @@ func TestGenesisValidation(t *testing.T) { genState := types.DefaultGenesisState() require.NoError(t, types.ValidateGenesis(genState)) - genState.Params.VotePeriod = 0 + genState.Params.SlashWindow = 0 require.Error(t, types.ValidateGenesis(genState)) } diff --git a/x/oracle/types/oracle.pb.go b/x/oracle/types/oracle.pb.go index 42465b3e..25ce794c 100644 --- a/x/oracle/types/oracle.pb.go +++ b/x/oracle/types/oracle.pb.go @@ -27,14 +27,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the oracle module. type Params struct { - VotePeriod uint64 `protobuf:"varint,1,opt,name=vote_period,json=votePeriod,proto3" json:"vote_period,omitempty" yaml:"vote_period"` - VoteThreshold cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=vote_threshold,json=voteThreshold,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"vote_threshold" yaml:"vote_threshold"` - MaxDeviation cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=max_deviation,json=maxDeviation,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"max_deviation" yaml:"max_deviation"` - RequiredSymbols []Symbol `protobuf:"bytes,4,rep,name=required_symbols,json=requiredSymbols,proto3" json:"required_symbols" yaml:"required_symbols"` - LastSymbolId uint32 `protobuf:"varint,5,opt,name=last_symbol_id,json=lastSymbolId,proto3" json:"last_symbol_id,omitempty"` - SlashFraction cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=slash_fraction,json=slashFraction,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"slash_fraction" yaml:"slash_fraction"` - SlashWindow uint64 `protobuf:"varint,7,opt,name=slash_window,json=slashWindow,proto3" json:"slash_window,omitempty" yaml:"slash_window"` - MinValidPerWindow cosmossdk_io_math.LegacyDec `protobuf:"bytes,8,opt,name=min_valid_per_window,json=minValidPerWindow,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_valid_per_window" yaml:"min_valid_per_window"` + VoteThreshold cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=vote_threshold,json=voteThreshold,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"vote_threshold" yaml:"vote_threshold"` + MaxDeviation cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=max_deviation,json=maxDeviation,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"max_deviation" yaml:"max_deviation"` + RequiredSymbols []Symbol `protobuf:"bytes,3,rep,name=required_symbols,json=requiredSymbols,proto3" json:"required_symbols" yaml:"required_symbols"` + LastSymbolId uint32 `protobuf:"varint,4,opt,name=last_symbol_id,json=lastSymbolId,proto3" json:"last_symbol_id,omitempty"` + SlashFraction cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=slash_fraction,json=slashFraction,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"slash_fraction" yaml:"slash_fraction"` + SlashWindow uint64 `protobuf:"varint,6,opt,name=slash_window,json=slashWindow,proto3" json:"slash_window,omitempty" yaml:"slash_window"` + MinValidPerWindow cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=min_valid_per_window,json=minValidPerWindow,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_valid_per_window" yaml:"min_valid_per_window"` } func (m *Params) Reset() { *m = Params{} } @@ -69,13 +68,6 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetVotePeriod() uint64 { - if m != nil { - return m.VotePeriod - } - return 0 -} - func (m *Params) GetRequiredSymbols() []Symbol { if m != nil { return m.RequiredSymbols @@ -274,52 +266,50 @@ func init() { func init() { proto.RegisterFile("kujira/oracle/oracle.proto", fileDescriptor_8fffe8fb5ee63325) } var fileDescriptor_8fffe8fb5ee63325 = []byte{ - // 712 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x4d, 0x6f, 0xd3, 0x4a, - 0x14, 0x8d, 0x93, 0x26, 0xaf, 0x9d, 0xc4, 0xfd, 0x98, 0x97, 0xb6, 0x51, 0x2a, 0xc5, 0x91, 0xdf, - 0x5b, 0x04, 0x24, 0x6c, 0x15, 0x16, 0x40, 0x40, 0x08, 0x45, 0x29, 0x12, 0x82, 0x45, 0x34, 0x54, - 0x45, 0x62, 0x93, 0x4e, 0xec, 0x21, 0x1e, 0x6a, 0x7b, 0x82, 0x67, 0x92, 0x26, 0xff, 0x80, 0x25, - 0x4b, 0x96, 0x5d, 0xb0, 0x46, 0xe2, 0x5f, 0x74, 0xd9, 0x25, 0x62, 0x61, 0xa1, 0x76, 0xc3, 0x3a, - 0xbf, 0x00, 0x79, 0xc6, 0xa9, 0x92, 0x88, 0x45, 0x61, 0x15, 0x9f, 0x73, 0xef, 0x39, 0xf7, 0xce, - 0x9d, 0x9b, 0x01, 0xd5, 0x93, 0xe1, 0x3b, 0x1a, 0x61, 0x9b, 0x45, 0xd8, 0xf1, 0x49, 0xfa, 0x63, - 0x0d, 0x22, 0x26, 0x18, 0xd4, 0x55, 0xcc, 0x52, 0x64, 0xb5, 0xdc, 0x67, 0x7d, 0x26, 0x23, 0x76, - 0xf2, 0xa5, 0x92, 0xaa, 0x35, 0x87, 0xf1, 0x80, 0x71, 0xbb, 0x87, 0x39, 0xb1, 0x47, 0xfb, 0x3d, - 0x22, 0xf0, 0xbe, 0xed, 0x30, 0x1a, 0xaa, 0xb8, 0xf9, 0x35, 0x0f, 0x0a, 0x1d, 0x1c, 0xe1, 0x80, - 0xc3, 0xfb, 0xa0, 0x38, 0x62, 0x82, 0x74, 0x07, 0x24, 0xa2, 0xcc, 0xad, 0x68, 0x75, 0xad, 0xb1, - 0xd2, 0xda, 0x99, 0xc6, 0x06, 0x9c, 0xe0, 0xc0, 0x6f, 0x9a, 0x73, 0x41, 0x13, 0x81, 0x04, 0x75, - 0x24, 0x80, 0x0e, 0x58, 0x97, 0x31, 0xe1, 0x45, 0x84, 0x7b, 0xcc, 0x77, 0x2b, 0xd9, 0xba, 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 0x01, 0x05, 0x8f, 0xd0, - 0xbe, 0x27, 0x64, 0xb3, 0x39, 0x94, 0x22, 0xf8, 0x14, 0x14, 0x06, 0x11, 0x75, 0x08, 0xaf, 0x64, - 0xe5, 0xd6, 0x37, 0x96, 0xb6, 0x7e, 0xc1, 0xc5, 0xea, 0xc8, 0xd4, 0x83, 0x50, 0x44, 0x13, 0x94, - 0xea, 0xaa, 0x0f, 0x41, 0x71, 0x8e, 0x86, 0x9b, 0x20, 0x77, 0x42, 0x26, 0xb2, 0x8a, 0x8e, 0x92, - 0x4f, 0x58, 0x06, 0xf9, 0x11, 0xf6, 0x87, 0xea, 0xd0, 0x25, 0xa4, 0x40, 0x33, 0xfb, 0x40, 0x6b, - 0xb5, 0xcf, 0x2f, 0x6b, 0xda, 0xc5, 0x65, 0x4d, 0xfb, 0x71, 0x59, 0xd3, 0x3e, 0x5e, 0xd5, 0x32, - 0x17, 0x57, 0xb5, 0xcc, 0xb7, 0xab, 0x5a, 0xe6, 0xcd, 0xed, 0x3e, 0x15, 0xde, 0xb0, 0x67, 0x39, - 0x2c, 0xb0, 0x0f, 0x09, 0x0e, 0xee, 0xbc, 0x50, 0x4f, 0xa2, 0xc3, 0x22, 0x62, 0x8f, 0x67, 0x2f, - 0xa3, 0x98, 0x0c, 0x08, 0xef, 0x15, 0xe4, 0xa3, 0x76, 0xef, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x72, 0xfb, 0xac, 0x6d, 0x37, 0x05, 0x00, 0x00, + // 681 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xbf, 0x6f, 0xd3, 0x4c, + 0x18, 0x8e, 0x93, 0x34, 0xdf, 0xf7, 0x5d, 0xe2, 0xfe, 0xf0, 0x97, 0xb6, 0x51, 0x2a, 0xc5, 0x91, + 0x61, 0x08, 0x48, 0xd8, 0x2a, 0x2c, 0x10, 0x10, 0x42, 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0x8e, 0x61, 0x22, 0xab, 0xe8, + 0x38, 0xfd, 0x35, 0xaa, 0x68, 0x65, 0x44, 0xc2, 0xa1, 0x3a, 0x74, 0x05, 0x2b, 0xd0, 0xce, 0x3f, + 0xd4, 0x3a, 0xdd, 0xb3, 0x8b, 0x86, 0x76, 0x7e, 0xd1, 0xd0, 0x7e, 0x5c, 0x34, 0xb4, 0x4f, 0x97, + 0x8d, 0xdc, 0xf9, 0x65, 0x23, 0xf7, 0xed, 0xb2, 0x91, 0x7b, 0x7b, 0xb7, 0x4f, 0x45, 0x30, 0xec, + 0xd9, 0x1e, 0x8b, 0x9c, 0x03, 0x20, 0xd1, 0xbd, 0x97, 0xea, 0x65, 0xf3, 0x58, 0x02, 0xce, 0x78, + 0xfe, 0xc0, 0x89, 0xc9, 0x00, 0x78, 0xaf, 0x24, 0xdf, 0xa6, 0x07, 0xbf, 0x03, 0x00, 0x00, 0xff, + 0xff, 0x05, 0x9f, 0x62, 0x76, 0xfe, 0x04, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -341,9 +331,6 @@ func (this *Params) Equal(that interface{}) bool { } else if this == nil { return false } - if this.VotePeriod != that1.VotePeriod { - return false - } if !this.VoteThreshold.Equal(that1.VoteThreshold) { return false } @@ -401,11 +388,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintOracle(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x3a if m.SlashWindow != 0 { i = encodeVarintOracle(dAtA, i, uint64(m.SlashWindow)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x30 } { size := m.SlashFraction.Size() @@ -416,11 +403,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintOracle(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x2a if m.LastSymbolId != 0 { i = encodeVarintOracle(dAtA, i, uint64(m.LastSymbolId)) i-- - dAtA[i] = 0x28 + dAtA[i] = 0x20 } if len(m.RequiredSymbols) > 0 { for iNdEx := len(m.RequiredSymbols) - 1; iNdEx >= 0; iNdEx-- { @@ -433,7 +420,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintOracle(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } } { @@ -445,7 +432,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintOracle(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 { size := m.VoteThreshold.Size() i -= size @@ -455,12 +442,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintOracle(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 - if m.VotePeriod != 0 { - i = encodeVarintOracle(dAtA, i, uint64(m.VotePeriod)) - i-- - dAtA[i] = 0x8 - } + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -633,9 +615,6 @@ func (m *Params) Size() (n int) { } var l int _ = l - if m.VotePeriod != 0 { - n += 1 + sovOracle(uint64(m.VotePeriod)) - } l = m.VoteThreshold.Size() n += 1 + l + sovOracle(uint64(l)) l = m.MaxDeviation.Size() @@ -763,25 +742,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field VotePeriod", wireType) - } - m.VotePeriod = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowOracle - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.VotePeriod |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field VoteThreshold", wireType) } @@ -815,7 +775,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MaxDeviation", wireType) } @@ -849,7 +809,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RequiredSymbols", wireType) } @@ -883,7 +843,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field LastSymbolId", wireType) } @@ -902,7 +862,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 6: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SlashFraction", wireType) } @@ -936,7 +896,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field SlashWindow", wireType) } @@ -955,7 +915,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 8: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinValidPerWindow", wireType) } diff --git a/x/oracle/types/params.go b/x/oracle/types/params.go index 8659f1a8..6c628788 100644 --- a/x/oracle/types/params.go +++ b/x/oracle/types/params.go @@ -11,7 +11,6 @@ import ( // Parameter keys var ( - KeyVotePeriod = []byte("VotePeriod") KeyVoteThreshold = []byte("VoteThreshold") KeyMaxDeviation = []byte("MaxDeviation") KeyRequiredSymbols = []byte("RequiredSymbols") @@ -25,7 +24,6 @@ var ( // Default parameter values const ( - DefaultVotePeriod = uint64(14) // 30 seconds DefaultSlashWindow = uint64(274000) // window for a week DefaultRewardDistributionWindow = uint64(14250000) // window for a year ) @@ -44,7 +42,6 @@ var _ paramstypes.ParamSet = &Params{} // DefaultParams creates default oracle module parameters func DefaultParams() Params { return Params{ - VotePeriod: DefaultVotePeriod, VoteThreshold: DefaultVoteThreshold, MaxDeviation: DefaultMaxDeviation, RequiredSymbols: DefaultRequiredSymbols, @@ -65,7 +62,6 @@ func (p *Params) ParamSetPairs() paramstypes.ParamSetPairs { rewardBand := math.LegacyDec{} whitelist := DenomList{} return paramstypes.ParamSetPairs{ - paramstypes.NewParamSetPair(KeyVotePeriod, &p.VotePeriod, validateVotePeriod), paramstypes.NewParamSetPair(KeyVoteThreshold, &p.VoteThreshold, validateVoteThreshold), paramstypes.NewParamSetPair(KeyMaxDeviation, &p.MaxDeviation, validateMaxDeviation), paramstypes.NewParamSetPair(KeyRequiredSymbols, &p.RequiredSymbols, validateRequiredSymbols), @@ -85,9 +81,6 @@ func (p Params) String() string { // Validate performs basic validation on oracle parameters. func (p Params) Validate() error { - if p.VotePeriod == 0 { - return fmt.Errorf("oracle parameter VotePeriod must be > 0, is %d", p.VotePeriod) - } if p.VoteThreshold.LTE(math.LegacyNewDecWithPrec(33, 2)) { return fmt.Errorf("oracle parameter VoteThreshold must be greater than 33 percent") } @@ -100,8 +93,8 @@ func (p Params) Validate() error { return fmt.Errorf("oracle parameter SlashFraction must be between [0, 1]") } - if p.SlashWindow < p.VotePeriod { - return fmt.Errorf("oracle parameter SlashWindow must be greater than or equal with VotePeriod") + if p.SlashWindow == 0 { + return fmt.Errorf("oracle parameter SlashWindow must be positive") } if p.MinValidPerWindow.GT(math.LegacyOneDec()) || p.MinValidPerWindow.IsNegative() { @@ -115,19 +108,6 @@ func (p Params) Validate() error { return nil } -func validateVotePeriod(i interface{}) error { - v, ok := i.(uint64) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v == 0 { - return fmt.Errorf("vote period must be positive: %d", v) - } - - return nil -} - func validateVoteThreshold(i interface{}) error { v, ok := i.(math.LegacyDec) if !ok { diff --git a/x/oracle/types/params_test.go b/x/oracle/types/params_test.go index 6aa84b76..71b00aa4 100644 --- a/x/oracle/types/params_test.go +++ b/x/oracle/types/params_test.go @@ -15,11 +15,6 @@ func TestParamsEqual(t *testing.T) { err := p1.Validate() require.NoError(t, err) - // minus vote period - p1.VotePeriod = 0 - err = p1.Validate() - require.Error(t, err) - // small vote threshold p2 := types.DefaultParams() p2.VoteThreshold = math.LegacyZeroDec() @@ -60,11 +55,6 @@ func TestValidate(t *testing.T) { pairs := p1.ParamSetPairs() for _, pair := range pairs { switch { - case bytes.Equal(types.KeyVotePeriod, pair.Key) || - bytes.Equal(types.KeySlashWindow, pair.Key): - require.NoError(t, pair.ValidatorFn(uint64(1))) - require.Error(t, pair.ValidatorFn("invalid")) - require.Error(t, pair.ValidatorFn(uint64(0))) case bytes.Equal(types.KeyVoteThreshold, pair.Key): require.NoError(t, pair.ValidatorFn(math.LegacyNewDecWithPrec(33, 2))) require.Error(t, pair.ValidatorFn("invalid"))