From fa102f675ac30bec59ebff7939636e54405bf53a Mon Sep 17 00:00:00 2001 From: pharr117 Date: Sun, 21 May 2023 19:27:23 -0400 Subject: [PATCH 1/3] Add the following: * Proto definitions for tendermint liquidity message types and service * Script and autogenerated code using for Liquidity messages * Filled out Liquidity message interface * Inclusion of Tendermint liquidity messages in base application codec * Extension to main.go proof of concept code --- buf.work.yaml | 4 + .../liquidity/x/liquidity/types/codecs.go | 48 + .../liquidity/x/liquidity/types/msgs.go | 150 ++ .../liquidity/x/liquidity/types/tx.pb.go | 2051 +++++++++++++++++ client/encoding.go | 5 + main.go | 21 +- proto/README.md | 40 + proto/buf.gen.gogo.yaml | 8 + proto/buf.lock | 7 + proto/buf.yaml | 5 + proto/tendermint/liquidity/v1beta1/tx.proto | 146 ++ protocgen.sh | 14 + .../proto/cosmos/base/v1beta1/coin.proto | 40 + third_party/proto/cosmos/msg/v1/msg.proto | 30 + 14 files changed, 2564 insertions(+), 5 deletions(-) create mode 100644 buf.work.yaml create mode 100644 client/codec/tendermint/liquidity/x/liquidity/types/codecs.go create mode 100644 client/codec/tendermint/liquidity/x/liquidity/types/msgs.go create mode 100644 client/codec/tendermint/liquidity/x/liquidity/types/tx.pb.go create mode 100644 proto/README.md create mode 100644 proto/buf.gen.gogo.yaml create mode 100644 proto/buf.lock create mode 100644 proto/buf.yaml create mode 100644 proto/tendermint/liquidity/v1beta1/tx.proto create mode 100755 protocgen.sh create mode 100644 third_party/proto/cosmos/base/v1beta1/coin.proto create mode 100644 third_party/proto/cosmos/msg/v1/msg.proto diff --git a/buf.work.yaml b/buf.work.yaml new file mode 100644 index 0000000..d3ed9b5 --- /dev/null +++ b/buf.work.yaml @@ -0,0 +1,4 @@ +version: v1 +directories: + - proto + - third_party/proto \ No newline at end of file diff --git a/client/codec/tendermint/liquidity/x/liquidity/types/codecs.go b/client/codec/tendermint/liquidity/x/liquidity/types/codecs.go new file mode 100644 index 0000000..b227b0f --- /dev/null +++ b/client/codec/tendermint/liquidity/x/liquidity/types/codecs.go @@ -0,0 +1,48 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterLegacyAminoCodec registers concrete types on the codec. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgCreatePool{}, "liquidity/MsgCreatePool", nil) + cdc.RegisterConcrete(&MsgDepositWithinBatch{}, "liquidity/MsgDepositWithinBatch", nil) + cdc.RegisterConcrete(&MsgWithdrawWithinBatch{}, "liquidity/MsgWithdrawWithinBatch", nil) + cdc.RegisterConcrete(&MsgSwapWithinBatch{}, "liquidity/MsgSwapWithinBatch", nil) +} + +// RegisterInterfaces registers the x/liquidity interface types with the +// interface registry +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgCreatePool{}, + &MsgDepositWithinBatch{}, + &MsgWithdrawWithinBatch{}, + &MsgSwapWithinBatch{}, + ) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +// legacy amino codecs +var ( + amino = codec.NewLegacyAmino() + + // ModuleCdc references the global x/liquidity module codec. Note, the + // codec should ONLY be used in certain instances of tests and for JSON + // encoding as Amino is still used for that purpose. + // + // The actual codec used for serialization should be provided to x/liquidity + // and defined at the application level. + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + amino.Seal() +} diff --git a/client/codec/tendermint/liquidity/x/liquidity/types/msgs.go b/client/codec/tendermint/liquidity/x/liquidity/types/msgs.go new file mode 100644 index 0000000..fcecf19 --- /dev/null +++ b/client/codec/tendermint/liquidity/x/liquidity/types/msgs.go @@ -0,0 +1,150 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + _ sdk.Msg = (*MsgCreatePool)(nil) + _ sdk.Msg = (*MsgDepositWithinBatch)(nil) + _ sdk.Msg = (*MsgWithdrawWithinBatch)(nil) + _ sdk.Msg = (*MsgSwapWithinBatch)(nil) +) + +// Message types for the liquidity module +const ( + TypeMsgCreatePool = "create_pool" + TypeMsgDepositWithinBatch = "deposit_within_batch" + TypeMsgWithdrawWithinBatch = "withdraw_within_batch" + TypeMsgSwapWithinBatch = "swap_within_batch" +) + +func (msg MsgCreatePool) Route() string { return "" } + +func (msg MsgCreatePool) Type() string { return TypeMsgCreatePool } + +func (msg MsgCreatePool) ValidateBasic() error { + return nil +} + +func (msg MsgCreatePool) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgCreatePool) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.PoolCreatorAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +func (msg MsgCreatePool) GetPoolCreator() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.PoolCreatorAddress) + if err != nil { + panic(err) + } + return addr +} + +// NewMsgDepositWithinBatch creates a new MsgDepositWithinBatch. +func NewMsgDepositWithinBatch(depositor sdk.AccAddress, poolID uint64, depositCoins sdk.Coins) *MsgDepositWithinBatch { + return &MsgDepositWithinBatch{ + DepositorAddress: depositor.String(), + PoolId: poolID, + DepositCoins: depositCoins, + } +} + +func (msg MsgDepositWithinBatch) Route() string { return "" } + +func (msg MsgDepositWithinBatch) Type() string { return TypeMsgDepositWithinBatch } + +func (msg MsgDepositWithinBatch) ValidateBasic() error { + return nil +} + +func (msg MsgDepositWithinBatch) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgDepositWithinBatch) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.DepositorAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +func (msg MsgDepositWithinBatch) GetDepositor() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.DepositorAddress) + if err != nil { + panic(err) + } + return addr +} + +// NewMsgWithdrawWithinBatch creates a new MsgWithdrawWithinBatch. +func NewMsgWithdrawWithinBatch(withdrawer sdk.AccAddress, poolID uint64, poolCoin sdk.Coin) *MsgWithdrawWithinBatch { + return &MsgWithdrawWithinBatch{ + WithdrawerAddress: withdrawer.String(), + PoolId: poolID, + PoolCoin: poolCoin, + } +} + +func (msg MsgWithdrawWithinBatch) Route() string { return "" } + +func (msg MsgWithdrawWithinBatch) Type() string { return TypeMsgWithdrawWithinBatch } + +func (msg MsgWithdrawWithinBatch) ValidateBasic() error { + return nil +} + +func (msg MsgWithdrawWithinBatch) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgWithdrawWithinBatch) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.WithdrawerAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +func (msg MsgWithdrawWithinBatch) GetWithdrawer() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.WithdrawerAddress) + if err != nil { + panic(err) + } + return addr +} + +func (msg MsgSwapWithinBatch) Route() string { return "" } + +func (msg MsgSwapWithinBatch) Type() string { return TypeMsgSwapWithinBatch } + +func (msg MsgSwapWithinBatch) ValidateBasic() error { + return nil +} + +func (msg MsgSwapWithinBatch) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgSwapWithinBatch) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.SwapRequesterAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +func (msg MsgSwapWithinBatch) GetSwapRequester() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.SwapRequesterAddress) + if err != nil { + panic(err) + } + return addr +} diff --git a/client/codec/tendermint/liquidity/x/liquidity/types/tx.pb.go b/client/codec/tendermint/liquidity/x/liquidity/types/tx.pb.go new file mode 100644 index 0000000..74c070f --- /dev/null +++ b/client/codec/tendermint/liquidity/x/liquidity/types/tx.pb.go @@ -0,0 +1,2051 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: tendermint/liquidity/v1beta1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgCreatePool defines an sdk.Msg type that supports submitting a create liquidity pool tx. +// +// See: https://github.com/tendermint/liquidity/blob/develop/x/liquidity/spec/04_messages.md +type MsgCreatePool struct { + PoolCreatorAddress string `protobuf:"bytes,1,opt,name=pool_creator_address,json=poolCreatorAddress,proto3" json:"pool_creator_address,omitempty" yaml:"pool_creator_address"` + // id of the target pool type, must match the value in the pool. Only pool-type-id 1 is supported. + PoolTypeId uint32 `protobuf:"varint,2,opt,name=pool_type_id,json=poolTypeId,proto3" json:"pool_type_id,omitempty" yaml:"pool_type_id"` + // reserve coin pair of the pool to deposit. + DepositCoins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=deposit_coins,json=depositCoins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"deposit_coins" yaml:"deposit_coins"` +} + +func (m *MsgCreatePool) Reset() { *m = MsgCreatePool{} } +func (m *MsgCreatePool) String() string { return proto.CompactTextString(m) } +func (*MsgCreatePool) ProtoMessage() {} +func (*MsgCreatePool) Descriptor() ([]byte, []int) { + return fileDescriptor_deae1e5d4eb3529c, []int{0} +} +func (m *MsgCreatePool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreatePool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreatePool.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 *MsgCreatePool) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreatePool.Merge(m, src) +} +func (m *MsgCreatePool) XXX_Size() int { + return m.Size() +} +func (m *MsgCreatePool) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreatePool.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreatePool proto.InternalMessageInfo + +// MsgCreatePoolResponse defines the Msg/CreatePool response type. +type MsgCreatePoolResponse struct { +} + +func (m *MsgCreatePoolResponse) Reset() { *m = MsgCreatePoolResponse{} } +func (m *MsgCreatePoolResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreatePoolResponse) ProtoMessage() {} +func (*MsgCreatePoolResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_deae1e5d4eb3529c, []int{1} +} +func (m *MsgCreatePoolResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreatePoolResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreatePoolResponse.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 *MsgCreatePoolResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreatePoolResponse.Merge(m, src) +} +func (m *MsgCreatePoolResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreatePoolResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreatePoolResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreatePoolResponse proto.InternalMessageInfo + +// `MsgDepositWithinBatch defines` an `sdk.Msg` type that supports submitting +// a deposit request to the batch of the liquidity pool. +// Deposit is submitted to the batch of the Liquidity pool with the specified +// `pool_id`, `deposit_coins` for reserve. +// This request is stacked in the batch of the liquidity pool, is not processed +// immediately, and is processed in the `endblock` at the same time as other requests. +// +// See: https://github.com/tendermint/liquidity/blob/develop/x/liquidity/spec/04_messages.md +type MsgDepositWithinBatch struct { + DepositorAddress string `protobuf:"bytes,1,opt,name=depositor_address,json=depositorAddress,proto3" json:"depositor_address,omitempty" yaml:"depositor_address"` + // id of the target pool + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id" yaml:"pool_id"` + // reserve coin pair of the pool to deposit + DepositCoins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=deposit_coins,json=depositCoins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"deposit_coins" yaml:"deposit_coins"` +} + +func (m *MsgDepositWithinBatch) Reset() { *m = MsgDepositWithinBatch{} } +func (m *MsgDepositWithinBatch) String() string { return proto.CompactTextString(m) } +func (*MsgDepositWithinBatch) ProtoMessage() {} +func (*MsgDepositWithinBatch) Descriptor() ([]byte, []int) { + return fileDescriptor_deae1e5d4eb3529c, []int{2} +} +func (m *MsgDepositWithinBatch) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDepositWithinBatch) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDepositWithinBatch.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 *MsgDepositWithinBatch) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDepositWithinBatch.Merge(m, src) +} +func (m *MsgDepositWithinBatch) XXX_Size() int { + return m.Size() +} +func (m *MsgDepositWithinBatch) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDepositWithinBatch.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDepositWithinBatch proto.InternalMessageInfo + +// MsgDepositWithinBatchResponse defines the Msg/DepositWithinBatch response type. +type MsgDepositWithinBatchResponse struct { +} + +func (m *MsgDepositWithinBatchResponse) Reset() { *m = MsgDepositWithinBatchResponse{} } +func (m *MsgDepositWithinBatchResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDepositWithinBatchResponse) ProtoMessage() {} +func (*MsgDepositWithinBatchResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_deae1e5d4eb3529c, []int{3} +} +func (m *MsgDepositWithinBatchResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDepositWithinBatchResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDepositWithinBatchResponse.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 *MsgDepositWithinBatchResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDepositWithinBatchResponse.Merge(m, src) +} +func (m *MsgDepositWithinBatchResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDepositWithinBatchResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDepositWithinBatchResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDepositWithinBatchResponse proto.InternalMessageInfo + +// `MsgWithdrawWithinBatch` defines an `sdk.Msg` type that supports submitting +// a withdraw request to the batch of the liquidity pool. +// Withdraw is submitted to the batch from the Liquidity pool with the +// specified `pool_id`, `pool_coin` of the pool. +// This request is stacked in the batch of the liquidity pool, is not processed +// immediately, and is processed in the `endblock` at the same time as other requests. +// +// See: https://github.com/tendermint/liquidity/blob/develop/x/liquidity/spec/04_messages.md +type MsgWithdrawWithinBatch struct { + WithdrawerAddress string `protobuf:"bytes,1,opt,name=withdrawer_address,json=withdrawerAddress,proto3" json:"withdrawer_address,omitempty" yaml:"withdrawer_address"` + // id of the target pool + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id" yaml:"pool_id"` + PoolCoin types.Coin `protobuf:"bytes,3,opt,name=pool_coin,json=poolCoin,proto3" json:"pool_coin" yaml:"pool_coin"` +} + +func (m *MsgWithdrawWithinBatch) Reset() { *m = MsgWithdrawWithinBatch{} } +func (m *MsgWithdrawWithinBatch) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawWithinBatch) ProtoMessage() {} +func (*MsgWithdrawWithinBatch) Descriptor() ([]byte, []int) { + return fileDescriptor_deae1e5d4eb3529c, []int{4} +} +func (m *MsgWithdrawWithinBatch) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawWithinBatch) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawWithinBatch.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 *MsgWithdrawWithinBatch) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawWithinBatch.Merge(m, src) +} +func (m *MsgWithdrawWithinBatch) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawWithinBatch) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawWithinBatch.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawWithinBatch proto.InternalMessageInfo + +// MsgWithdrawWithinBatchResponse defines the Msg/WithdrawWithinBatch response type. +type MsgWithdrawWithinBatchResponse struct { +} + +func (m *MsgWithdrawWithinBatchResponse) Reset() { *m = MsgWithdrawWithinBatchResponse{} } +func (m *MsgWithdrawWithinBatchResponse) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawWithinBatchResponse) ProtoMessage() {} +func (*MsgWithdrawWithinBatchResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_deae1e5d4eb3529c, []int{5} +} +func (m *MsgWithdrawWithinBatchResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawWithinBatchResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawWithinBatchResponse.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 *MsgWithdrawWithinBatchResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawWithinBatchResponse.Merge(m, src) +} +func (m *MsgWithdrawWithinBatchResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawWithinBatchResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawWithinBatchResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawWithinBatchResponse proto.InternalMessageInfo + +// `MsgSwapWithinBatch` defines an sdk.Msg type that supports submitting a swap offer request to the batch of the liquidity pool. +// Submit swap offer to the liquidity pool batch with the specified the `pool_id`, `swap_type_id`, +// `demand_coin_denom` with the coin and the price you're offering +// and `offer_coin_fee` must be half of offer coin amount * current `params.swap_fee_rate` and ceil for reservation to pay fees. +// This request is stacked in the batch of the liquidity pool, is not processed +// immediately, and is processed in the `endblock` at the same time as other requests. +// You must request the same fields as the pool. +// Only the default `swap_type_id` 1 is supported. +// +// See: https://github.com/tendermint/liquidity/tree/develop/doc +// https://github.com/tendermint/liquidity/blob/develop/x/liquidity/spec/04_messages.md +type MsgSwapWithinBatch struct { + // address of swap requester + SwapRequesterAddress string `protobuf:"bytes,1,opt,name=swap_requester_address,json=swapRequesterAddress,proto3" json:"swap_requester_address,omitempty" yaml:"swap_requester_address"` + // id of swap type, must match the value in the pool. Only `swap_type_id` 1 is supported. + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id" yaml:"pool_id"` + // id of swap type. Must match the value in the pool. + SwapTypeId uint32 `protobuf:"varint,3,opt,name=swap_type_id,json=swapTypeId,proto3" json:"swap_type_id,omitempty" yaml:"swap_type_id"` + // offer sdk.coin for the swap request, must match the denom in the pool. + OfferCoin types.Coin `protobuf:"bytes,4,opt,name=offer_coin,json=offerCoin,proto3" json:"offer_coin" yaml:"offer_coin"` + // denom of demand coin to be exchanged on the swap request, must match the denom in the pool. + DemandCoinDenom string `protobuf:"bytes,5,opt,name=demand_coin_denom,json=demandCoinDenom,proto3" json:"demand_coin_denom,omitempty" yaml:"demand_coin_denom"` + // half of offer coin amount * params.swap_fee_rate and ceil for reservation to pay fees. + OfferCoinFee types.Coin `protobuf:"bytes,6,opt,name=offer_coin_fee,json=offerCoinFee,proto3" json:"offer_coin_fee" yaml:"offer_coin_fee"` + // limit order price for the order, the price is the exchange ratio of X/Y + // where X is the amount of the first coin and Y is the amount + // of the second coin when their denoms are sorted alphabetically. + OrderPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=order_price,json=orderPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"order_price" yaml:"order_price"` +} + +func (m *MsgSwapWithinBatch) Reset() { *m = MsgSwapWithinBatch{} } +func (m *MsgSwapWithinBatch) String() string { return proto.CompactTextString(m) } +func (*MsgSwapWithinBatch) ProtoMessage() {} +func (*MsgSwapWithinBatch) Descriptor() ([]byte, []int) { + return fileDescriptor_deae1e5d4eb3529c, []int{6} +} +func (m *MsgSwapWithinBatch) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSwapWithinBatch) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSwapWithinBatch.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 *MsgSwapWithinBatch) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSwapWithinBatch.Merge(m, src) +} +func (m *MsgSwapWithinBatch) XXX_Size() int { + return m.Size() +} +func (m *MsgSwapWithinBatch) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSwapWithinBatch.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSwapWithinBatch proto.InternalMessageInfo + +// MsgSwapWithinBatchResponse defines the Msg/Swap response type. +type MsgSwapWithinBatchResponse struct { +} + +func (m *MsgSwapWithinBatchResponse) Reset() { *m = MsgSwapWithinBatchResponse{} } +func (m *MsgSwapWithinBatchResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSwapWithinBatchResponse) ProtoMessage() {} +func (*MsgSwapWithinBatchResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_deae1e5d4eb3529c, []int{7} +} +func (m *MsgSwapWithinBatchResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSwapWithinBatchResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSwapWithinBatchResponse.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 *MsgSwapWithinBatchResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSwapWithinBatchResponse.Merge(m, src) +} +func (m *MsgSwapWithinBatchResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSwapWithinBatchResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSwapWithinBatchResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSwapWithinBatchResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgCreatePool)(nil), "tendermint.liquidity.v1beta1.MsgCreatePool") + proto.RegisterType((*MsgCreatePoolResponse)(nil), "tendermint.liquidity.v1beta1.MsgCreatePoolResponse") + proto.RegisterType((*MsgDepositWithinBatch)(nil), "tendermint.liquidity.v1beta1.MsgDepositWithinBatch") + proto.RegisterType((*MsgDepositWithinBatchResponse)(nil), "tendermint.liquidity.v1beta1.MsgDepositWithinBatchResponse") + proto.RegisterType((*MsgWithdrawWithinBatch)(nil), "tendermint.liquidity.v1beta1.MsgWithdrawWithinBatch") + proto.RegisterType((*MsgWithdrawWithinBatchResponse)(nil), "tendermint.liquidity.v1beta1.MsgWithdrawWithinBatchResponse") + proto.RegisterType((*MsgSwapWithinBatch)(nil), "tendermint.liquidity.v1beta1.MsgSwapWithinBatch") + proto.RegisterType((*MsgSwapWithinBatchResponse)(nil), "tendermint.liquidity.v1beta1.MsgSwapWithinBatchResponse") +} + +func init() { + proto.RegisterFile("tendermint/liquidity/v1beta1/tx.proto", fileDescriptor_deae1e5d4eb3529c) +} + +var fileDescriptor_deae1e5d4eb3529c = []byte{ + // 866 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x96, 0x4d, 0x8f, 0xdb, 0x44, + 0x18, 0xc7, 0xe3, 0x4d, 0xba, 0xed, 0x4e, 0xb3, 0xa5, 0x3b, 0x4d, 0xbb, 0x5e, 0xb3, 0xf1, 0x04, + 0x4b, 0xa0, 0x08, 0x84, 0xcd, 0xb6, 0x08, 0xd1, 0xc2, 0x85, 0x6c, 0x84, 0x5a, 0xa9, 0x91, 0x82, + 0x8b, 0x54, 0x89, 0x03, 0x96, 0x63, 0x4f, 0xbc, 0x03, 0x89, 0xc7, 0xf5, 0x78, 0x9b, 0xe6, 0xc6, + 0x05, 0x54, 0x6e, 0x7c, 0x84, 0x9e, 0xb9, 0x80, 0xf8, 0x14, 0x7b, 0xdc, 0x23, 0xe2, 0x60, 0xd0, + 0xee, 0x01, 0xc4, 0xd1, 0x47, 0x4e, 0x68, 0xfc, 0x16, 0x27, 0xb1, 0x36, 0xec, 0xee, 0x81, 0x93, + 0x67, 0x9e, 0x97, 0xff, 0x3c, 0xf3, 0xf3, 0xcc, 0x63, 0x83, 0x37, 0x03, 0xec, 0xda, 0xd8, 0x1f, + 0x13, 0x37, 0xd0, 0x46, 0xe4, 0xd9, 0x21, 0xb1, 0x49, 0x30, 0xd5, 0x9e, 0xef, 0x0d, 0x70, 0x60, + 0xee, 0x69, 0xc1, 0x0b, 0xd5, 0xf3, 0x69, 0x40, 0xe1, 0xee, 0x2c, 0x4c, 0xcd, 0xc3, 0xd4, 0x34, + 0x4c, 0x6a, 0x38, 0xd4, 0xa1, 0x71, 0xa0, 0xc6, 0x47, 0x49, 0x8e, 0x24, 0x5b, 0x94, 0x8d, 0x29, + 0xd3, 0x06, 0x26, 0xc3, 0xb9, 0xa2, 0x45, 0x89, 0x9b, 0xfa, 0xb7, 0x53, 0xff, 0x98, 0x39, 0xda, + 0xf3, 0x3d, 0xfe, 0x48, 0x1c, 0xca, 0x2f, 0x6b, 0x60, 0xb3, 0xc7, 0x9c, 0x7d, 0x1f, 0x9b, 0x01, + 0xee, 0x53, 0x3a, 0x82, 0x9f, 0x81, 0x86, 0x47, 0xe9, 0xc8, 0xb0, 0xb8, 0x89, 0xfa, 0x86, 0x69, + 0xdb, 0x3e, 0x66, 0x4c, 0x14, 0x5a, 0x42, 0x7b, 0xa3, 0x83, 0xa2, 0x10, 0xbd, 0x3e, 0x35, 0xc7, + 0xa3, 0x07, 0x4a, 0x59, 0x94, 0xa2, 0x43, 0x6e, 0xde, 0x4f, 0xac, 0x9f, 0x24, 0x46, 0x78, 0x1f, + 0xd4, 0xe3, 0xe0, 0x60, 0xea, 0x61, 0x83, 0xd8, 0xe2, 0x5a, 0x4b, 0x68, 0x6f, 0x76, 0xb6, 0xa3, + 0x10, 0xdd, 0x2a, 0x48, 0xa5, 0x5e, 0x45, 0x07, 0x7c, 0xfa, 0xf9, 0xd4, 0xc3, 0x8f, 0x6c, 0xf8, + 0x52, 0x00, 0x9b, 0x36, 0xf6, 0x28, 0x23, 0x81, 0xc1, 0xf7, 0xc3, 0xc4, 0x5a, 0xab, 0xda, 0xbe, + 0x7e, 0x77, 0x47, 0x4d, 0x76, 0xa4, 0xf2, 0x1d, 0x67, 0x70, 0xd4, 0x7d, 0x4a, 0xdc, 0xce, 0xc3, + 0xa3, 0x10, 0x55, 0xa2, 0x10, 0x35, 0x12, 0xed, 0xb9, 0x6c, 0xe5, 0xc7, 0xdf, 0x51, 0xdb, 0x21, + 0xc1, 0xc1, 0xe1, 0x40, 0xb5, 0xe8, 0x58, 0x4b, 0xb1, 0x24, 0x8f, 0x77, 0x99, 0xfd, 0xb5, 0xc6, + 0xab, 0x60, 0xb1, 0x10, 0xd3, 0xeb, 0x69, 0x6e, 0x3c, 0x7b, 0x70, 0xed, 0xe5, 0x2b, 0x54, 0xf9, + 0xeb, 0x15, 0xaa, 0x28, 0xdb, 0xe0, 0xf6, 0x1c, 0x33, 0x1d, 0x33, 0x8f, 0xba, 0x0c, 0x2b, 0x3f, + 0xad, 0xc5, 0x9e, 0x6e, 0x92, 0xf6, 0x94, 0x04, 0x07, 0xc4, 0xed, 0x98, 0x81, 0x75, 0x00, 0x1f, + 0x81, 0xad, 0x54, 0x6c, 0x09, 0xe9, 0x6e, 0x14, 0x22, 0x71, 0xae, 0xd6, 0x22, 0xcf, 0x9b, 0xb9, + 0x2d, 0xa3, 0xf9, 0x01, 0xb8, 0x1a, 0xf3, 0x4a, 0x41, 0xd6, 0x3a, 0xcd, 0xbf, 0x43, 0x94, 0x99, + 0xa2, 0x10, 0xdd, 0x28, 0x30, 0xe5, 0x38, 0xd7, 0xf9, 0xa8, 0x14, 0x65, 0xf5, 0xff, 0x47, 0x89, + 0x40, 0xb3, 0x14, 0x58, 0x8e, 0xf4, 0x1f, 0x01, 0xdc, 0xe9, 0x31, 0x87, 0xbb, 0x6c, 0xdf, 0x9c, + 0x14, 0x99, 0x3e, 0x06, 0x70, 0x92, 0x9a, 0xf1, 0x22, 0xd4, 0x66, 0x14, 0xa2, 0x9d, 0xa4, 0xea, + 0xe5, 0x18, 0x45, 0xdf, 0x9a, 0x19, 0x2f, 0x8b, 0xb5, 0x0f, 0x36, 0x92, 0x9b, 0x40, 0x89, 0x2b, + 0x56, 0x5b, 0xc2, 0xd9, 0x44, 0xc5, 0x94, 0xe8, 0xcd, 0xe2, 0x1d, 0xa2, 0xc4, 0x55, 0xf4, 0x6b, + 0xf1, 0xc5, 0xa1, 0xc4, 0x2d, 0xd0, 0x69, 0x01, 0xb9, 0x7c, 0xef, 0x39, 0x9e, 0xe3, 0x1a, 0x80, + 0x3d, 0xe6, 0x3c, 0x99, 0x98, 0x5e, 0x11, 0xcd, 0x53, 0x70, 0x87, 0x4d, 0x4c, 0xcf, 0xf0, 0xf1, + 0xb3, 0x43, 0xcc, 0x82, 0x25, 0x3c, 0x6f, 0x44, 0x21, 0x6a, 0x26, 0x25, 0x94, 0xc7, 0x29, 0x7a, + 0x83, 0x3b, 0xf4, 0xcc, 0x7e, 0x59, 0x4a, 0xf7, 0x41, 0x3d, 0x5e, 0x28, 0x6b, 0x01, 0xd5, 0xc5, + 0x16, 0x50, 0xf4, 0x2a, 0x3a, 0xe0, 0xd3, 0xb4, 0x05, 0x3c, 0x01, 0x80, 0x0e, 0x87, 0xd8, 0x4f, + 0x08, 0xd7, 0x56, 0x11, 0xde, 0x49, 0x09, 0x6f, 0x25, 0xba, 0xb3, 0x54, 0x45, 0xdf, 0x88, 0x27, + 0x3c, 0x0a, 0x3e, 0xe4, 0xf7, 0x71, 0x6c, 0xba, 0x76, 0xec, 0x32, 0x6c, 0xec, 0xd2, 0xb1, 0x78, + 0x65, 0xf9, 0x3e, 0x2e, 0x84, 0x28, 0xfa, 0x6b, 0x89, 0x8d, 0x8b, 0x74, 0xb9, 0x05, 0x7e, 0x09, + 0x6e, 0xcc, 0xd6, 0x30, 0x86, 0x18, 0x8b, 0xeb, 0xab, 0x4a, 0x6c, 0xa6, 0x25, 0xde, 0x5e, 0x2c, + 0x91, 0xa7, 0x2b, 0x7a, 0x3d, 0x2f, 0xf3, 0x53, 0x8c, 0x21, 0x06, 0xd7, 0xa9, 0x6f, 0x63, 0xdf, + 0xf0, 0x7c, 0x62, 0x61, 0xf1, 0x6a, 0x5c, 0x63, 0x97, 0x2b, 0xfc, 0x16, 0xa2, 0xb7, 0xfe, 0xc3, + 0x05, 0xec, 0x62, 0x2b, 0x0a, 0x11, 0x4c, 0xd7, 0x9a, 0x49, 0x29, 0x3a, 0x88, 0x67, 0x7d, 0x3e, + 0x29, 0x1c, 0xba, 0x5d, 0x20, 0x2d, 0x9f, 0xa8, 0xec, 0xc0, 0xdd, 0xfd, 0xb6, 0x06, 0xaa, 0x3d, + 0xe6, 0x40, 0x17, 0x80, 0xc2, 0x47, 0xe3, 0x1d, 0xf5, 0xac, 0x8f, 0x96, 0x3a, 0xd7, 0x2d, 0xa5, + 0x7b, 0xe7, 0x08, 0xce, 0xd6, 0x85, 0xdf, 0x09, 0x00, 0x96, 0xf4, 0xd5, 0xd5, 0x5a, 0xcb, 0x49, + 0xd2, 0x47, 0x17, 0x48, 0xca, 0x0b, 0xf9, 0x5e, 0x00, 0xb7, 0xca, 0xba, 0xd1, 0xfb, 0x2b, 0x45, + 0x4b, 0xb2, 0xa4, 0x8f, 0x2f, 0x92, 0x95, 0xd7, 0xe2, 0x83, 0x1a, 0x7f, 0x4f, 0xf0, 0xbd, 0x95, + 0x2a, 0x0b, 0xaf, 0x53, 0xfa, 0xf0, 0xbc, 0x19, 0xd9, 0x9a, 0xd2, 0x95, 0x6f, 0xfe, 0xfc, 0xf9, + 0x6d, 0xa1, 0xf3, 0xd5, 0xd1, 0x89, 0x2c, 0x1c, 0x9f, 0xc8, 0xc2, 0x1f, 0x27, 0xb2, 0xf0, 0xc3, + 0xa9, 0x5c, 0x39, 0x3e, 0x95, 0x2b, 0xbf, 0x9e, 0xca, 0x95, 0x2f, 0xfa, 0x85, 0x33, 0xd9, 0xc5, + 0x43, 0x62, 0xba, 0xc1, 0x63, 0x73, 0xc0, 0x34, 0xcf, 0xa7, 0x03, 0xac, 0x59, 0x23, 0x82, 0xdd, + 0x40, 0xb3, 0xa8, 0x8d, 0x2d, 0xad, 0xf4, 0x87, 0xe8, 0x45, 0x61, 0x1c, 0x9f, 0xe0, 0xc1, 0x7a, + 0xfc, 0xaf, 0x72, 0xef, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x67, 0x1a, 0xac, 0xb7, 0x41, 0x09, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // Submit a create liquidity pool message. + CreatePool(ctx context.Context, in *MsgCreatePool, opts ...grpc.CallOption) (*MsgCreatePoolResponse, error) + // Submit a deposit to the liquidity pool batch. + DepositWithinBatch(ctx context.Context, in *MsgDepositWithinBatch, opts ...grpc.CallOption) (*MsgDepositWithinBatchResponse, error) + // Submit a withdraw from the liquidity pool batch. + WithdrawWithinBatch(ctx context.Context, in *MsgWithdrawWithinBatch, opts ...grpc.CallOption) (*MsgWithdrawWithinBatchResponse, error) + // Submit a swap to the liquidity pool batch. + Swap(ctx context.Context, in *MsgSwapWithinBatch, opts ...grpc.CallOption) (*MsgSwapWithinBatchResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) CreatePool(ctx context.Context, in *MsgCreatePool, opts ...grpc.CallOption) (*MsgCreatePoolResponse, error) { + out := new(MsgCreatePoolResponse) + err := c.cc.Invoke(ctx, "/tendermint.liquidity.v1beta1.Msg/CreatePool", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) DepositWithinBatch(ctx context.Context, in *MsgDepositWithinBatch, opts ...grpc.CallOption) (*MsgDepositWithinBatchResponse, error) { + out := new(MsgDepositWithinBatchResponse) + err := c.cc.Invoke(ctx, "/tendermint.liquidity.v1beta1.Msg/DepositWithinBatch", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) WithdrawWithinBatch(ctx context.Context, in *MsgWithdrawWithinBatch, opts ...grpc.CallOption) (*MsgWithdrawWithinBatchResponse, error) { + out := new(MsgWithdrawWithinBatchResponse) + err := c.cc.Invoke(ctx, "/tendermint.liquidity.v1beta1.Msg/WithdrawWithinBatch", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Swap(ctx context.Context, in *MsgSwapWithinBatch, opts ...grpc.CallOption) (*MsgSwapWithinBatchResponse, error) { + out := new(MsgSwapWithinBatchResponse) + err := c.cc.Invoke(ctx, "/tendermint.liquidity.v1beta1.Msg/Swap", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // Submit a create liquidity pool message. + CreatePool(context.Context, *MsgCreatePool) (*MsgCreatePoolResponse, error) + // Submit a deposit to the liquidity pool batch. + DepositWithinBatch(context.Context, *MsgDepositWithinBatch) (*MsgDepositWithinBatchResponse, error) + // Submit a withdraw from the liquidity pool batch. + WithdrawWithinBatch(context.Context, *MsgWithdrawWithinBatch) (*MsgWithdrawWithinBatchResponse, error) + // Submit a swap to the liquidity pool batch. + Swap(context.Context, *MsgSwapWithinBatch) (*MsgSwapWithinBatchResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) CreatePool(ctx context.Context, req *MsgCreatePool) (*MsgCreatePoolResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreatePool not implemented") +} +func (*UnimplementedMsgServer) DepositWithinBatch(ctx context.Context, req *MsgDepositWithinBatch) (*MsgDepositWithinBatchResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DepositWithinBatch not implemented") +} +func (*UnimplementedMsgServer) WithdrawWithinBatch(ctx context.Context, req *MsgWithdrawWithinBatch) (*MsgWithdrawWithinBatchResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WithdrawWithinBatch not implemented") +} +func (*UnimplementedMsgServer) Swap(ctx context.Context, req *MsgSwapWithinBatch) (*MsgSwapWithinBatchResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Swap not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_CreatePool_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreatePool) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreatePool(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tendermint.liquidity.v1beta1.Msg/CreatePool", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreatePool(ctx, req.(*MsgCreatePool)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_DepositWithinBatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDepositWithinBatch) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DepositWithinBatch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tendermint.liquidity.v1beta1.Msg/DepositWithinBatch", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DepositWithinBatch(ctx, req.(*MsgDepositWithinBatch)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_WithdrawWithinBatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgWithdrawWithinBatch) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).WithdrawWithinBatch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tendermint.liquidity.v1beta1.Msg/WithdrawWithinBatch", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).WithdrawWithinBatch(ctx, req.(*MsgWithdrawWithinBatch)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Swap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSwapWithinBatch) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Swap(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tendermint.liquidity.v1beta1.Msg/Swap", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Swap(ctx, req.(*MsgSwapWithinBatch)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "tendermint.liquidity.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreatePool", + Handler: _Msg_CreatePool_Handler, + }, + { + MethodName: "DepositWithinBatch", + Handler: _Msg_DepositWithinBatch_Handler, + }, + { + MethodName: "WithdrawWithinBatch", + Handler: _Msg_WithdrawWithinBatch_Handler, + }, + { + MethodName: "Swap", + Handler: _Msg_Swap_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "tendermint/liquidity/v1beta1/tx.proto", +} + +func (m *MsgCreatePool) 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 *MsgCreatePool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreatePool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DepositCoins) > 0 { + for iNdEx := len(m.DepositCoins) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DepositCoins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if m.PoolTypeId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PoolTypeId)) + i-- + dAtA[i] = 0x10 + } + if len(m.PoolCreatorAddress) > 0 { + i -= len(m.PoolCreatorAddress) + copy(dAtA[i:], m.PoolCreatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.PoolCreatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreatePoolResponse) 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 *MsgCreatePoolResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreatePoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgDepositWithinBatch) 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 *MsgDepositWithinBatch) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDepositWithinBatch) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DepositCoins) > 0 { + for iNdEx := len(m.DepositCoins) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DepositCoins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.PoolId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if len(m.DepositorAddress) > 0 { + i -= len(m.DepositorAddress) + copy(dAtA[i:], m.DepositorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.DepositorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDepositWithinBatchResponse) 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 *MsgDepositWithinBatchResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDepositWithinBatchResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgWithdrawWithinBatch) 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 *MsgWithdrawWithinBatch) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawWithinBatch) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.PoolCoin.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.PoolId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if len(m.WithdrawerAddress) > 0 { + i -= len(m.WithdrawerAddress) + copy(dAtA[i:], m.WithdrawerAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.WithdrawerAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgWithdrawWithinBatchResponse) 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 *MsgWithdrawWithinBatchResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawWithinBatchResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSwapWithinBatch) 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 *MsgSwapWithinBatch) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSwapWithinBatch) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.OrderPrice.Size() + i -= size + if _, err := m.OrderPrice.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + { + size, err := m.OfferCoinFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + if len(m.DemandCoinDenom) > 0 { + i -= len(m.DemandCoinDenom) + copy(dAtA[i:], m.DemandCoinDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.DemandCoinDenom))) + i-- + dAtA[i] = 0x2a + } + { + size, err := m.OfferCoin.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if m.SwapTypeId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.SwapTypeId)) + i-- + dAtA[i] = 0x18 + } + if m.PoolId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if len(m.SwapRequesterAddress) > 0 { + i -= len(m.SwapRequesterAddress) + copy(dAtA[i:], m.SwapRequesterAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.SwapRequesterAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSwapWithinBatchResponse) 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 *MsgSwapWithinBatchResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSwapWithinBatchResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCreatePool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PoolCreatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.PoolTypeId != 0 { + n += 1 + sovTx(uint64(m.PoolTypeId)) + } + if len(m.DepositCoins) > 0 { + for _, e := range m.DepositCoins { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgCreatePoolResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDepositWithinBatch) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DepositorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovTx(uint64(m.PoolId)) + } + if len(m.DepositCoins) > 0 { + for _, e := range m.DepositCoins { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgDepositWithinBatchResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgWithdrawWithinBatch) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.WithdrawerAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovTx(uint64(m.PoolId)) + } + l = m.PoolCoin.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgWithdrawWithinBatchResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSwapWithinBatch) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SwapRequesterAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovTx(uint64(m.PoolId)) + } + if m.SwapTypeId != 0 { + n += 1 + sovTx(uint64(m.SwapTypeId)) + } + l = m.OfferCoin.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.DemandCoinDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.OfferCoinFee.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.OrderPrice.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgSwapWithinBatchResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreatePool) 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: MsgCreatePool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreatePool: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolCreatorAddress", 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.PoolCreatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolTypeId", wireType) + } + m.PoolTypeId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolTypeId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DepositCoins", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DepositCoins = append(m.DepositCoins, types.Coin{}) + if err := m.DepositCoins[len(m.DepositCoins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreatePoolResponse) 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: MsgCreatePoolResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreatePoolResponse: 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 *MsgDepositWithinBatch) 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: MsgDepositWithinBatch: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDepositWithinBatch: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DepositorAddress", 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.DepositorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DepositCoins", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DepositCoins = append(m.DepositCoins, types.Coin{}) + if err := m.DepositCoins[len(m.DepositCoins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDepositWithinBatchResponse) 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: MsgDepositWithinBatchResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDepositWithinBatchResponse: 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 *MsgWithdrawWithinBatch) 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: MsgWithdrawWithinBatch: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawWithinBatch: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WithdrawerAddress", 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.WithdrawerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolCoin", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PoolCoin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgWithdrawWithinBatchResponse) 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: MsgWithdrawWithinBatchResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawWithinBatchResponse: 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 *MsgSwapWithinBatch) 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: MsgSwapWithinBatch: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSwapWithinBatch: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapRequesterAddress", 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.SwapRequesterAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapTypeId", wireType) + } + m.SwapTypeId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SwapTypeId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OfferCoin", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OfferCoin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DemandCoinDenom", 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.DemandCoinDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OfferCoinFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OfferCoinFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OrderPrice", 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 + } + if err := m.OrderPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSwapWithinBatchResponse) 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: MsgSwapWithinBatchResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSwapWithinBatchResponse: 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 skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/client/encoding.go b/client/encoding.go index 2ac820d..a513dc6 100644 --- a/client/encoding.go +++ b/client/encoding.go @@ -3,6 +3,7 @@ package client import ( + tendermintLiquidityTypes "github.com/DefiantLabs/probe/client/codec/tendermint/liquidity/x/liquidity/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" @@ -26,6 +27,10 @@ func MakeCodec(moduleBasics []module.AppModuleBasic) Codec { modBasic.RegisterLegacyAminoCodec(encodingConfig.Amino) modBasic.RegisterInterfaces(encodingConfig.InterfaceRegistry) + // osmosisGammTypes.RegisterInterfaces(encodingConfig.InterfaceRegistry) + tendermintLiquidityTypes.RegisterLegacyAminoCodec(encodingConfig.Amino) + tendermintLiquidityTypes.RegisterInterfaces(encodingConfig.InterfaceRegistry) + return encodingConfig } diff --git a/main.go b/main.go index b6022ce..baaa48f 100644 --- a/main.go +++ b/main.go @@ -28,7 +28,7 @@ func main() { } // Proof of concept code - var checkHeight int64 = 8283313 + var checkHeight int64 = 15289176 // Check chain status query := querier.Query{Client: cl, Options: &querier.QueryOptions{}} @@ -44,7 +44,7 @@ func main() { // Get a block options := querier.QueryOptions{Height: checkHeight} - query = querier.Query{Client: cl, Options: &querier.QueryOptions{}} + query = querier.Query{Client: cl, Options: &querier.QueryOptions{Height: checkHeight}} block, err := querier.BlockRPC(&query) if err != nil { fmt.Println("Error getting block") @@ -57,7 +57,7 @@ func main() { // Get block results options = querier.QueryOptions{Height: checkHeight} - query = querier.Query{Client: cl, Options: &querier.QueryOptions{}} + query = querier.Query{Client: cl, Options: &querier.QueryOptions{Height: checkHeight}} blockResults, err := querier.BlockResultsRPC(&query) if err != nil { fmt.Println("Error getting block results") @@ -81,8 +81,19 @@ func main() { os.Exit(1) } else { fmt.Println("Got txes, some TX hashes follow:") - for _, v := range txResponse.TxResponses { - fmt.Println(v.TxHash) + for i := range txResponse.Txs { + currTx := txResponse.Txs[i] + currTxResp := txResponse.TxResponses[i] + fmt.Println("TX Hash:", currTxResp.TxHash) + fmt.Println("Contains these messages:") + for msgIdx := range currTx.Body.Messages { + currMsg := currTx.Body.Messages[msgIdx].GetCachedValue() + if currMsg == nil { + fmt.Println("Error getting CachedValue for", currTx.Body.Messages[msgIdx].TypeUrl) + } else { + fmt.Println(currTx.Body.Messages[msgIdx].TypeUrl) + } + } } } } diff --git a/proto/README.md b/proto/README.md new file mode 100644 index 0000000..b5439fa --- /dev/null +++ b/proto/README.md @@ -0,0 +1,40 @@ +# Proto Definitions and Generation + +## Why Module Protobuf definitions and code generation is needed: + +The main use-case of this repo is for generalized querying on Cosmos blockchains. + +For the use-case of Transaction and Message type querying, the package needs some way to unpack the message types found on-chain into their underlying Go types. The message types all are expected to follow the Cosmos Msg interface, with their representation stored onchain in byte form. These bytes need to be converted to the Go Msg types by this package to support transaction querying. + +When messages are received from the chain during Transaction querying, they are unpacked into their underlying type. The message type is found using the TypeUrl for the message, pulled from the client Codec, and unpacked. + +For base Cosmos SDK types, this process is trivial. This package imports the Cosmos SDK and sets up the Codec to handle these types. + +For customized modules, the process is more involved. The types cannot always be imported directly into this codebase due to (amongst other considerations): Random blockchains are not always using Cosmos SDK v47, meaning they are incompatible with this package if imported. + +## Our Solution + +We are making use of the following solution where needed: + +1. Determine which Blockchain modules need to be supported by this package +2. Bring in the Module Msg proto definitions +3. Generate the .pb.go files using `buf` +4. Fill out the remaining Msg interface function definition requirements +5. Register the Msg types into the application Codec + +This allows Transaction querying to unpack these messages into their underlying type so that values can be pulled out of them. + +## Requirements + +Before contributing proto definitions here, make sure your environment is setup for generating Cosmos Proto files by following these requirements: + +1. Download Cosmos Gogoproto + +```sh +git clone https://github.com/cosmos/gogoproto.git +cd gogoproto +go mod download +make install +``` + +2. Make sure your proto definitions fit the application package requirements. Primarily, due to the location of auto-generated code living under client/codec/\/\, make sure your proto package name reflects this location. diff --git a/proto/buf.gen.gogo.yaml b/proto/buf.gen.gogo.yaml new file mode 100644 index 0000000..200c501 --- /dev/null +++ b/proto/buf.gen.gogo.yaml @@ -0,0 +1,8 @@ +version: v1 +plugins: + - name: gocosmos + out: . + opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types,Mcosmos/orm/v1/orm.proto=cosmossdk.io/orm + - name: grpc-gateway + out: . + opt: logtostderr=true,allow_colon_final_segments=true \ No newline at end of file diff --git a/proto/buf.lock b/proto/buf.lock new file mode 100644 index 0000000..535b6fa --- /dev/null +++ b/proto/buf.lock @@ -0,0 +1,7 @@ +# Generated by buf. DO NOT EDIT. +version: v1 +deps: + - remote: buf.build + owner: cosmos + repository: gogo-proto + commit: 34d970b699f84aa382f3c29773a60836 diff --git a/proto/buf.yaml b/proto/buf.yaml new file mode 100644 index 0000000..c64cf1e --- /dev/null +++ b/proto/buf.yaml @@ -0,0 +1,5 @@ +# This module represents buf.build/cosmos/cosmos-sdk +version: v1 +name: buf.build/cosmos/cosmos-sdk +deps: + - buf.build/cosmos/gogo-proto \ No newline at end of file diff --git a/proto/tendermint/liquidity/v1beta1/tx.proto b/proto/tendermint/liquidity/v1beta1/tx.proto new file mode 100644 index 0000000..29b1737 --- /dev/null +++ b/proto/tendermint/liquidity/v1beta1/tx.proto @@ -0,0 +1,146 @@ +syntax = "proto3"; +package tendermint.liquidity.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/msg/v1/msg.proto"; + +//option go_package = "github.com/tendermint/liquidity/x/liquidity/types"; +option go_package = "github.com/DefiantLabs/probe/client/codec/tendermint/liquidity/x/liquidity/types"; + +// Msg defines the liquidity Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + // Submit a create liquidity pool message. + rpc CreatePool(MsgCreatePool) returns (MsgCreatePoolResponse); + + // Submit a deposit to the liquidity pool batch. + rpc DepositWithinBatch(MsgDepositWithinBatch) returns (MsgDepositWithinBatchResponse); + + // Submit a withdraw from the liquidity pool batch. + rpc WithdrawWithinBatch(MsgWithdrawWithinBatch) returns (MsgWithdrawWithinBatchResponse); + + // Submit a swap to the liquidity pool batch. + rpc Swap(MsgSwapWithinBatch) returns (MsgSwapWithinBatchResponse); +} + +// MsgCreatePool defines an sdk.Msg type that supports submitting a create liquidity pool tx. +// +// See: https://github.com/tendermint/liquidity/blob/develop/x/liquidity/spec/04_messages.md +message MsgCreatePool { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string pool_creator_address = 1 [(gogoproto.moretags) = "yaml:\"pool_creator_address\""]; + + // id of the target pool type, must match the value in the pool. Only pool-type-id 1 is supported. + uint32 pool_type_id = 2 [(gogoproto.moretags) = "yaml:\"pool_type_id\""]; + + // reserve coin pair of the pool to deposit. + repeated cosmos.base.v1beta1.Coin deposit_coins = 4 [(gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"deposit_coins\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +// MsgCreatePoolResponse defines the Msg/CreatePool response type. +message MsgCreatePoolResponse {} + +// `MsgDepositWithinBatch defines` an `sdk.Msg` type that supports submitting +// a deposit request to the batch of the liquidity pool. +// Deposit is submitted to the batch of the Liquidity pool with the specified +// `pool_id`, `deposit_coins` for reserve. +// This request is stacked in the batch of the liquidity pool, is not processed +// immediately, and is processed in the `endblock` at the same time as other requests. +// +// See: https://github.com/tendermint/liquidity/blob/develop/x/liquidity/spec/04_messages.md +message MsgDepositWithinBatch { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string depositor_address = 1 [(gogoproto.moretags) = "yaml:\"depositor_address\""]; + + // id of the target pool + uint64 pool_id = 2 [(gogoproto.moretags) = "yaml:\"pool_id\"", (gogoproto.jsontag) = "pool_id"]; + + // reserve coin pair of the pool to deposit + repeated cosmos.base.v1beta1.Coin deposit_coins = 3 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"deposit_coins\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + +} + +// MsgDepositWithinBatchResponse defines the Msg/DepositWithinBatch response type. +message MsgDepositWithinBatchResponse {} + +// `MsgWithdrawWithinBatch` defines an `sdk.Msg` type that supports submitting +// a withdraw request to the batch of the liquidity pool. +// Withdraw is submitted to the batch from the Liquidity pool with the +// specified `pool_id`, `pool_coin` of the pool. +// This request is stacked in the batch of the liquidity pool, is not processed +// immediately, and is processed in the `endblock` at the same time as other requests. +// +// See: https://github.com/tendermint/liquidity/blob/develop/x/liquidity/spec/04_messages.md +message MsgWithdrawWithinBatch { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string withdrawer_address = 1 [ (gogoproto.moretags) = "yaml:\"withdrawer_address\""]; + // id of the target pool + uint64 pool_id = 2 [(gogoproto.moretags) = "yaml:\"pool_id\"", (gogoproto.jsontag) = "pool_id"]; + cosmos.base.v1beta1.Coin pool_coin = 3 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"pool_coin\""]; +} + +// MsgWithdrawWithinBatchResponse defines the Msg/WithdrawWithinBatch response type. +message MsgWithdrawWithinBatchResponse {} + +// `MsgSwapWithinBatch` defines an sdk.Msg type that supports submitting a swap offer request to the batch of the liquidity pool. +// Submit swap offer to the liquidity pool batch with the specified the `pool_id`, `swap_type_id`, +// `demand_coin_denom` with the coin and the price you're offering +// and `offer_coin_fee` must be half of offer coin amount * current `params.swap_fee_rate` and ceil for reservation to pay fees. +// This request is stacked in the batch of the liquidity pool, is not processed +// immediately, and is processed in the `endblock` at the same time as other requests. +// You must request the same fields as the pool. +// Only the default `swap_type_id` 1 is supported. +// +// See: https://github.com/tendermint/liquidity/tree/develop/doc +// https://github.com/tendermint/liquidity/blob/develop/x/liquidity/spec/04_messages.md +message MsgSwapWithinBatch { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + // address of swap requester + string swap_requester_address = 1 [(gogoproto.moretags) = "yaml:\"swap_requester_address\""]; + // id of swap type, must match the value in the pool. Only `swap_type_id` 1 is supported. + uint64 pool_id = 2 [(gogoproto.moretags) = "yaml:\"pool_id\"", (gogoproto.jsontag) = "pool_id"]; + + // id of swap type. Must match the value in the pool. + uint32 swap_type_id = 3 [(gogoproto.moretags) = "yaml:\"swap_type_id\""]; + + // offer sdk.coin for the swap request, must match the denom in the pool. + cosmos.base.v1beta1.Coin offer_coin = 4 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"offer_coin\""]; + + // denom of demand coin to be exchanged on the swap request, must match the denom in the pool. + string demand_coin_denom = 5 [(gogoproto.moretags) = "yaml:\"demand_coin_denom\""]; + + // half of offer coin amount * params.swap_fee_rate and ceil for reservation to pay fees. + cosmos.base.v1beta1.Coin offer_coin_fee = 6 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"offer_coin_fee\"" + ]; + + // limit order price for the order, the price is the exchange ratio of X/Y + // where X is the amount of the first coin and Y is the amount + // of the second coin when their denoms are sorted alphabetically. + string order_price = 7 [ + (gogoproto.moretags) = "yaml:\"order_price\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false]; +} + +// MsgSwapWithinBatchResponse defines the Msg/Swap response type. +message MsgSwapWithinBatchResponse {} diff --git a/protocgen.sh b/protocgen.sh new file mode 100755 index 0000000..b08cf93 --- /dev/null +++ b/protocgen.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -eox pipefail + +echo "Generating gogo proto code" +proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) +for dir in $proto_dirs; do + for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do + buf generate --template proto/buf.gen.gogo.yaml $file + done +done + +# move proto files to the right places +cp -r github.com/DefiantLabs/probe/* ./ +rm -rf github.com \ No newline at end of file diff --git a/third_party/proto/cosmos/base/v1beta1/coin.proto b/third_party/proto/cosmos/base/v1beta1/coin.proto new file mode 100644 index 0000000..fab7528 --- /dev/null +++ b/third_party/proto/cosmos/base/v1beta1/coin.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; +package cosmos.base.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/types"; +option (gogoproto.goproto_stringer_all) = false; +option (gogoproto.stringer_all) = false; + +// Coin defines a token with a denomination and an amount. +// +// NOTE: The amount field is an Int which implements the custom method +// signatures required by gogoproto. +message Coin { + option (gogoproto.equal) = true; + + string denom = 1; + string amount = 2 [(gogoproto.customtype) = "Int", (gogoproto.nullable) = false]; +} + +// DecCoin defines a token with a denomination and a decimal amount. +// +// NOTE: The amount field is an Dec which implements the custom method +// signatures required by gogoproto. +message DecCoin { + option (gogoproto.equal) = true; + + string denom = 1; + string amount = 2 [(gogoproto.customtype) = "Dec", (gogoproto.nullable) = false]; +} + +// IntProto defines a Protobuf wrapper around an Int object. +message IntProto { + string int = 1 [(gogoproto.customtype) = "Int", (gogoproto.nullable) = false]; +} + +// DecProto defines a Protobuf wrapper around a Dec object. +message DecProto { + string dec = 1 [(gogoproto.customtype) = "Dec", (gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/msg/v1/msg.proto b/third_party/proto/cosmos/msg/v1/msg.proto new file mode 100644 index 0000000..853efa1 --- /dev/null +++ b/third_party/proto/cosmos/msg/v1/msg.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; + +package cosmos.msg.v1; + +import "google/protobuf/descriptor.proto"; + +// TODO(fdymylja): once we fully migrate to protov2 the go_package needs to be updated. +// We need this right now because gogoproto codegen needs to import the extension. +option go_package = "github.com/cosmos/cosmos-sdk/types/msgservice"; + +extend google.protobuf.ServiceOptions { + // service indicates that the service is a Msg service and that requests + // must be transported via blockchain transactions rather than gRPC. + // Tooling can use this annotation to distinguish between Msg services and + // other types of services via reflection. + bool service = 11110000; +} + +extend google.protobuf.MessageOptions { + // signer must be used in cosmos messages in order + // to signal to external clients which fields in a + // given cosmos message must be filled with signer + // information (address). + // The field must be the protobuf name of the message + // field extended with this MessageOption. + // The field must either be of string kind, or of message + // kind in case the signer information is contained within + // a message inside the cosmos message. + repeated string signer = 11110000; +} From 5ee86edc20c0b3da9816aee3fb7e294474214bcc Mon Sep 17 00:00:00 2001 From: pharr117 Date: Sun, 21 May 2023 19:38:19 -0400 Subject: [PATCH 2/3] Remove replace statement for regennetwork, use cosmos grpc package instead --- client/grpc_query.go | 2 +- go.mod | 6 ++---- go.sum | 13 ++++++++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/client/grpc_query.go b/client/grpc_query.go index 00bd442..5c795bb 100644 --- a/client/grpc_query.go +++ b/client/grpc_query.go @@ -11,7 +11,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/store/rootmulti" - gogogrpc "github.com/gogo/protobuf/grpc" + gogogrpc "github.com/cosmos/gogoproto/grpc" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/encoding" diff --git a/go.mod b/go.mod index d24b994..37268cc 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.19 require ( github.com/cometbft/cometbft v0.37.1 github.com/cosmos/cosmos-sdk v0.47.0 - github.com/gogo/protobuf v1.3.2 + github.com/cosmos/gogoproto v1.4.8 google.golang.org/grpc v1.54.0 ) @@ -35,7 +35,6 @@ require ( github.com/cosmos/cosmos-proto v1.0.0-beta.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/gogoproto v1.4.8 // indirect github.com/cosmos/iavl v0.20.0 // indirect github.com/cosmos/ledger-cosmos-go v0.12.1 // indirect github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect @@ -56,6 +55,7 @@ require ( github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.1.0 // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.3 // indirect @@ -133,5 +133,3 @@ require ( pgregory.net/rapid v0.5.5 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) - -replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 diff --git a/go.sum b/go.sum index 4d56724..dd46d00 100644 --- a/go.sum +++ b/go.sum @@ -287,6 +287,12 @@ github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFG github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= @@ -467,6 +473,8 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= @@ -641,8 +649,6 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/gocuke v0.6.2 h1:pHviZ0kKAq2U2hN2q3smKNxct6hS0mGByFMHGnWA97M= -github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4= -github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -980,8 +986,10 @@ golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -1093,7 +1101,6 @@ google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200324203455-a04cca1dde73/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= From 47381d84e22e952880774ab9d3b25dd6ff0da5e1 Mon Sep 17 00:00:00 2001 From: pharr117 Date: Sun, 21 May 2023 19:43:27 -0400 Subject: [PATCH 3/3] More README --- proto/README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/proto/README.md b/proto/README.md index b5439fa..8c2da35 100644 --- a/proto/README.md +++ b/proto/README.md @@ -18,7 +18,7 @@ We are making use of the following solution where needed: 1. Determine which Blockchain modules need to be supported by this package 2. Bring in the Module Msg proto definitions -3. Generate the .pb.go files using `buf` +3. Generate the `.pb.go` files using `buf` 4. Fill out the remaining Msg interface function definition requirements 5. Register the Msg types into the application Codec @@ -38,3 +38,11 @@ make install ``` 2. Make sure your proto definitions fit the application package requirements. Primarily, due to the location of auto-generated code living under client/codec/\/\, make sure your proto package name reflects this location. + +## General Guidance + +With this repo being oriented to querying, the package is not too concerned with actually making Message definition functionality work in general. This means: + +* Message invoke functionality can be skipped (e.g. ValidateBasic needs to be defined but, since this package is not concerned with message pre-validation, the function can return nil) +* Go for minimum viable Message interface definitions to keep the codebase light +* Try to keep the proto files light, when looking through module Proto definitions to see what is needed, pull in the least amount of proto code as possible \ No newline at end of file