From 1f2294826b6f945025bfe4cc4ae74e6d5c283d91 Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Thu, 23 Jun 2022 14:58:06 -0700 Subject: [PATCH 1/6] Remove message register pair --- proto/dex/tx.proto | 9 ---- x/dex/client/cli/tx_register_pair.go | 59 ------------------------ x/dex/handler.go | 3 -- x/dex/keeper/msg_server_register_pair.go | 24 ---------- x/dex/types/message_register_pair.go | 55 ---------------------- 5 files changed, 150 deletions(-) delete mode 100644 x/dex/client/cli/tx_register_pair.go delete mode 100644 x/dex/keeper/msg_server_register_pair.go delete mode 100644 x/dex/types/message_register_pair.go diff --git a/proto/dex/tx.proto b/proto/dex/tx.proto index 00a58c07fb..715c87fd99 100644 --- a/proto/dex/tx.proto +++ b/proto/dex/tx.proto @@ -17,7 +17,6 @@ service Msg { rpc PlaceOrders(MsgPlaceOrders) returns (MsgPlaceOrdersResponse); rpc CancelOrders(MsgCancelOrders) returns (MsgCancelOrdersResponse); rpc Liquidate(MsgLiquidation) returns (MsgLiquidationResponse); - rpc RegisterPair(MsgRegisterPair) returns (MsgRegisterPairResponse); rpc RegisterContract(MsgRegisterContract) returns(MsgRegisterContractResponse); // privileged endpoints below @@ -54,14 +53,6 @@ message MsgLiquidation { message MsgLiquidationResponse {} -message MsgRegisterPair { - string creator = 1; - string contractAddr = 2; - Pair pair = 3; -} - -message MsgRegisterPairResponse {} - message MsgRegisterContract { string creator = 1; ContractInfo contract = 2; diff --git a/x/dex/client/cli/tx_register_pair.go b/x/dex/client/cli/tx_register_pair.go deleted file mode 100644 index 1a3f6ac559..0000000000 --- a/x/dex/client/cli/tx_register_pair.go +++ /dev/null @@ -1,59 +0,0 @@ -package cli - -import ( - "errors" - "strconv" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/sei-protocol/sei-chain/x/dex/types" - "github.com/spf13/cobra" -) - -var _ = strconv.Itoa(0) - -func CmdRegisterPair() *cobra.Command { - cmd := &cobra.Command{ - Use: "register-pair [contract address] [price denom] [asset denom]", - Short: "Register tradable pair", - Args: cobra.ExactArgs(3), - RunE: func(cmd *cobra.Command, args []string) (err error) { - argContractAddr := args[0] - reqPriceDenom, unit, err := types.GetDenomFromStr(args[1]) - if err != nil { - return err - } - if unit != types.Unit_STANDARD { - return errors.New("Denom must be in standard/whole unit (e.g. sei instead of usei)") - } - reqAssetDenom, unit, err := types.GetDenomFromStr(args[2]) - if err != nil { - return err - } - if unit != types.Unit_STANDARD { - return errors.New("Denom must be in standard/whole unit (e.g. sei instead of usei)") - } - - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := types.NewMsgRegisterPair( - clientCtx.GetFromAddress().String(), - argContractAddr, - reqPriceDenom, - reqAssetDenom, - ) - if err := msg.ValidateBasic(); err != nil { - return err - } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/dex/handler.go b/x/dex/handler.go index 7a2ffcd316..d182a8ca55 100644 --- a/x/dex/handler.go +++ b/x/dex/handler.go @@ -27,9 +27,6 @@ func NewHandler(k keeper.Keeper, tracingInfo *tracing.TracingInfo) sdk.Handler { case *types.MsgLiquidation: res, err := msgServer.Liquidate(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgRegisterPair: - res, err := msgServer.RegisterPair(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) case *types.MsgRegisterContract: res, err := msgServer.RegisterContract(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) diff --git a/x/dex/keeper/msg_server_register_pair.go b/x/dex/keeper/msg_server_register_pair.go deleted file mode 100644 index 384664813f..0000000000 --- a/x/dex/keeper/msg_server_register_pair.go +++ /dev/null @@ -1,24 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - dexcache "github.com/sei-protocol/sei-chain/x/dex/cache" - "github.com/sei-protocol/sei-chain/x/dex/types" -) - -func (k msgServer) RegisterPair(goCtx context.Context, msg *types.MsgRegisterPair) (*types.MsgRegisterPairResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - for _, pair := range k.GetAllRegisteredPairs(ctx, msg.ContractAddr) { - if pair == *msg.Pair { - return &types.MsgRegisterPairResponse{}, nil - } - } - k.AddRegisteredPair(ctx, msg.ContractAddr, *msg.Pair) - k.Orders[msg.ContractAddr][(*msg.Pair).String()] = dexcache.NewOrders() - k.OrderPlacements[msg.ContractAddr][(*msg.Pair).String()] = dexcache.NewOrderPlacements() - k.OrderCancellations[msg.ContractAddr][(*msg.Pair).String()] = dexcache.NewOrderCancellations() - - return &types.MsgRegisterPairResponse{}, nil -} diff --git a/x/dex/types/message_register_pair.go b/x/dex/types/message_register_pair.go deleted file mode 100644 index 240025057f..0000000000 --- a/x/dex/types/message_register_pair.go +++ /dev/null @@ -1,55 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -const TypeMsgRegisterPair = "register_pair" - -var _ sdk.Msg = &MsgRegisterPair{} - -func NewMsgRegisterPair( - creator string, - contractAddr string, - priceDenom Denom, - assetDenom Denom, -) *MsgRegisterPair { - return &MsgRegisterPair{ - Creator: creator, - ContractAddr: contractAddr, - Pair: &Pair{ - PriceDenom: priceDenom, - AssetDenom: assetDenom, - }, - } -} - -func (msg *MsgRegisterPair) Route() string { - return RouterKey -} - -func (msg *MsgRegisterPair) Type() string { - return TypeMsgRegisterPair -} - -func (msg *MsgRegisterPair) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{creator} -} - -func (msg *MsgRegisterPair) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) -} - -func (msg *MsgRegisterPair) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) - } - return nil -} From bc6c350177ea3bfd263363c9176a50018719ed85 Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Mon, 27 Jun 2022 13:42:24 -0700 Subject: [PATCH 2/6] Add RegisterPairsProposal --- app/app.go | 3 ++- proto/dex/gov.proto | 23 ++++++++++++++++++++ proto/dex/pair.proto | 7 +++++- x/dex/client/cli/tx.go | 1 - x/dex/handler.go | 17 +++++++++++++++ x/dex/keeper/gov.go | 25 +++++++++++++++++++++ x/dex/keeper/pair.go | 10 ++++++++- x/dex/types/codec.go | 5 +++++ x/dex/types/gov.go | 49 ++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 proto/dex/gov.proto create mode 100644 x/dex/keeper/gov.go create mode 100644 x/dex/types/gov.go diff --git a/app/app.go b/app/app.go index fdee04b458..a037649b9a 100644 --- a/app/app.go +++ b/app/app.go @@ -409,7 +409,8 @@ func New( AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). - AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) + AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)). + AddRoute(dexmoduletypes.RouterKey, dex.NewRegisterPairsProposalHandler(app.DexKeeper)) if len(enabledProposals) != 0 { govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, enabledProposals)) } diff --git a/proto/dex/gov.proto b/proto/dex/gov.proto new file mode 100644 index 0000000000..2a849415a5 --- /dev/null +++ b/proto/dex/gov.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +package seiprotocol.seichain.dex; + +import "gogoproto/gogo.proto"; +import "dex/pair.proto"; + +option go_package = "github.com/sei-protocol/sei-chain/x/dex/types"; + +// RegisterPairsProposal is a gov Content type for adding a new whitelisted token +// pair to the dex module. It must specify a list of contract addresses and their respective +// token pairs to be registered. +message RegisterPairsProposal { + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; + string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + repeated BatchContractPair batchcontractpair = 3 [ + (gogoproto.moretags) = "yaml:\"batch_contract_pair\"", + (gogoproto.nullable) = false + ]; + } diff --git a/proto/dex/pair.proto b/proto/dex/pair.proto index aeb662a215..bb90e23a30 100644 --- a/proto/dex/pair.proto +++ b/proto/dex/pair.proto @@ -8,4 +8,9 @@ option go_package = "github.com/sei-protocol/sei-chain/x/dex/types"; message Pair { Denom priceDenom = 1; Denom assetDenom = 2; -} \ No newline at end of file +} + +message BatchContractPair { + string contractAddr = 1 [(gogoproto.jsontag) = "contractAddr"]; + repeated Pair pairs = 2 [(gogoproto.jsontag) = "pairs"]; +} diff --git a/x/dex/client/cli/tx.go b/x/dex/client/cli/tx.go index f6c7826f8b..69d9815d4c 100644 --- a/x/dex/client/cli/tx.go +++ b/x/dex/client/cli/tx.go @@ -30,7 +30,6 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdPlaceOrders()) cmd.AddCommand(CmdCancelOrders()) cmd.AddCommand(CmdLiquidate()) - cmd.AddCommand(CmdRegisterPair()) cmd.AddCommand(CmdRegisterContract()) // this line is used by starport scaffolding # 1 diff --git a/x/dex/handler.go b/x/dex/handler.go index d182a8ca55..b5b36ff088 100644 --- a/x/dex/handler.go +++ b/x/dex/handler.go @@ -5,6 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/sei-protocol/sei-chain/utils/tracing" "github.com/sei-protocol/sei-chain/x/dex/keeper" "github.com/sei-protocol/sei-chain/x/dex/types" @@ -37,3 +39,18 @@ func NewHandler(k keeper.Keeper, tracingInfo *tracing.TracingInfo) sdk.Handler { } } } + +func NewRegisterPairsProposalHandler(k keeper.Keeper) govtypes.Handler { + return func(ctx sdk.Context, content govtypes.Content) error { + switch c := content.(type) { + case *types.RegisterPairsProposal: + return handleRegisterPairsProposal(ctx, k, c) + default: + return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized dex proposal content type: %T", c) + } + } +} + +func handleRegisterPairsProposal(ctx sdk.Context, k keeper.Keeper, p *types.RegisterPairsProposal) error { + return k.HandleUpdateFeeTokenProposal(ctx, p) +} diff --git a/x/dex/keeper/gov.go b/x/dex/keeper/gov.go new file mode 100644 index 0000000000..2da97bce02 --- /dev/null +++ b/x/dex/keeper/gov.go @@ -0,0 +1,25 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + dexcache "github.com/sei-protocol/sei-chain/x/dex/cache" + "github.com/sei-protocol/sei-chain/x/dex/types" +) + +func (k Keeper) HandleRegisterPairsProposal(ctx sdk.Context, p *types.RegisterPairsProposal) error { + // Loop through each batch contract pair an individual contract pair, token pair + // tuple and register them individually + for _, batchContractPair := range p.batchcontractpair { + var contractAddress string = batchContractPair.contractAddr + for _, pair := range batchContractPair.pairs { + k.AddRegisteredPair(ctx, contractAddress, pair) + k.Orders[contractAddr][pair.String()] = dexcache.NewOrders() + k.OrderPlacements[contractAddress][pair.String()] = dexcache.NewOrderPlacements() + k.OrderCancellations[contractAddress][pair.String()] = dexcache.NewOrderCancellations() + } + } + + return nil +} diff --git a/x/dex/keeper/pair.go b/x/dex/keeper/pair.go index bb74e5cdc7..e051074e5d 100644 --- a/x/dex/keeper/pair.go +++ b/x/dex/keeper/pair.go @@ -30,13 +30,21 @@ func (k Keeper) GetPairCount(ctx sdk.Context, contractAddr string) uint64 { return binary.BigEndian.Uint64(cnt) } -func (k Keeper) AddRegisteredPair(ctx sdk.Context, contractAddr string, pair types.Pair) { +func (k Keeper) AddRegisteredPair(ctx sdk.Context, contractAddr string, pair types.Pair) bool { + // Only add pairs that have not been added before + for _, prevPair := range k.GetAllRegisteredPairs(ctx, contractAddr) { + if pair == prevPair { + return false + } + } oldPairCnt := k.GetPairCount(ctx, contractAddr) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.RegisteredPairPrefix(contractAddr)) keyBytes := make([]byte, 8) binary.BigEndian.PutUint64(keyBytes, oldPairCnt) store.Set(keyBytes, k.Cdc.MustMarshal(&pair)) k.SetPairCount(ctx, contractAddr, oldPairCnt+1) + + return true } func (k Keeper) GetAllRegisteredPairs(ctx sdk.Context, contractAddr string) []types.Pair { diff --git a/x/dex/types/codec.go b/x/dex/types/codec.go index 20293244ee..48edceb3dd 100644 --- a/x/dex/types/codec.go +++ b/x/dex/types/codec.go @@ -5,12 +5,14 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgPlaceOrders{}, "dex/MsgPlaceOrders", nil) cdc.RegisterConcrete(&MsgCancelOrders{}, "dex/MsgCancelOrders", nil) cdc.RegisterConcrete(&MsgLiquidation{}, "dex/MsgLiquidation", nil) + cdc.RegisterConcrete(&RegisterPairsProposal{}, "dex/RegisterPairsProposal", nil) // this line is used by starport scaffolding # 2 } @@ -24,6 +26,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgLiquidation{}, ) + registry.RegisterImplementations((*govtypes.Content)(nil), + &RegisterPairsProposal{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/dex/types/gov.go b/x/dex/types/gov.go new file mode 100644 index 0000000000..bf4c349f89 --- /dev/null +++ b/x/dex/types/gov.go @@ -0,0 +1,49 @@ +package types + +import ( + "fmt" + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" +) + +const ( + ProposalTypeRegisterPairs = "RegisterPairs" +) + +func init() { + govtypes.RegisterProposalType(ProposalTypeRegisterPairs) + govtypes.RegisterProposalTypeCodec(&RegisterPairsProposal{}, "dex/RegisterPairsProposal") +} + +var _ govtypes.Content = &RegisterPairsProposal{} + +func NewRegisterPairsProposal(title, description string, batchContractPair []BatchContractPair) RegisterPairsProposal { + return RegisterPairsProposal{ + Title: title, + Description: description, + BatchContractPair: batchContractPair, + } +} + +func (p *RegisterPairsProposal) GetTitle() string { return p.Title } + +func (p *RegisterPairsProposal) GetDescription() string { return p.Description } + +func (p *RegisterPairsProposal) ProposalRoute() string { return RouterKey } + +func (p *RegisterPairsProposal) ProposalType() string { + return ProposalTypeRegisterPairs +} + +// TODO: String support for register pair type +func (p RegisterPairsProposal) String() string { + var b strings.Builder + b.WriteString(fmt.Sprintf(`Update Fee Token Proposal: + Title: %s + Description: %s + Records: %s +`, p.Title, p.Description, p.BatchContractPair.String())) + return b.String() +} From 470c18ea9b1737ee93c352a23682c18c6b805465 Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Mon, 27 Jun 2022 15:02:26 -0700 Subject: [PATCH 3/6] Fix string representation, handler --- app/app.go | 2 +- proto/dex/gov.proto | 2 +- proto/dex/pair.proto | 1 + x/dex/handler.go | 2 +- x/dex/keeper/gov.go | 15 +- x/dex/types/gov.go | 14 +- x/dex/types/gov.pb.go | 419 +++++++++++++++++++++++++++++++++ x/dex/types/pair.pb.go | 260 ++++++++++++++++++++- x/dex/types/tx.pb.go | 519 ++++------------------------------------- 9 files changed, 730 insertions(+), 504 deletions(-) create mode 100644 x/dex/types/gov.pb.go diff --git a/app/app.go b/app/app.go index a037649b9a..b114f8e9c9 100644 --- a/app/app.go +++ b/app/app.go @@ -410,7 +410,7 @@ func New( AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)). - AddRoute(dexmoduletypes.RouterKey, dex.NewRegisterPairsProposalHandler(app.DexKeeper)) + AddRoute(dexmoduletypes.RouterKey, dexmodule.NewRegisterPairsProposalHandler(app.DexKeeper)) if len(enabledProposals) != 0 { govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, enabledProposals)) } diff --git a/proto/dex/gov.proto b/proto/dex/gov.proto index 2a849415a5..671a61be25 100644 --- a/proto/dex/gov.proto +++ b/proto/dex/gov.proto @@ -10,7 +10,7 @@ option go_package = "github.com/sei-protocol/sei-chain/x/dex/types"; // pair to the dex module. It must specify a list of contract addresses and their respective // token pairs to be registered. message RegisterPairsProposal { - option (gogoproto.equal) = true; + option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_stringer) = false; diff --git a/proto/dex/pair.proto b/proto/dex/pair.proto index bb90e23a30..661b864f15 100644 --- a/proto/dex/pair.proto +++ b/proto/dex/pair.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package seiprotocol.seichain.dex; import "dex/enums.proto"; +import "gogoproto/gogo.proto"; option go_package = "github.com/sei-protocol/sei-chain/x/dex/types"; diff --git a/x/dex/handler.go b/x/dex/handler.go index b5b36ff088..aca47fea5b 100644 --- a/x/dex/handler.go +++ b/x/dex/handler.go @@ -52,5 +52,5 @@ func NewRegisterPairsProposalHandler(k keeper.Keeper) govtypes.Handler { } func handleRegisterPairsProposal(ctx sdk.Context, k keeper.Keeper, p *types.RegisterPairsProposal) error { - return k.HandleUpdateFeeTokenProposal(ctx, p) + return k.HandleRegisterPairsProposal(ctx, p) } diff --git a/x/dex/keeper/gov.go b/x/dex/keeper/gov.go index 2da97bce02..53a253b6cf 100644 --- a/x/dex/keeper/gov.go +++ b/x/dex/keeper/gov.go @@ -2,7 +2,6 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" dexcache "github.com/sei-protocol/sei-chain/x/dex/cache" "github.com/sei-protocol/sei-chain/x/dex/types" @@ -11,13 +10,13 @@ import ( func (k Keeper) HandleRegisterPairsProposal(ctx sdk.Context, p *types.RegisterPairsProposal) error { // Loop through each batch contract pair an individual contract pair, token pair // tuple and register them individually - for _, batchContractPair := range p.batchcontractpair { - var contractAddress string = batchContractPair.contractAddr - for _, pair := range batchContractPair.pairs { - k.AddRegisteredPair(ctx, contractAddress, pair) - k.Orders[contractAddr][pair.String()] = dexcache.NewOrders() - k.OrderPlacements[contractAddress][pair.String()] = dexcache.NewOrderPlacements() - k.OrderCancellations[contractAddress][pair.String()] = dexcache.NewOrderCancellations() + for _, batchContractPair := range p.Batchcontractpair { + var contractAddress string = batchContractPair.ContractAddr + for _, pair := range batchContractPair.Pairs { + k.AddRegisteredPair(ctx, contractAddress, *pair) + k.Orders[contractAddress][(*pair).String()] = dexcache.NewOrders() + k.OrderPlacements[contractAddress][(*pair).String()] = dexcache.NewOrderPlacements() + k.OrderCancellations[contractAddress][(*pair).String()] = dexcache.NewOrderCancellations() } } diff --git a/x/dex/types/gov.go b/x/dex/types/gov.go index bf4c349f89..18e8135399 100644 --- a/x/dex/types/gov.go +++ b/x/dex/types/gov.go @@ -4,7 +4,6 @@ import ( "fmt" "strings" - sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -23,7 +22,7 @@ func NewRegisterPairsProposal(title, description string, batchContractPair []Bat return RegisterPairsProposal{ Title: title, Description: description, - BatchContractPair: batchContractPair, + Batchcontractpair: batchContractPair, } } @@ -37,13 +36,22 @@ func (p *RegisterPairsProposal) ProposalType() string { return ProposalTypeRegisterPairs } +func (p *RegisterPairsProposal) ValidateBasic() error { + err := govtypes.ValidateAbstract(p) + return err +} + // TODO: String support for register pair type func (p RegisterPairsProposal) String() string { + batchContractPairRecords := "" + for _, contractPair := range p.Batchcontractpair { + batchContractPairRecords += contractPair.String() + } var b strings.Builder b.WriteString(fmt.Sprintf(`Update Fee Token Proposal: Title: %s Description: %s Records: %s -`, p.Title, p.Description, p.BatchContractPair.String())) +`, p.Title, p.Description, batchContractPairRecords)) return b.String() } diff --git a/x/dex/types/gov.pb.go b/x/dex/types/gov.pb.go new file mode 100644 index 0000000000..986cedc093 --- /dev/null +++ b/x/dex/types/gov.pb.go @@ -0,0 +1,419 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dex/gov.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// RegisterPairsProposal is a gov Content type for adding a new whitelisted token +// pair to the dex module. It must specify a list of contract addresses and their respective +// token pairs to be registered. +type RegisterPairsProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + Batchcontractpair []BatchContractPair `protobuf:"bytes,3,rep,name=batchcontractpair,proto3" json:"batchcontractpair" yaml:"batch_contract_pair"` +} + +func (m *RegisterPairsProposal) Reset() { *m = RegisterPairsProposal{} } +func (*RegisterPairsProposal) ProtoMessage() {} +func (*RegisterPairsProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_dab07ca1a96062d0, []int{0} +} +func (m *RegisterPairsProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RegisterPairsProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RegisterPairsProposal.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 *RegisterPairsProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_RegisterPairsProposal.Merge(m, src) +} +func (m *RegisterPairsProposal) XXX_Size() int { + return m.Size() +} +func (m *RegisterPairsProposal) XXX_DiscardUnknown() { + xxx_messageInfo_RegisterPairsProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_RegisterPairsProposal proto.InternalMessageInfo + +func init() { + proto.RegisterType((*RegisterPairsProposal)(nil), "seiprotocol.seichain.dex.RegisterPairsProposal") +} + +func init() { proto.RegisterFile("dex/gov.proto", fileDescriptor_dab07ca1a96062d0) } + +var fileDescriptor_dab07ca1a96062d0 = []byte{ + // 316 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x50, 0x3f, 0x4b, 0x03, 0x31, + 0x14, 0xcf, 0xb5, 0x28, 0x78, 0xad, 0xa2, 0x87, 0xca, 0xd1, 0x21, 0x29, 0x19, 0xa4, 0x20, 0xcd, + 0x81, 0x2e, 0xd2, 0xf1, 0x1c, 0x5c, 0xcb, 0x8d, 0x2e, 0x25, 0x4d, 0xc3, 0x35, 0x70, 0x6d, 0x8e, + 0x24, 0x4a, 0x3b, 0xb8, 0x8a, 0xa3, 0xa3, 0x63, 0x3f, 0x4e, 0xc7, 0x8e, 0x4e, 0x87, 0xf4, 0x16, + 0xe7, 0xfb, 0x04, 0x92, 0x9c, 0x85, 0x82, 0xb8, 0xbd, 0x97, 0xdf, 0xdf, 0x3c, 0xff, 0x78, 0xc2, + 0x17, 0x51, 0x2a, 0x9f, 0x49, 0xae, 0xa4, 0x91, 0x41, 0xa8, 0xb9, 0x70, 0x13, 0x93, 0x19, 0xd1, + 0x5c, 0xb0, 0x29, 0x15, 0x73, 0x32, 0xe1, 0x8b, 0xce, 0x79, 0x2a, 0x53, 0xe9, 0xa0, 0xc8, 0x4e, + 0x35, 0xbf, 0x73, 0x62, 0xe5, 0x39, 0x15, 0xaa, 0xde, 0xf1, 0x6b, 0xc3, 0xbf, 0x48, 0x78, 0x2a, + 0xb4, 0xe1, 0x6a, 0x48, 0x85, 0xd2, 0x43, 0x25, 0x73, 0xa9, 0x69, 0x16, 0x5c, 0xf9, 0x07, 0x46, + 0x98, 0x8c, 0x87, 0x5e, 0xd7, 0xeb, 0x1d, 0xc5, 0xa7, 0x55, 0x81, 0xda, 0x4b, 0x3a, 0xcb, 0x06, + 0xd8, 0x3d, 0xe3, 0xa4, 0x86, 0x83, 0x3b, 0xbf, 0x35, 0xe1, 0x9a, 0x29, 0x91, 0x1b, 0x21, 0xe7, + 0x61, 0xc3, 0xb1, 0x2f, 0xab, 0x02, 0x05, 0x35, 0x7b, 0x0f, 0xc4, 0xc9, 0x3e, 0x35, 0x78, 0xf1, + 0xcf, 0xc6, 0xd4, 0xb0, 0x29, 0x93, 0x73, 0xa3, 0x28, 0x33, 0xb6, 0x56, 0xd8, 0xec, 0x36, 0x7b, + 0xad, 0x9b, 0x6b, 0xf2, 0xdf, 0xbf, 0x48, 0x6c, 0x25, 0xf7, 0xbf, 0x12, 0x5b, 0x39, 0xc6, 0xeb, + 0x02, 0x81, 0xaa, 0x40, 0x9d, 0x3a, 0xd0, 0x79, 0x8e, 0x76, 0xa6, 0x23, 0xeb, 0x8a, 0x93, 0xbf, + 0x49, 0x83, 0xf6, 0xdb, 0x0a, 0x81, 0x8f, 0x15, 0x02, 0xdf, 0x2b, 0x04, 0xe2, 0x87, 0xf5, 0x16, + 0x7a, 0x9b, 0x2d, 0xf4, 0xbe, 0xb6, 0xd0, 0x7b, 0x2f, 0x21, 0xd8, 0x94, 0x10, 0x7c, 0x96, 0x10, + 0x3c, 0xf6, 0x53, 0x61, 0xa6, 0x4f, 0x63, 0xc2, 0xe4, 0x2c, 0xd2, 0x5c, 0xf4, 0x77, 0xb5, 0xdc, + 0xe2, 0x7a, 0x45, 0x8b, 0xc8, 0x9e, 0xd5, 0x2c, 0x73, 0xae, 0xc7, 0x87, 0x0e, 0xbf, 0xfd, 0x09, + 0x00, 0x00, 0xff, 0xff, 0x29, 0xbc, 0x93, 0x10, 0xa9, 0x01, 0x00, 0x00, +} + +func (m *RegisterPairsProposal) 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 *RegisterPairsProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RegisterPairsProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Batchcontractpair) > 0 { + for iNdEx := len(m.Batchcontractpair) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Batchcontractpair[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGov(dAtA []byte, offset int, v uint64) int { + offset -= sovGov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *RegisterPairsProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + if len(m.Batchcontractpair) > 0 { + for _, e := range m.Batchcontractpair { + l = e.Size() + n += 1 + l + sovGov(uint64(l)) + } + } + return n +} + +func sovGov(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGov(x uint64) (n int) { + return sovGov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *RegisterPairsProposal) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RegisterPairsProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RegisterPairsProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Batchcontractpair", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Batchcontractpair = append(m.Batchcontractpair, BatchContractPair{}) + if err := m.Batchcontractpair[len(m.Batchcontractpair)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGov(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGov + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGov + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGov + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGov = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGov = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGov = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/dex/types/pair.pb.go b/x/dex/types/pair.pb.go index 5fe52e2363..4150e5a786 100644 --- a/x/dex/types/pair.pb.go +++ b/x/dex/types/pair.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -74,27 +75,85 @@ func (m *Pair) GetAssetDenom() Denom { return Denom_SEI } +type BatchContractPair struct { + ContractAddr string `protobuf:"bytes,1,opt,name=contractAddr,proto3" json:"contractAddr"` + Pairs []*Pair `protobuf:"bytes,2,rep,name=pairs,proto3" json:"pairs"` +} + +func (m *BatchContractPair) Reset() { *m = BatchContractPair{} } +func (m *BatchContractPair) String() string { return proto.CompactTextString(m) } +func (*BatchContractPair) ProtoMessage() {} +func (*BatchContractPair) Descriptor() ([]byte, []int) { + return fileDescriptor_d4350ebee878f69a, []int{1} +} +func (m *BatchContractPair) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BatchContractPair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BatchContractPair.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 *BatchContractPair) XXX_Merge(src proto.Message) { + xxx_messageInfo_BatchContractPair.Merge(m, src) +} +func (m *BatchContractPair) XXX_Size() int { + return m.Size() +} +func (m *BatchContractPair) XXX_DiscardUnknown() { + xxx_messageInfo_BatchContractPair.DiscardUnknown(m) +} + +var xxx_messageInfo_BatchContractPair proto.InternalMessageInfo + +func (m *BatchContractPair) GetContractAddr() string { + if m != nil { + return m.ContractAddr + } + return "" +} + +func (m *BatchContractPair) GetPairs() []*Pair { + if m != nil { + return m.Pairs + } + return nil +} + func init() { proto.RegisterType((*Pair)(nil), "seiprotocol.seichain.dex.Pair") + proto.RegisterType((*BatchContractPair)(nil), "seiprotocol.seichain.dex.BatchContractPair") } func init() { proto.RegisterFile("dex/pair.proto", fileDescriptor_d4350ebee878f69a) } var fileDescriptor_d4350ebee878f69a = []byte{ - // 195 bytes of a gzipped FileDescriptorProto + // 280 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4b, 0x49, 0xad, 0xd0, 0x2f, 0x48, 0xcc, 0x2c, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x28, 0x4e, 0xcd, 0x04, 0xb3, 0x92, 0xf3, 0x73, 0xf4, 0x8a, 0x53, 0x33, 0x93, 0x33, 0x12, 0x33, 0xf3, 0xf4, 0x52, 0x52, - 0x2b, 0xa4, 0xf8, 0x41, 0x2a, 0x53, 0xf3, 0x4a, 0x73, 0x8b, 0x21, 0x4a, 0x95, 0x3a, 0x18, 0xb9, - 0x58, 0x02, 0x12, 0x33, 0x8b, 0x84, 0xec, 0xb9, 0xb8, 0x0a, 0x8a, 0x32, 0x93, 0x53, 0x5d, 0x52, - 0xf3, 0xf2, 0x73, 0x25, 0x18, 0x15, 0x18, 0x35, 0xf8, 0x8c, 0xe4, 0xf5, 0x70, 0x19, 0xa4, 0x07, - 0x56, 0x16, 0x84, 0xa4, 0x05, 0x64, 0x40, 0x62, 0x71, 0x71, 0x6a, 0x09, 0xc4, 0x00, 0x26, 0x22, - 0x0d, 0x40, 0x68, 0x71, 0x72, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, - 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, - 0xdd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xe2, 0xd4, 0x4c, 0x5d, - 0x98, 0x89, 0x60, 0x0e, 0xd8, 0x48, 0xfd, 0x0a, 0x7d, 0x90, 0xcf, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, - 0x93, 0xd8, 0xc0, 0xf2, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x48, 0xd0, 0x33, 0x69, 0x17, - 0x01, 0x00, 0x00, + 0x2b, 0xa4, 0xf8, 0x41, 0x2a, 0x53, 0xf3, 0x4a, 0x73, 0x8b, 0x21, 0x4a, 0xa5, 0x44, 0xd2, 0xf3, + 0xd3, 0xf3, 0xc1, 0x4c, 0x7d, 0x10, 0x0b, 0x22, 0xaa, 0xd4, 0xc1, 0xc8, 0xc5, 0x12, 0x90, 0x98, + 0x59, 0x24, 0x64, 0xcf, 0xc5, 0x55, 0x50, 0x94, 0x99, 0x9c, 0xea, 0x92, 0x9a, 0x97, 0x9f, 0x2b, + 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x67, 0x24, 0xaf, 0x87, 0xcb, 0x78, 0x3d, 0xb0, 0xb2, 0x20, 0x24, + 0x2d, 0x20, 0x03, 0x12, 0x8b, 0x8b, 0x53, 0x4b, 0x20, 0x06, 0x30, 0x11, 0x69, 0x00, 0x42, 0x8b, + 0x52, 0x17, 0x23, 0x97, 0xa0, 0x53, 0x62, 0x49, 0x72, 0x86, 0x73, 0x7e, 0x5e, 0x49, 0x51, 0x62, + 0x72, 0x09, 0xd8, 0x5d, 0x26, 0x5c, 0x3c, 0xc9, 0x50, 0xbe, 0x63, 0x4a, 0x4a, 0x11, 0xd8, 0x65, + 0x9c, 0x4e, 0x02, 0xaf, 0xee, 0xc9, 0xa3, 0x88, 0x07, 0xa1, 0xf0, 0x84, 0xec, 0xb9, 0x58, 0x41, + 0xa1, 0x54, 0x2c, 0xc1, 0xa4, 0xc0, 0xac, 0xc1, 0x6d, 0x24, 0x87, 0xdb, 0x1d, 0x20, 0x4b, 0x9c, + 0x38, 0x5f, 0xdd, 0x93, 0x87, 0x68, 0x08, 0x82, 0x50, 0x4e, 0xee, 0x27, 0x1e, 0xc9, 0x31, 0x5e, + 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, + 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x9b, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, + 0xab, 0x5f, 0x9c, 0x9a, 0xa9, 0x0b, 0x33, 0x16, 0xcc, 0x01, 0x9b, 0xab, 0x5f, 0xa1, 0x0f, 0x0a, + 0xfc, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xbc, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, + 0x85, 0x86, 0x41, 0x0d, 0xba, 0x01, 0x00, 0x00, } func (m *Pair) Marshal() (dAtA []byte, err error) { @@ -130,6 +189,50 @@ func (m *Pair) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *BatchContractPair) 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 *BatchContractPair) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BatchContractPair) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Pairs) > 0 { + for iNdEx := len(m.Pairs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Pairs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPair(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.ContractAddr) > 0 { + i -= len(m.ContractAddr) + copy(dAtA[i:], m.ContractAddr) + i = encodeVarintPair(dAtA, i, uint64(len(m.ContractAddr))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintPair(dAtA []byte, offset int, v uint64) int { offset -= sovPair(v) base := offset @@ -156,6 +259,25 @@ func (m *Pair) Size() (n int) { return n } +func (m *BatchContractPair) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ContractAddr) + if l > 0 { + n += 1 + l + sovPair(uint64(l)) + } + if len(m.Pairs) > 0 { + for _, e := range m.Pairs { + l = e.Size() + n += 1 + l + sovPair(uint64(l)) + } + } + return n +} + func sovPair(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -250,6 +372,122 @@ func (m *Pair) Unmarshal(dAtA []byte) error { } return nil } +func (m *BatchContractPair) 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 ErrIntOverflowPair + } + 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: BatchContractPair: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BatchContractPair: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPair + } + 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 ErrInvalidLengthPair + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPair + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pairs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPair + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPair + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPair + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Pairs = append(m.Pairs, &Pair{}) + if err := m.Pairs[len(m.Pairs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPair(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPair + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipPair(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/dex/types/tx.pb.go b/x/dex/types/tx.pb.go index 11a5dd93cf..66e16c5168 100644 --- a/x/dex/types/tx.pb.go +++ b/x/dex/types/tx.pb.go @@ -334,102 +334,6 @@ func (m *MsgLiquidationResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgLiquidationResponse proto.InternalMessageInfo -type MsgRegisterPair struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - ContractAddr string `protobuf:"bytes,2,opt,name=contractAddr,proto3" json:"contractAddr,omitempty"` - Pair *Pair `protobuf:"bytes,3,opt,name=pair,proto3" json:"pair,omitempty"` -} - -func (m *MsgRegisterPair) Reset() { *m = MsgRegisterPair{} } -func (m *MsgRegisterPair) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterPair) ProtoMessage() {} -func (*MsgRegisterPair) Descriptor() ([]byte, []int) { - return fileDescriptor_463701e671e5a5e0, []int{6} -} -func (m *MsgRegisterPair) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRegisterPair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRegisterPair.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 *MsgRegisterPair) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterPair.Merge(m, src) -} -func (m *MsgRegisterPair) XXX_Size() int { - return m.Size() -} -func (m *MsgRegisterPair) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterPair.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRegisterPair proto.InternalMessageInfo - -func (m *MsgRegisterPair) GetCreator() string { - if m != nil { - return m.Creator - } - return "" -} - -func (m *MsgRegisterPair) GetContractAddr() string { - if m != nil { - return m.ContractAddr - } - return "" -} - -func (m *MsgRegisterPair) GetPair() *Pair { - if m != nil { - return m.Pair - } - return nil -} - -type MsgRegisterPairResponse struct { -} - -func (m *MsgRegisterPairResponse) Reset() { *m = MsgRegisterPairResponse{} } -func (m *MsgRegisterPairResponse) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterPairResponse) ProtoMessage() {} -func (*MsgRegisterPairResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_463701e671e5a5e0, []int{7} -} -func (m *MsgRegisterPairResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRegisterPairResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRegisterPairResponse.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 *MsgRegisterPairResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterPairResponse.Merge(m, src) -} -func (m *MsgRegisterPairResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgRegisterPairResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterPairResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRegisterPairResponse proto.InternalMessageInfo - type MsgRegisterContract struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` Contract *ContractInfo `protobuf:"bytes,2,opt,name=contract,proto3" json:"contract,omitempty"` @@ -439,7 +343,7 @@ func (m *MsgRegisterContract) Reset() { *m = MsgRegisterContract{} } func (m *MsgRegisterContract) String() string { return proto.CompactTextString(m) } func (*MsgRegisterContract) ProtoMessage() {} func (*MsgRegisterContract) Descriptor() ([]byte, []int) { - return fileDescriptor_463701e671e5a5e0, []int{8} + return fileDescriptor_463701e671e5a5e0, []int{6} } func (m *MsgRegisterContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -489,7 +393,7 @@ func (m *MsgRegisterContractResponse) Reset() { *m = MsgRegisterContract func (m *MsgRegisterContractResponse) String() string { return proto.CompactTextString(m) } func (*MsgRegisterContractResponse) ProtoMessage() {} func (*MsgRegisterContractResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_463701e671e5a5e0, []int{9} + return fileDescriptor_463701e671e5a5e0, []int{7} } func (m *MsgRegisterContractResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -525,8 +429,6 @@ func init() { proto.RegisterType((*MsgCancelOrdersResponse)(nil), "seiprotocol.seichain.dex.MsgCancelOrdersResponse") proto.RegisterType((*MsgLiquidation)(nil), "seiprotocol.seichain.dex.MsgLiquidation") proto.RegisterType((*MsgLiquidationResponse)(nil), "seiprotocol.seichain.dex.MsgLiquidationResponse") - proto.RegisterType((*MsgRegisterPair)(nil), "seiprotocol.seichain.dex.MsgRegisterPair") - proto.RegisterType((*MsgRegisterPairResponse)(nil), "seiprotocol.seichain.dex.MsgRegisterPairResponse") proto.RegisterType((*MsgRegisterContract)(nil), "seiprotocol.seichain.dex.MsgRegisterContract") proto.RegisterType((*MsgRegisterContractResponse)(nil), "seiprotocol.seichain.dex.MsgRegisterContractResponse") } @@ -534,47 +436,44 @@ func init() { func init() { proto.RegisterFile("dex/tx.proto", fileDescriptor_463701e671e5a5e0) } var fileDescriptor_463701e671e5a5e0 = []byte{ - // 634 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x41, 0x8f, 0xd2, 0x40, - 0x14, 0xa6, 0x0b, 0xae, 0xbb, 0x03, 0x59, 0x4d, 0x35, 0x5a, 0xaa, 0x76, 0x49, 0x0f, 0x06, 0x63, - 0x98, 0x2e, 0xa8, 0x77, 0x85, 0x83, 0xd9, 0x44, 0x22, 0x69, 0x3c, 0xe9, 0xc1, 0x0c, 0xd3, 0xd9, - 0xee, 0x44, 0xe8, 0x60, 0x67, 0x30, 0x78, 0xf1, 0xe2, 0x1f, 0xf0, 0x77, 0x18, 0x13, 0xff, 0xc6, - 0x1e, 0xf7, 0xe8, 0x49, 0x0d, 0xfc, 0x04, 0xff, 0x80, 0x99, 0xa1, 0xd3, 0x2d, 0x6b, 0x29, 0x78, - 0x62, 0xa6, 0xef, 0xbd, 0xef, 0xfb, 0xde, 0xd7, 0xf7, 0x0a, 0xa8, 0x05, 0x64, 0xe6, 0x89, 0x19, - 0x9c, 0xc4, 0x4c, 0x30, 0xd3, 0xe2, 0x84, 0xaa, 0x13, 0x66, 0x23, 0xc8, 0x09, 0xc5, 0xa7, 0x88, - 0x46, 0x30, 0x20, 0x33, 0xdb, 0xc1, 0x8c, 0x8f, 0x19, 0xf7, 0x86, 0x88, 0x13, 0xef, 0x43, 0x7b, - 0x48, 0x04, 0x6a, 0x7b, 0x98, 0xd1, 0x68, 0x59, 0x69, 0xdf, 0x0c, 0x59, 0xc8, 0xd4, 0xd1, 0x93, - 0xa7, 0xe4, 0x69, 0x5d, 0xa2, 0xb3, 0x38, 0x20, 0xf1, 0xdb, 0xc9, 0x08, 0x61, 0x32, 0x26, 0x91, - 0x48, 0x42, 0x77, 0x2f, 0x42, 0x18, 0x45, 0x98, 0x8c, 0x46, 0x48, 0x50, 0xa6, 0xe1, 0x0e, 0x64, - 0x74, 0x82, 0x68, 0x9c, 0xdc, 0x4d, 0x79, 0xc7, 0x2c, 0x12, 0x31, 0xc2, 0x09, 0x82, 0xfb, 0xc7, - 0x00, 0x07, 0x7d, 0x1e, 0x0e, 0x24, 0xf0, 0x4b, 0x09, 0xc4, 0x4d, 0x0b, 0x5c, 0xc5, 0x31, 0x41, - 0x82, 0xc5, 0x96, 0xd1, 0x30, 0x9a, 0xfb, 0xbe, 0xbe, 0x9a, 0x4f, 0xc1, 0xae, 0x22, 0xe3, 0xd6, - 0x4e, 0xa3, 0xdc, 0xac, 0x76, 0x9a, 0x70, 0x5d, 0xab, 0x50, 0x61, 0x0d, 0xb4, 0x5c, 0x3f, 0xa9, - 0x33, 0x5d, 0x50, 0xd3, 0x02, 0x9e, 0x05, 0x41, 0x6c, 0x95, 0x15, 0xc1, 0xca, 0x33, 0x13, 0x81, - 0x2b, 0x27, 0xd3, 0x28, 0xe0, 0x56, 0x45, 0x91, 0xd4, 0xe1, 0xd2, 0x35, 0x28, 0x5d, 0x83, 0x89, - 0x6b, 0xb0, 0xc7, 0x68, 0xd4, 0x3d, 0x3a, 0xfb, 0x79, 0x58, 0xfa, 0xfa, 0xeb, 0xb0, 0x19, 0x52, - 0x71, 0x3a, 0x1d, 0x42, 0xcc, 0xc6, 0x5e, 0x62, 0xf1, 0xf2, 0xa7, 0xc5, 0x83, 0x77, 0x9e, 0xf8, - 0x38, 0x21, 0x5c, 0x15, 0x70, 0x7f, 0x89, 0xec, 0x3e, 0x06, 0xb7, 0x56, 0x9b, 0xf6, 0x09, 0x9f, - 0xb0, 0x88, 0x13, 0xd3, 0x06, 0x7b, 0x4a, 0xea, 0x71, 0xc0, 0x2d, 0xa3, 0x51, 0x6e, 0x56, 0xfc, - 0xf4, 0xee, 0x7e, 0x33, 0xc0, 0xb5, 0x3e, 0x0f, 0x7b, 0xca, 0xe9, 0x8d, 0x66, 0xbd, 0x01, 0xa6, - 0xaa, 0xec, 0x65, 0x5e, 0x8c, 0x36, 0xee, 0xe1, 0x06, 0xe3, 0xb2, 0x35, 0x7e, 0x0e, 0xcc, 0x36, - 0x3e, 0xba, 0x75, 0x70, 0xfb, 0x92, 0x5a, 0xdd, 0xa5, 0xfb, 0x49, 0xbd, 0xf4, 0x17, 0xf4, 0xfd, - 0x94, 0x06, 0x0a, 0xb1, 0xa0, 0x0f, 0x08, 0x4c, 0x84, 0x31, 0x9b, 0x46, 0xe2, 0x15, 0xd3, 0x15, - 0xc4, 0xda, 0x51, 0x49, 0x39, 0x91, 0xad, 0xa4, 0x59, 0xca, 0xff, 0x0c, 0x7f, 0xaa, 0xec, 0xf3, - 0xd2, 0x63, 0x9f, 0x84, 0x94, 0x0b, 0x12, 0x0f, 0x10, 0x8d, 0x0b, 0xb4, 0x5d, 0xe6, 0xda, 0xc9, - 0x19, 0xa7, 0x0e, 0xa8, 0xc8, 0x1d, 0x50, 0x3a, 0xaa, 0x1d, 0x67, 0xbd, 0xf3, 0x92, 0xcb, 0x57, - 0xb9, 0x89, 0x75, 0x59, 0x11, 0xa9, 0x40, 0x0e, 0x6e, 0x64, 0x42, 0xbd, 0x84, 0xa9, 0x40, 0x63, - 0x17, 0xec, 0x69, 0x3d, 0x4a, 0x5f, 0xb5, 0x73, 0x7f, 0xbd, 0x06, 0x8d, 0x77, 0x1c, 0x9d, 0x30, - 0x3f, 0xad, 0x73, 0xef, 0x81, 0x3b, 0x39, 0xa4, 0x5a, 0x53, 0xe7, 0x7b, 0x05, 0x94, 0xfb, 0x3c, - 0x34, 0x29, 0xa8, 0x66, 0x17, 0xb9, 0x60, 0x3d, 0x57, 0xa7, 0xdf, 0x3e, 0xda, 0x36, 0x33, 0xdd, - 0x93, 0x11, 0xa8, 0xad, 0xec, 0xc1, 0x83, 0x42, 0x84, 0x6c, 0xaa, 0xdd, 0xde, 0x3a, 0x35, 0x65, - 0x0b, 0xc1, 0xfe, 0xc5, 0x80, 0x15, 0xb7, 0x95, 0x19, 0xaa, 0x0d, 0x6d, 0xe5, 0x8c, 0x9f, 0x6c, - 0x6b, 0x65, 0xf4, 0x8a, 0xdb, 0xca, 0xa6, 0x6e, 0x68, 0x2b, 0x6f, 0x96, 0xcc, 0x19, 0xb8, 0xfe, - 0xcf, 0x20, 0xb5, 0xb6, 0x82, 0xd1, 0xe9, 0xf6, 0x93, 0xff, 0x4a, 0xd7, 0xcc, 0xdd, 0xe7, 0x67, - 0x73, 0xc7, 0x38, 0x9f, 0x3b, 0xc6, 0xef, 0xb9, 0x63, 0x7c, 0x59, 0x38, 0xa5, 0xf3, 0x85, 0x53, - 0xfa, 0xb1, 0x70, 0x4a, 0xaf, 0x5b, 0x99, 0x6f, 0x29, 0x27, 0xb4, 0xa5, 0xb1, 0xd5, 0x45, 0x81, - 0x7b, 0x33, 0x4f, 0xfd, 0xdf, 0xc9, 0xcf, 0xea, 0x70, 0x57, 0xc5, 0x1f, 0xfd, 0x0d, 0x00, 0x00, - 0xff, 0xff, 0xba, 0xa1, 0x0c, 0x0d, 0x03, 0x07, 0x00, 0x00, + // 585 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xc1, 0x6e, 0xd3, 0x4c, + 0x10, 0x8e, 0x9b, 0xfe, 0xfd, 0xdb, 0x4d, 0x54, 0xd0, 0x82, 0xc0, 0x31, 0xe0, 0x46, 0x3e, 0xa0, + 0x20, 0x94, 0x75, 0x13, 0xe0, 0x0e, 0xc9, 0x01, 0x55, 0x22, 0xa2, 0xb2, 0x38, 0xc1, 0x01, 0x6d, + 0xd6, 0x5b, 0x77, 0x45, 0xe2, 0x0d, 0x9e, 0x0d, 0x0a, 0x17, 0x9e, 0x81, 0xe7, 0x40, 0xbc, 0x04, + 0xb7, 0x1e, 0x7b, 0xe4, 0x04, 0x28, 0x79, 0x04, 0x5e, 0x00, 0x79, 0xe3, 0x4d, 0x9d, 0x92, 0x3a, + 0xe1, 0x94, 0x1d, 0xcf, 0x7c, 0xdf, 0x7c, 0xf3, 0xcd, 0x66, 0x51, 0x35, 0xe4, 0x13, 0x5f, 0x4d, + 0xc8, 0x28, 0x91, 0x4a, 0x62, 0x1b, 0xb8, 0xd0, 0x27, 0x26, 0x07, 0x04, 0xb8, 0x60, 0xa7, 0x54, + 0xc4, 0x24, 0xe4, 0x13, 0xc7, 0x65, 0x12, 0x86, 0x12, 0xfc, 0x3e, 0x05, 0xee, 0x7f, 0x68, 0xf5, + 0xb9, 0xa2, 0x2d, 0x9f, 0x49, 0x11, 0xcf, 0x91, 0xce, 0xcd, 0x48, 0x46, 0x52, 0x1f, 0xfd, 0xf4, + 0x94, 0x7d, 0xad, 0xa5, 0xec, 0x32, 0x09, 0x79, 0xf2, 0x76, 0x34, 0xa0, 0x8c, 0x0f, 0x79, 0xac, + 0xb2, 0xd4, 0xdd, 0x8b, 0x14, 0xa3, 0x31, 0xe3, 0x83, 0x01, 0x55, 0x42, 0x1a, 0xba, 0xfd, 0x34, + 0x3b, 0xa2, 0x22, 0xc9, 0x62, 0x9c, 0xc6, 0x4c, 0xc6, 0x2a, 0xa1, 0x2c, 0x63, 0xf0, 0x7e, 0x5b, + 0x68, 0xbf, 0x07, 0xd1, 0x71, 0x4a, 0xfc, 0x32, 0x25, 0x02, 0x6c, 0xa3, 0xff, 0x59, 0xc2, 0xa9, + 0x92, 0x89, 0x6d, 0xd5, 0xad, 0xc6, 0x5e, 0x60, 0x42, 0xfc, 0x14, 0xed, 0xe8, 0x66, 0x60, 0x6f, + 0xd5, 0xcb, 0x8d, 0x4a, 0xbb, 0x41, 0xae, 0x1a, 0x95, 0x68, 0xae, 0x63, 0x23, 0x37, 0xc8, 0x70, + 0xd8, 0x43, 0x55, 0x23, 0xe0, 0x59, 0x18, 0x26, 0x76, 0x59, 0x37, 0x58, 0xfa, 0x86, 0x29, 0xfa, + 0xef, 0x64, 0x1c, 0x87, 0x60, 0x6f, 0xeb, 0x26, 0x35, 0x32, 0x77, 0x8d, 0xa4, 0xae, 0x91, 0xcc, + 0x35, 0xd2, 0x95, 0x22, 0xee, 0x1c, 0x9e, 0xfd, 0x38, 0x28, 0x7d, 0xf9, 0x79, 0xd0, 0x88, 0x84, + 0x3a, 0x1d, 0xf7, 0x09, 0x93, 0x43, 0x3f, 0xb3, 0x78, 0xfe, 0xd3, 0x84, 0xf0, 0x9d, 0xaf, 0x3e, + 0x8e, 0x38, 0x68, 0x00, 0x04, 0x73, 0x66, 0xef, 0x31, 0xba, 0xb5, 0x3c, 0x74, 0xc0, 0x61, 0x24, + 0x63, 0xe0, 0xd8, 0x41, 0xbb, 0x5a, 0xea, 0x51, 0x08, 0xb6, 0x55, 0x2f, 0x37, 0xb6, 0x83, 0x45, + 0xec, 0x7d, 0xb5, 0xd0, 0xb5, 0x1e, 0x44, 0x5d, 0xed, 0xf4, 0x5a, 0xb3, 0xde, 0x20, 0xac, 0x91, + 0xdd, 0xdc, 0x62, 0x8c, 0x71, 0x0f, 0xd7, 0x18, 0x97, 0xc7, 0x04, 0x2b, 0x68, 0x36, 0xf1, 0xd1, + 0xab, 0xa1, 0xdb, 0x97, 0xd4, 0x9a, 0x29, 0xbd, 0x4f, 0x7a, 0xe9, 0x2f, 0xc4, 0xfb, 0xb1, 0x08, + 0x35, 0x63, 0xc1, 0x1c, 0x04, 0x61, 0xca, 0x98, 0x1c, 0xc7, 0xea, 0x95, 0x34, 0x08, 0x6e, 0x6f, + 0xe9, 0xa2, 0x15, 0x99, 0x8d, 0xa4, 0xd9, 0xda, 0xff, 0x5c, 0xff, 0x85, 0x32, 0x40, 0x37, 0x7a, + 0x10, 0x05, 0x3c, 0x12, 0xa0, 0x78, 0xd2, 0xcd, 0x40, 0x05, 0xf2, 0x3a, 0x68, 0xd7, 0x50, 0x6b, + 0x51, 0x95, 0xf6, 0xfd, 0xab, 0xcd, 0x35, 0x7c, 0x47, 0xf1, 0x89, 0x0c, 0x16, 0x38, 0xef, 0x1e, + 0xba, 0xb3, 0xa2, 0xa9, 0xd1, 0xd4, 0xfe, 0x56, 0x46, 0xe5, 0x1e, 0x44, 0x58, 0xa0, 0x4a, 0xfe, + 0x7f, 0x52, 0x70, 0xfb, 0x97, 0x2f, 0x97, 0x73, 0xb8, 0x69, 0xe5, 0xe2, 0x1a, 0x0e, 0x50, 0x75, + 0xe9, 0x9a, 0x3d, 0x28, 0x64, 0xc8, 0x97, 0x3a, 0xad, 0x8d, 0x4b, 0x17, 0xdd, 0x22, 0xb4, 0x77, + 0xb1, 0xbf, 0xe2, 0xb1, 0x72, 0x3b, 0x5b, 0x33, 0xd6, 0x8a, 0xed, 0xe2, 0x09, 0xba, 0xfe, 0xd7, + 0x6a, 0x9b, 0x85, 0x2c, 0x97, 0xcb, 0x9d, 0x27, 0xff, 0x54, 0x6e, 0x3a, 0x77, 0x9e, 0x9f, 0x4d, + 0x5d, 0xeb, 0x7c, 0xea, 0x5a, 0xbf, 0xa6, 0xae, 0xf5, 0x79, 0xe6, 0x96, 0xce, 0x67, 0x6e, 0xe9, + 0xfb, 0xcc, 0x2d, 0xbd, 0x6e, 0xe6, 0x1e, 0x0f, 0xe0, 0xa2, 0x69, 0xb8, 0x75, 0xa0, 0xc9, 0xfd, + 0x89, 0xaf, 0x1f, 0xf8, 0xf4, 0x1d, 0xe9, 0xef, 0xe8, 0xfc, 0xa3, 0x3f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0xeb, 0xf8, 0x79, 0x77, 0xf4, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -592,7 +491,6 @@ type MsgClient interface { PlaceOrders(ctx context.Context, in *MsgPlaceOrders, opts ...grpc.CallOption) (*MsgPlaceOrdersResponse, error) CancelOrders(ctx context.Context, in *MsgCancelOrders, opts ...grpc.CallOption) (*MsgCancelOrdersResponse, error) Liquidate(ctx context.Context, in *MsgLiquidation, opts ...grpc.CallOption) (*MsgLiquidationResponse, error) - RegisterPair(ctx context.Context, in *MsgRegisterPair, opts ...grpc.CallOption) (*MsgRegisterPairResponse, error) RegisterContract(ctx context.Context, in *MsgRegisterContract, opts ...grpc.CallOption) (*MsgRegisterContractResponse, error) } @@ -631,15 +529,6 @@ func (c *msgClient) Liquidate(ctx context.Context, in *MsgLiquidation, opts ...g return out, nil } -func (c *msgClient) RegisterPair(ctx context.Context, in *MsgRegisterPair, opts ...grpc.CallOption) (*MsgRegisterPairResponse, error) { - out := new(MsgRegisterPairResponse) - err := c.cc.Invoke(ctx, "/seiprotocol.seichain.dex.Msg/RegisterPair", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) RegisterContract(ctx context.Context, in *MsgRegisterContract, opts ...grpc.CallOption) (*MsgRegisterContractResponse, error) { out := new(MsgRegisterContractResponse) err := c.cc.Invoke(ctx, "/seiprotocol.seichain.dex.Msg/RegisterContract", in, out, opts...) @@ -654,7 +543,6 @@ type MsgServer interface { PlaceOrders(context.Context, *MsgPlaceOrders) (*MsgPlaceOrdersResponse, error) CancelOrders(context.Context, *MsgCancelOrders) (*MsgCancelOrdersResponse, error) Liquidate(context.Context, *MsgLiquidation) (*MsgLiquidationResponse, error) - RegisterPair(context.Context, *MsgRegisterPair) (*MsgRegisterPairResponse, error) RegisterContract(context.Context, *MsgRegisterContract) (*MsgRegisterContractResponse, error) } @@ -671,9 +559,6 @@ func (*UnimplementedMsgServer) CancelOrders(ctx context.Context, req *MsgCancelO func (*UnimplementedMsgServer) Liquidate(ctx context.Context, req *MsgLiquidation) (*MsgLiquidationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Liquidate not implemented") } -func (*UnimplementedMsgServer) RegisterPair(ctx context.Context, req *MsgRegisterPair) (*MsgRegisterPairResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisterPair not implemented") -} func (*UnimplementedMsgServer) RegisterContract(ctx context.Context, req *MsgRegisterContract) (*MsgRegisterContractResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RegisterContract not implemented") } @@ -736,24 +621,6 @@ func _Msg_Liquidate_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } -func _Msg_RegisterPair_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRegisterPair) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).RegisterPair(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/seiprotocol.seichain.dex.Msg/RegisterPair", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RegisterPair(ctx, req.(*MsgRegisterPair)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_RegisterContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgRegisterContract) if err := dec(in); err != nil { @@ -788,10 +655,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "Liquidate", Handler: _Msg_Liquidate_Handler, }, - { - MethodName: "RegisterPair", - Handler: _Msg_RegisterPair_Handler, - }, { MethodName: "RegisterContract", Handler: _Msg_RegisterContract_Handler, @@ -1048,78 +911,6 @@ func (m *MsgLiquidationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *MsgRegisterPair) 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 *MsgRegisterPair) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRegisterPair) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pair != nil { - { - size, err := m.Pair.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if len(m.ContractAddr) > 0 { - i -= len(m.ContractAddr) - copy(dAtA[i:], m.ContractAddr) - i = encodeVarintTx(dAtA, i, uint64(len(m.ContractAddr))) - i-- - dAtA[i] = 0x12 - } - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgRegisterPairResponse) 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 *MsgRegisterPairResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRegisterPairResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - func (m *MsgRegisterContract) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1303,36 +1094,6 @@ func (m *MsgLiquidationResponse) Size() (n int) { return n } -func (m *MsgRegisterPair) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ContractAddr) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Pair != nil { - l = m.Pair.Size() - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgRegisterPairResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - func (m *MsgRegisterContract) Size() (n int) { if m == nil { return 0 @@ -2067,206 +1828,6 @@ func (m *MsgLiquidationResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgRegisterPair) 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: MsgRegisterPair: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterPair: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ContractAddr", 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.ContractAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pair", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pair == nil { - m.Pair = &Pair{} - } - if err := m.Pair.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 *MsgRegisterPairResponse) 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: MsgRegisterPairResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterPairResponse: 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 *MsgRegisterContract) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 From 8a9db901f28b041ab9aeadc9e40b8a0dd55b1c23 Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Mon, 27 Jun 2022 17:05:35 -0700 Subject: [PATCH 4/6] Address comments --- x/dex/handler.go | 6 +----- x/dex/types/gov.go | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/x/dex/handler.go b/x/dex/handler.go index aca47fea5b..63f8d602af 100644 --- a/x/dex/handler.go +++ b/x/dex/handler.go @@ -44,13 +44,9 @@ func NewRegisterPairsProposalHandler(k keeper.Keeper) govtypes.Handler { return func(ctx sdk.Context, content govtypes.Content) error { switch c := content.(type) { case *types.RegisterPairsProposal: - return handleRegisterPairsProposal(ctx, k, c) + return k.HandleRegisterPairsProposal(ctx, c) default: return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized dex proposal content type: %T", c) } } } - -func handleRegisterPairsProposal(ctx sdk.Context, k keeper.Keeper, p *types.RegisterPairsProposal) error { - return k.HandleRegisterPairsProposal(ctx, p) -} diff --git a/x/dex/types/gov.go b/x/dex/types/gov.go index 18e8135399..2c4e6a6f1f 100644 --- a/x/dex/types/gov.go +++ b/x/dex/types/gov.go @@ -48,7 +48,7 @@ func (p RegisterPairsProposal) String() string { batchContractPairRecords += contractPair.String() } var b strings.Builder - b.WriteString(fmt.Sprintf(`Update Fee Token Proposal: + b.WriteString(fmt.Sprintf(`Register Pairs Proposal: Title: %s Description: %s Records: %s From 7de67352b3ff14a202beb5a051171397fe9cd6c3 Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Tue, 28 Jun 2022 21:07:01 -0700 Subject: [PATCH 5/6] CLI update --- proto/dex/pair.proto | 2 +- x/dex/README.md | 17 ++++++ x/dex/client/cli/gov_tx.go | 56 ++++++++++++++++++++ x/dex/client/cli/tx.go | 1 + x/dex/client/utils/utils.go | 100 ++++++++++++++++++++++++++++++++++++ 5 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 x/dex/client/cli/gov_tx.go create mode 100644 x/dex/client/utils/utils.go diff --git a/proto/dex/pair.proto b/proto/dex/pair.proto index 661b864f15..70e0acbcc4 100644 --- a/proto/dex/pair.proto +++ b/proto/dex/pair.proto @@ -12,6 +12,6 @@ message Pair { } message BatchContractPair { - string contractAddr = 1 [(gogoproto.jsontag) = "contractAddr"]; + string contractAddr = 1 [(gogoproto.jsontag) = "contract_addr"]; repeated Pair pairs = 2 [(gogoproto.jsontag) = "pairs"]; } diff --git a/x/dex/README.md b/x/dex/README.md index fca2c094fc..e9e102e514 100644 --- a/x/dex/README.md +++ b/x/dex/README.md @@ -8,6 +8,22 @@ TODO: Populate dex README Contents below. ## State +## Governance + +Token pairs can be whitelisted with a contract address to the `dex` module via governance. The following is an example +proposal json to whitelist a token pair. + +```json + "dex": { + "params": { + "code_upload_access": { + "permission": "Everybody" + }, + "instantiate_default_permission": "Everybody" + } + }, +``` + ## Messages ## Events @@ -19,3 +35,4 @@ TODO: Populate dex README Contents below. ## Transactions ## Queries + diff --git a/x/dex/client/cli/gov_tx.go b/x/dex/client/cli/gov_tx.go new file mode 100644 index 0000000000..87b1fdb452 --- /dev/null +++ b/x/dex/client/cli/gov_tx.go @@ -0,0 +1,56 @@ +package cli + +import ( + + "github.com/sei-protocol/sei-chain/x/dex/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + cutils "github.com/sei-protocol/sei-chain/x/dex/client/utils" + + "github.com/spf13/cobra" +) + +// NewSubmitParamChangeProposalTxCmd returns a CLI command handler for creating +// a parameter change proposal governance transaction. +func NewRegisterPairsProposalTxCmd() *cobra.Command { + return &cobra.Command{ + Use: "register-pairs-proposal [proposal-file]", + Args: cobra.ExactArgs(1), + Short: "Submit a register pairs proposal", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + proposal, err := cutils.ParseRegisterPairsProposalJSON(clientCtx.LegacyAmino, args[0]) + if err != nil { + return err + } + + // Convert proposal to RegisterPairsProposal Type + from := clientCtx.GetFromAddress() + proposal_batch_contract_pair, err := proposal.BatchContractPair.ToMultipleBatchContractPair() + if err != nil { + return err + } + content := types.NewRegisterPairsProposal( + proposal.Title, proposal.Description, proposal_batch_contract_pair, + ) + + deposit, err := sdk.ParseCoinsNormalized(proposal.Deposit) + if err != nil { + return err + } + + msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, from) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } +} diff --git a/x/dex/client/cli/tx.go b/x/dex/client/cli/tx.go index 69d9815d4c..d5d2406f20 100644 --- a/x/dex/client/cli/tx.go +++ b/x/dex/client/cli/tx.go @@ -31,6 +31,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdCancelOrders()) cmd.AddCommand(CmdLiquidate()) cmd.AddCommand(CmdRegisterContract()) + cmd.AddCommand(NewRegisterPairsProposalTxCmd()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/dex/client/utils/utils.go b/x/dex/client/utils/utils.go new file mode 100644 index 0000000000..8520579b4f --- /dev/null +++ b/x/dex/client/utils/utils.go @@ -0,0 +1,100 @@ +package utils + +import ( + "errors" + "io/ioutil" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/sei-protocol/sei-chain/x/dex/types" +) + +type ( + PairJSON struct { + PriceDenom string `json:"price_denom" yaml:"price_denom"` + AssetDenom string `json:"asset_denom" yaml:"asset_denom"` + } + + PairsJSON []PairJSON + + // ParamChangeJSON defines a parameter change used in JSON input. This + // allows values to be specified in raw JSON instead of being string encoded. + BatchContractPairJSON struct { + ContractAddr string `json:"contract_addr" yaml:"contract_addr"` + Pairs PairsJSON `json:"pairs" yaml:"pairs"` + } + + MultipleBatchContractPairJSON []BatchContractPairJSON + + // RegisterPairsProposalJSON defines a RegisterPairsProposal + // to parse register pair proposals from a JSON file. + RegisterPairsProposalJSON struct { + Title string `json:"title" yaml:"title"` + Description string `json:"description" yaml:"description"` + BatchContractPair MultipleBatchContractPairJSON `json:"batch_contract_pair" yaml:"batch_contract_pair"` + Deposit string `json:"deposit" yaml:"deposit"` + } +) + +// TODO: ADD utils to convert Each type to dex/type (string to denom) +func NewPair(pair PairJSON) (types.Pair, error) { + + PriceDenom, unit, err := types.GetDenomFromStr(pair.PriceDenom) + if err != nil { + return types.Pair{}, err + } + if unit != types.Unit_STANDARD { + return types.Pair{}, errors.New("Denom must be in standard/whole unit (e.g. sei instead of usei)") + } + AssetDenom, unit, err := types.GetDenomFromStr(pair.AssetDenom) + if err != nil { + return types.Pair{}, err + } + if unit != types.Unit_STANDARD { + return types.Pair{}, errors.New("Denom must be in standard/whole unit (e.g. sei instead of usei)") + } + return types.Pair{PriceDenom, AssetDenom}, nil +} + +// ToParamChange converts a ParamChangeJSON object to ParamChange. +func (bcp BatchContractPairJSON) ToBatchContractPair() (types.BatchContractPair, error) { + pairs := make([]*types.Pair, len(bcp.Pairs)) + for i, p := range bcp.Pairs { + new_pair, err := NewPair(p) + if err != nil { + return types.BatchContractPair{}, nil + } + pairs[i] = &new_pair + } + return types.BatchContractPair{bcp.ContractAddr, pairs}, nil +} + +// ToParamChanges converts a slice of ParamChangeJSON objects to a slice of +// ParamChange. +func (mbcp MultipleBatchContractPairJSON) ToMultipleBatchContractPair() ([]types.BatchContractPair, error) { + res := make([]types.BatchContractPair, len(mbcp)) + for i, bcp := range mbcp { + new_batch, err := bcp.ToBatchContractPair() + if err != nil { + return res, nil + } + res[i] = new_batch + } + return res, nil +} + +// ParseRegisterPairsProposalJSON reads and parses a RegisterPairsProposalJSON from +// a file. +func ParseRegisterPairsProposalJSON(cdc *codec.LegacyAmino, proposalFile string) (RegisterPairsProposalJSON, error) { + proposal := RegisterPairsProposalJSON{} + + contents, err := ioutil.ReadFile(proposalFile) + if err != nil { + return proposal, err + } + + if err := cdc.UnmarshalJSON(contents, &proposal); err != nil { + return proposal, err + } + + return proposal, nil +} From dd21afcbed73a61be735e6330f53804edda5b76c Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Wed, 29 Jun 2022 10:36:07 -0700 Subject: [PATCH 6/6] Fix merge conflicts --- proto/dex/pair.proto | 8 ++++++-- x/dex/types/pair.pb.go | 37 +++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/proto/dex/pair.proto b/proto/dex/pair.proto index 70e0acbcc4..10947beaeb 100644 --- a/proto/dex/pair.proto +++ b/proto/dex/pair.proto @@ -7,8 +7,12 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/sei-protocol/sei-chain/x/dex/types"; message Pair { - Denom priceDenom = 1; - Denom assetDenom = 2; + Denom priceDenom = 1 [ + (gogoproto.jsontag) = "price_denom" + ]; + Denom assetDenom = 2 [ + (gogoproto.jsontag) = "asset_denom" + ]; } message BatchContractPair { diff --git a/x/dex/types/pair.pb.go b/x/dex/types/pair.pb.go index 4150e5a786..e425a6f459 100644 --- a/x/dex/types/pair.pb.go +++ b/x/dex/types/pair.pb.go @@ -24,8 +24,8 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Pair struct { - PriceDenom Denom `protobuf:"varint,1,opt,name=priceDenom,proto3,enum=seiprotocol.seichain.dex.Denom" json:"priceDenom,omitempty"` - AssetDenom Denom `protobuf:"varint,2,opt,name=assetDenom,proto3,enum=seiprotocol.seichain.dex.Denom" json:"assetDenom,omitempty"` + PriceDenom Denom `protobuf:"varint,1,opt,name=priceDenom,proto3,enum=seiprotocol.seichain.dex.Denom" json:"price_denom"` + AssetDenom Denom `protobuf:"varint,2,opt,name=assetDenom,proto3,enum=seiprotocol.seichain.dex.Denom" json:"asset_denom"` } func (m *Pair) Reset() { *m = Pair{} } @@ -76,7 +76,7 @@ func (m *Pair) GetAssetDenom() Denom { } type BatchContractPair struct { - ContractAddr string `protobuf:"bytes,1,opt,name=contractAddr,proto3" json:"contractAddr"` + ContractAddr string `protobuf:"bytes,1,opt,name=contractAddr,proto3" json:"contract_addr"` Pairs []*Pair `protobuf:"bytes,2,rep,name=pairs,proto3" json:"pairs"` } @@ -135,25 +135,26 @@ func init() { func init() { proto.RegisterFile("dex/pair.proto", fileDescriptor_d4350ebee878f69a) } var fileDescriptor_d4350ebee878f69a = []byte{ - // 280 bytes of a gzipped FileDescriptorProto + // 303 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4b, 0x49, 0xad, 0xd0, 0x2f, 0x48, 0xcc, 0x2c, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x28, 0x4e, 0xcd, 0x04, 0xb3, 0x92, 0xf3, 0x73, 0xf4, 0x8a, 0x53, 0x33, 0x93, 0x33, 0x12, 0x33, 0xf3, 0xf4, 0x52, 0x52, 0x2b, 0xa4, 0xf8, 0x41, 0x2a, 0x53, 0xf3, 0x4a, 0x73, 0x8b, 0x21, 0x4a, 0xa5, 0x44, 0xd2, 0xf3, - 0xd3, 0xf3, 0xc1, 0x4c, 0x7d, 0x10, 0x0b, 0x22, 0xaa, 0xd4, 0xc1, 0xc8, 0xc5, 0x12, 0x90, 0x98, - 0x59, 0x24, 0x64, 0xcf, 0xc5, 0x55, 0x50, 0x94, 0x99, 0x9c, 0xea, 0x92, 0x9a, 0x97, 0x9f, 0x2b, - 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x67, 0x24, 0xaf, 0x87, 0xcb, 0x78, 0x3d, 0xb0, 0xb2, 0x20, 0x24, - 0x2d, 0x20, 0x03, 0x12, 0x8b, 0x8b, 0x53, 0x4b, 0x20, 0x06, 0x30, 0x11, 0x69, 0x00, 0x42, 0x8b, - 0x52, 0x17, 0x23, 0x97, 0xa0, 0x53, 0x62, 0x49, 0x72, 0x86, 0x73, 0x7e, 0x5e, 0x49, 0x51, 0x62, - 0x72, 0x09, 0xd8, 0x5d, 0x26, 0x5c, 0x3c, 0xc9, 0x50, 0xbe, 0x63, 0x4a, 0x4a, 0x11, 0xd8, 0x65, - 0x9c, 0x4e, 0x02, 0xaf, 0xee, 0xc9, 0xa3, 0x88, 0x07, 0xa1, 0xf0, 0x84, 0xec, 0xb9, 0x58, 0x41, - 0xa1, 0x54, 0x2c, 0xc1, 0xa4, 0xc0, 0xac, 0xc1, 0x6d, 0x24, 0x87, 0xdb, 0x1d, 0x20, 0x4b, 0x9c, - 0x38, 0x5f, 0xdd, 0x93, 0x87, 0x68, 0x08, 0x82, 0x50, 0x4e, 0xee, 0x27, 0x1e, 0xc9, 0x31, 0x5e, - 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, - 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x9b, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, - 0xab, 0x5f, 0x9c, 0x9a, 0xa9, 0x0b, 0x33, 0x16, 0xcc, 0x01, 0x9b, 0xab, 0x5f, 0xa1, 0x0f, 0x0a, - 0xfc, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xbc, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, - 0x85, 0x86, 0x41, 0x0d, 0xba, 0x01, 0x00, 0x00, + 0xd3, 0xf3, 0xc1, 0x4c, 0x7d, 0x10, 0x0b, 0x22, 0xaa, 0xb4, 0x8a, 0x91, 0x8b, 0x25, 0x20, 0x31, + 0xb3, 0x48, 0x28, 0x80, 0x8b, 0xab, 0xa0, 0x28, 0x33, 0x39, 0xd5, 0x25, 0x35, 0x2f, 0x3f, 0x57, + 0x82, 0x51, 0x81, 0x51, 0x83, 0xcf, 0x48, 0x5e, 0x0f, 0x97, 0xf1, 0x7a, 0x60, 0x65, 0x4e, 0xfc, + 0xaf, 0xee, 0xc9, 0x73, 0x83, 0xb5, 0xc5, 0xa7, 0x80, 0x04, 0x82, 0x90, 0xcc, 0x00, 0x99, 0x98, + 0x58, 0x5c, 0x9c, 0x5a, 0x02, 0x31, 0x91, 0x89, 0x04, 0x13, 0xc1, 0xda, 0x60, 0x26, 0x22, 0xcc, + 0x50, 0xea, 0x66, 0xe4, 0x12, 0x74, 0x4a, 0x2c, 0x49, 0xce, 0x70, 0xce, 0xcf, 0x2b, 0x29, 0x4a, + 0x4c, 0x2e, 0x01, 0xbb, 0xdc, 0x94, 0x8b, 0x27, 0x19, 0xca, 0x77, 0x4c, 0x49, 0x29, 0x02, 0xbb, + 0x9d, 0xd3, 0x49, 0xf0, 0xd5, 0x3d, 0x79, 0x5e, 0x98, 0x78, 0x7c, 0x62, 0x4a, 0x4a, 0x51, 0x10, + 0x8a, 0x32, 0x21, 0x7b, 0x2e, 0x56, 0x50, 0x40, 0x16, 0x4b, 0x30, 0x29, 0x30, 0x6b, 0x70, 0x1b, + 0xc9, 0xe1, 0x76, 0x19, 0xc8, 0x16, 0x27, 0xce, 0x57, 0xf7, 0xe4, 0x21, 0x1a, 0x82, 0x20, 0x94, + 0x93, 0xfb, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, + 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa6, 0x67, 0x96, + 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x17, 0xa7, 0x66, 0xea, 0xc2, 0x8c, 0x05, 0x73, + 0xc0, 0xe6, 0xea, 0x57, 0xe8, 0x83, 0xe2, 0xa7, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x2c, + 0x6f, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x58, 0x0d, 0x63, 0xcc, 0xdd, 0x01, 0x00, 0x00, } func (m *Pair) Marshal() (dAtA []byte, err error) {