From d2c793b49b13c682c7702a1c5ff15229d890845a Mon Sep 17 00:00:00 2001 From: Michael Tsitrin Date: Sun, 8 Sep 2024 17:05:15 +0300 Subject: [PATCH] added cli --- proto/dymensionxyz/dymension/iro/query.proto | 79 +++-- proto/dymensionxyz/dymension/iro/tx.proto | 20 +- x/iro/cli/cli_test.go | 10 +- x/iro/cli/query.go | 198 ++++++++++++- x/iro/cli/tx.go | 148 +--------- x/iro/cli/tx_claim.go | 39 +++ x/iro/cli/tx_create_iro.go | 163 +++++++++++ x/iro/cli/tx_trade.go | 83 ++++++ x/iro/keeper/query.go | 15 +- x/iro/keeper/trade.go | 4 +- x/iro/module.go | 2 +- x/iro/types/query.pb.go | 166 +++++------ x/iro/types/tx.pb.go | 291 ++++++++----------- 13 files changed, 750 insertions(+), 468 deletions(-) create mode 100644 x/iro/cli/tx_claim.go create mode 100644 x/iro/cli/tx_create_iro.go create mode 100644 x/iro/cli/tx_trade.go diff --git a/proto/dymensionxyz/dymension/iro/query.proto b/proto/dymensionxyz/dymension/iro/query.proto index b10011795..6ea1e21cb 100644 --- a/proto/dymensionxyz/dymension/iro/query.proto +++ b/proto/dymensionxyz/dymension/iro/query.proto @@ -23,28 +23,33 @@ service Query { // Plan returns the plan for the specified plan ID. rpc QueryPlan(QueryPlanRequest) returns (QueryPlanResponse) { - option (google.api.http).get = "/dymensionxyz/dymension/iro/plans/{plan_id}"; + option (google.api.http).get = + "/dymensionxyz/dymension/iro/plans/{plan_id}"; } // PlanByRollapp returns the plans for the specified rollapp ID. - rpc QueryPlanByRollapp(QueryPlanByRollappRequest) returns (QueryPlanByRollappResponse) { - option (google.api.http).get = "/dymensionxyz/dymension/iro/plans_by_rollapp/{rollapp_id}"; + rpc QueryPlanByRollapp(QueryPlanByRollappRequest) + returns (QueryPlanByRollappResponse) { + option (google.api.http).get = + "/dymensionxyz/dymension/iro/plans_by_rollapp/{rollapp_id}"; } // Price returns the current price for 1 IRO token for the specified plan ID. rpc QueryPrice(QueryPriceRequest) returns (QueryPriceResponse) { - option (google.api.http).get = "/dymensionxyz/dymension/iro/price/{plan_id}"; + option (google.api.http).get = + "/dymensionxyz/dymension/iro/price/{plan_id}"; } - // Cost returns the expected cost for buying or selling the specified amount of shares. + // Cost returns the expected cost for buying or selling the specified amount + // of shares. rpc QueryCost(QueryCostRequest) returns (QueryCostResponse) { option (google.api.http).get = "/dymensionxyz/dymension/iro/cost/{plan_id}"; } - // Claimed returns the claimed amount thus far for the specified plan ID. rpc QueryClaimed(QueryClaimedRequest) returns (QueryClaimedResponse) { - option (google.api.http).get = "/dymensionxyz/dymension/iro/claimed/{plan_id}"; + option (google.api.http).get = + "/dymensionxyz/dymension/iro/claimed/{plan_id}"; } } @@ -54,67 +59,57 @@ message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. message QueryParamsResponse { // params holds all the parameters of this module. - Params params = 1 [(gogoproto.nullable) = false]; + Params params = 1 [ (gogoproto.nullable) = false ]; } - // QueryPlanRequest is the request type for the Query/QueryPlan RPC method. -message QueryPlansRequest { -} +message QueryPlansRequest {} // QueryPlanResponse is the response type for the Query/QueryPlan RPC method. message QueryPlansResponse { - repeated Plan plans = 1 [(gogoproto.nullable) = false]; + repeated Plan plans = 1 [ (gogoproto.nullable) = false ]; } // QueryPlanRequest is the request type for the Query/QueryPlan RPC method. -message QueryPlanRequest { - string plan_id = 1; -} +message QueryPlanRequest { string plan_id = 1; } // QueryPlanResponse is the response type for the Query/QueryPlan RPC method. -message QueryPlanResponse { - Plan plan = 1; -} +message QueryPlanResponse { Plan plan = 1; } -// QueryPlanByRollappRequest is the request type for the Query/QueryPlanByRollapp RPC method. -message QueryPlanByRollappRequest { - string rollapp_id = 1; -} +// QueryPlanByRollappRequest is the request type for the +// Query/QueryPlanByRollapp RPC method. +message QueryPlanByRollappRequest { string rollapp_id = 1; } -// QueryPlanByRollappResponse is the response type for the Query/QueryPlanByRollapp RPC method. -message QueryPlanByRollappResponse { - Plan plan = 1; -} +// QueryPlanByRollappResponse is the response type for the +// Query/QueryPlanByRollapp RPC method. +message QueryPlanByRollappResponse { Plan plan = 1; } // QueryPriceRequest is the request type for the Query/QueryPrice RPC method. -message QueryPriceRequest { - string plan_id = 1; -} +message QueryPriceRequest { string plan_id = 1; } // QueryPriceResponse is the response type for the Query/QueryPrice RPC method. -message QueryPriceResponse { - cosmos.base.v1beta1.Coin price = 1; -} +message QueryPriceResponse { cosmos.base.v1beta1.Coin price = 1; } // QueryCostRequest is the request type for the Query/QueryCost RPC method. message QueryCostRequest { string plan_id = 1; - cosmos.base.v1beta1.Coin amt = 2; + string amt = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; bool sell = 3; } // QueryCostResponse is the response type for the Query/QueryCost RPC method. -message QueryCostResponse { - cosmos.base.v1beta1.Coin cost = 1; -} +message QueryCostResponse { cosmos.base.v1beta1.Coin cost = 1; } -// QueryClaimedRequest is the request type for the Query/QueryClaimed RPC method. -message QueryClaimedRequest { - string plan_id = 1; -} +// QueryClaimedRequest is the request type for the Query/QueryClaimed RPC +// method. +message QueryClaimedRequest { string plan_id = 1; } -// QueryClaimedResponse is the response type for the Query/QueryClaimed RPC method. +// QueryClaimedResponse is the response type for the Query/QueryClaimed RPC +// method. message QueryClaimedResponse { - string claimed_amt = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"]; + string claimed_amt = 1 + [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int" ]; } \ No newline at end of file diff --git a/proto/dymensionxyz/dymension/iro/tx.proto b/proto/dymensionxyz/dymension/iro/tx.proto index 4744385b3..0aa82ddd1 100644 --- a/proto/dymensionxyz/dymension/iro/tx.proto +++ b/proto/dymensionxyz/dymension/iro/tx.proto @@ -88,10 +88,16 @@ message MsgBuy { string plan_id = 2; // The amount of tokens to buy. - cosmos.base.v1beta1.Coin amount = 3; + string amount = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // The expected output amount. - cosmos.base.v1beta1.Coin expected_out_amount = 4; + string expected_out_amount = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } message MsgBuyResponse {} @@ -106,10 +112,16 @@ message MsgSell { string plan_id = 2; // The amount of tokens to sell. - cosmos.base.v1beta1.Coin amount = 3; + string amount = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // The expected output amount. - cosmos.base.v1beta1.Coin expected_out_amount = 4; + string expected_out_amount = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } message MsgSellResponse {} diff --git a/x/iro/cli/cli_test.go b/x/iro/cli/cli_test.go index 78f84b2c8..745fabafb 100644 --- a/x/iro/cli/cli_test.go +++ b/x/iro/cli/cli_test.go @@ -19,8 +19,16 @@ func TestGetTxCmd(t *testing.T) { cmd = cli.CmdCreateIRO() assert.NotNil(t, cmd) - assert.True(t, strings.HasPrefix(cmd.Use, "create-iro")) + assert.True(t, strings.HasPrefix(cmd.Use, "create")) assert.True(t, cmd.Flags().HasFlags()) + + cmd = cli.CmdBuy() + assert.NotNil(t, cmd) + assert.True(t, strings.HasPrefix(cmd.Use, "buy")) + + cmd = cli.CmdSell() + assert.NotNil(t, cmd) + assert.True(t, strings.HasPrefix(cmd.Use, "sell")) } func TestCmdCreateIRO(t *testing.T) { diff --git a/x/iro/cli/query.go b/x/iro/cli/query.go index 33122f688..c10e34df2 100644 --- a/x/iro/cli/query.go +++ b/x/iro/cli/query.go @@ -2,21 +2,17 @@ package cli import ( "fmt" - // "strings" - - "github.com/spf13/cobra" + "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" - // sdk "github.com/cosmos/cosmos-sdk/types" - + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/dymensionxyz/dymension/v3/x/iro/types" + "github.com/spf13/cobra" ) // GetQueryCmd returns the cli query commands for this module -func GetQueryCmd(queryRoute string) *cobra.Command { - // Group iro queries under a subcommand - cmd := &cobra.Command{ +func GetQueryCmd() *cobra.Command { + iroQueryCmd := &cobra.Command{ Use: types.ModuleName, Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), DisableFlagParsing: true, @@ -24,8 +20,188 @@ func GetQueryCmd(queryRoute string) *cobra.Command { RunE: client.ValidateCmd, } - cmd.AddCommand(CmdQueryParams()) - // this line is used by starport scaffolding # 1 + iroQueryCmd.AddCommand( + CmdQueryParams(), + CmdQueryPlans(), + CmdQueryPlan(), + CmdQueryPlanByRollapp(), + CmdQueryPrice(), + CmdQueryCost(), + CmdQueryClaimed(), + ) + + return iroQueryCmd +} + +func CmdQueryPlans() *cobra.Command { + cmd := &cobra.Command{ + Use: "plans", + Short: "Query all IRO plans", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QueryPlans(cmd.Context(), &types.QueryPlansRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +func CmdQueryPlan() *cobra.Command { + cmd := &cobra.Command{ + Use: "plan [plan-id]", + Short: "Query a specific IRO plan", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QueryPlan(cmd.Context(), &types.QueryPlanRequest{PlanId: args[0]}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +func CmdQueryPlanByRollapp() *cobra.Command { + cmd := &cobra.Command{ + Use: "plan-by-rollapp [rollapp-id]", + Short: "Query IRO plan by rollapp ID", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QueryPlanByRollapp(cmd.Context(), &types.QueryPlanByRollappRequest{RollappId: args[0]}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +func CmdQueryPrice() *cobra.Command { + cmd := &cobra.Command{ + Use: "price [plan-id]", + Short: "Query the current price for 1 IRO token for a specific IRO plan", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QueryPrice(cmd.Context(), &types.QueryPriceRequest{PlanId: args[0]}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +func CmdQueryCost() *cobra.Command { + cmd := &cobra.Command{ + Use: "cost [plan-id] [amount]", + Short: "Query the expected cost for buying or selling a specified amount of tokens", + Long: `Query the expected cost for buying or selling a specified amount of tokens. +A positive amount indicates a buy operation, while a negative amount indicates a sell operation.`, + Example: ` + dymd query iro cost plan1 1000000 + # Query the cost of buying 1000000 tokens from plan1 + + dymd query iro cost plan1 -500000 + # Query the cost of selling 500000 tokens from plan1`, + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + planId := args[0] + amount, ok := math.NewIntFromString(args[1]) + if !ok { + return fmt.Errorf("invalid amount: %s", args[1]) + } + + sell := amount.IsNegative() + if sell { + amount = amount.Abs() + } + + res, err := queryClient.QueryCost(cmd.Context(), &types.QueryCostRequest{ + PlanId: planId, + Amt: amount, + Sell: sell, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +func CmdQueryClaimed() *cobra.Command { + cmd := &cobra.Command{ + Use: "claimed [plan-id]", + Short: "Query the claimed amount for a specific plan", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QueryClaimed(cmd.Context(), &types.QueryClaimedRequest{PlanId: args[0]}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) return cmd } diff --git a/x/iro/cli/tx.go b/x/iro/cli/tx.go index a0e2624ba..ceddcb161 100644 --- a/x/iro/cli/tx.go +++ b/x/iro/cli/tx.go @@ -1,22 +1,11 @@ package cli import ( - "errors" "fmt" - "strconv" - "strings" - "time" - - "cosmossdk.io/math" - "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - - // "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/dymensionxyz/dymension/v3/x/iro/types" + "github.com/spf13/cobra" ) // GetTxCmd returns the transaction commands for this module @@ -30,138 +19,9 @@ func GetTxCmd() *cobra.Command { } cmd.AddCommand(CmdCreateIRO()) + cmd.AddCommand(CmdBuy()) + cmd.AddCommand(CmdSell()) + cmd.AddCommand(CmdClaim()) return cmd } - -func CmdCreateIRO() *cobra.Command { - cmd := &cobra.Command{ - Use: "create-iro [rollappId] [allocation] [pre-launch-time] --curve [curve params]", - Short: "Create a new IRO plan", - Example: `dymd create-iro [rollappId] [allocation] [pre-launch-time] --curve "1.2,0.4,0" - Optional: - --start-time [start-time] - --incentives-start [incentives-start] - --incentives-epochs [incentives-epochs] - `, - Args: cobra.ExactArgs(3), - RunE: func(cmd *cobra.Command, args []string) (err error) { - argRollappId := args[0] - argAllocation := args[1] - argPreLaunchTimeStr := args[2] - - allocationAmt, ok := math.NewIntFromString(argAllocation) - if !ok { - return fmt.Errorf("invalid allocation amount: %s", argAllocation) - } - - var preLaunchTime time.Time - if argPreLaunchTimeStr == "" { - return errors.New("pre-launch time cannot be empty") - } else if timeUnix, err := strconv.ParseInt(argPreLaunchTimeStr, 10, 64); err == nil { // unix time - preLaunchTime = time.Unix(timeUnix, 0) - } else if timeRFC, err := time.Parse(time.RFC3339, argPreLaunchTimeStr); err == nil { // RFC time - preLaunchTime = timeRFC - } else { // invalid input - return errors.New("invalid start time format") - } - - // Parse curve flag - curveStr, err := cmd.Flags().GetString(FlagBondingCurve) - if err != nil { - return err - } - curve, err := ParseBondingCurve(curveStr) - if err != nil { - return errors.Join(types.ErrInvalidBondingCurve, err) - } - - /* ----------------------------- optional flags ----------------------------- */ - var startTime time.Time - timeStr, err := cmd.Flags().GetString(FlagStartTime) - if err != nil { - return err - } - if timeStr == "" { // empty start time - startTime = time.Unix(0, 0) - } else if timeUnix, err := strconv.ParseInt(timeStr, 10, 64); err == nil { // unix time - startTime = time.Unix(timeUnix, 0) - } else if timeRFC, err := time.Parse(time.RFC3339, timeStr); err == nil { // RFC time - startTime = timeRFC - } else { // invalid input - return errors.New("invalid start time format") - } - - incentivesStart, err := cmd.Flags().GetDuration(FlagIncentivesStartDurationAfterSettlement) - if err != nil { - return err - } - - incentivesEpochs, err := cmd.Flags().GetUint64(FlagIncentivesEpochs) - if err != nil { - return err - } - - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := types.MsgCreatePlan{ - Owner: clientCtx.GetFromAddress().String(), - RollappId: argRollappId, - AllocatedAmount: allocationAmt, - BondingCurve: curve, - StartTime: startTime, - PreLaunchTime: preLaunchTime, - IncentivePlanParams: types.IncentivePlanParams{ - StartTimeAfterSettlement: incentivesStart, - NumEpochsPaidOver: incentivesEpochs, - }, - } - if err := msg.ValidateBasic(); err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - cmd.Flags().AddFlagSet(FlagSetCreatePlan()) - - return cmd -} - -// ParseBondingCurve parses the bonding curve string into a BondingCurve struct -// expected format: "M,N,C" for p(x) = M * x^N + C -func ParseBondingCurve(curveStr string) (types.BondingCurve, error) { - var curve types.BondingCurve - - curveParams := strings.Split(curveStr, ",") - if len(curveParams) != 3 { - return curve, errors.New("invalid bonding curve parameters") - } - - M, err := math.LegacyNewDecFromStr(curveParams[0]) - if err != nil { - return curve, errors.New("invalid M parameter") - } - - N, err := math.LegacyNewDecFromStr(curveParams[1]) - if err != nil { - return curve, errors.New("invalid N parameter") - } - - C, err := math.LegacyNewDecFromStr(curveParams[2]) - if err != nil { - return curve, errors.New("invalid C parameter") - } - - curve = types.NewBondingCurve(M, N, C) - return curve, curve.ValidateBasic() -} - -// buy -// sell -// claim diff --git a/x/iro/cli/tx_claim.go b/x/iro/cli/tx_claim.go new file mode 100644 index 000000000..57a910a4e --- /dev/null +++ b/x/iro/cli/tx_claim.go @@ -0,0 +1,39 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/dymensionxyz/dymension/v3/x/iro/types" + "github.com/spf13/cobra" +) + +func CmdClaim() *cobra.Command { + cmd := &cobra.Command{ + Use: "claim [plan-id]", + Short: "Claim tokens after the plan is settled", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + planID := args[0] + + msg := types.MsgClaim{ + Claimer: clientCtx.GetFromAddress().String(), + PlanId: planID, + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/iro/cli/tx_create_iro.go b/x/iro/cli/tx_create_iro.go new file mode 100644 index 000000000..a267bb4b2 --- /dev/null +++ b/x/iro/cli/tx_create_iro.go @@ -0,0 +1,163 @@ +package cli + +import ( + "errors" + "fmt" + "strconv" + "strings" + "time" + + "cosmossdk.io/math" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + + "github.com/dymensionxyz/dymension/v3/x/iro/types" +) + +func CmdCreateIRO() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-iro [rollapp-id] [allocation] [pre-launch-time]", + Short: "Create a new Initial RollApp Offering (IRO) plan", + Long: `Create a new Initial RollApp Offering (IRO) plan for a specific RollApp. + +Parameters: + [rollapp-id] : The unique identifier of the RollApp for which the IRO is being created. + [allocation] : The total amount of tokens to be allocated for the IRO. + [pre-launch-time] : The time before which the IRO cannot be launched. Can be in Unix timestamp or RFC3339 format. + +Required Flags: + --curve : The bonding curve parameters in the format "M,N,C" where the curve is defined as p(x) = M * x^N + C. + +Optional Flags: + --start-time : The time when the IRO will start. If not provided, it starts immediately after creation. + --incentives-start: The duration after settlement when incentives distribution starts. + --incentives-epochs: The number of epochs over which incentives will be distributed. (1 minute epoch) + +Examples: + dymd tx iro create-iro myrollapp1 1000000000 1630000000 --curve "1.2,0.4,0" --from mykey + dymd tx iro create-iro myrollapp2 500000000 "2023-09-15T14:00:00Z" --curve "1.5,0.5,100" --start-time "2023-10-01T00:00:00Z" --incentives-start 24h --incentives-epochs 3000 --from mykey +`, + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argRollappId := args[0] + argAllocation := args[1] + argPreLaunchTimeStr := args[2] + + allocationAmt, ok := math.NewIntFromString(argAllocation) + if !ok { + return fmt.Errorf("invalid allocation amount: %s", argAllocation) + } + + var preLaunchTime time.Time + if argPreLaunchTimeStr == "" { + return errors.New("pre-launch time cannot be empty") + } else if timeUnix, err := strconv.ParseInt(argPreLaunchTimeStr, 10, 64); err == nil { // unix time + preLaunchTime = time.Unix(timeUnix, 0) + } else if timeRFC, err := time.Parse(time.RFC3339, argPreLaunchTimeStr); err == nil { // RFC time + preLaunchTime = timeRFC + } else { // invalid input + return errors.New("invalid start time format") + } + + // Parse curve flag + curveStr, err := cmd.Flags().GetString(FlagBondingCurve) + if err != nil { + return err + } + curve, err := ParseBondingCurve(curveStr) + if err != nil { + return errors.Join(types.ErrInvalidBondingCurve, err) + } + + /* ----------------------------- optional flags ----------------------------- */ + var startTime time.Time + timeStr, err := cmd.Flags().GetString(FlagStartTime) + if err != nil { + return err + } + if timeStr == "" { // empty start time + startTime = time.Unix(0, 0) + } else if timeUnix, err := strconv.ParseInt(timeStr, 10, 64); err == nil { // unix time + startTime = time.Unix(timeUnix, 0) + } else if timeRFC, err := time.Parse(time.RFC3339, timeStr); err == nil { // RFC time + startTime = timeRFC + } else { // invalid input + return errors.New("invalid start time format") + } + + incentivesStart, err := cmd.Flags().GetDuration(FlagIncentivesStartDurationAfterSettlement) + if err != nil { + return err + } + + incentivesEpochs, err := cmd.Flags().GetUint64(FlagIncentivesEpochs) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.MsgCreatePlan{ + Owner: clientCtx.GetFromAddress().String(), + RollappId: argRollappId, + AllocatedAmount: allocationAmt, + BondingCurve: curve, + StartTime: startTime, + PreLaunchTime: preLaunchTime, + IncentivePlanParams: types.IncentivePlanParams{ + StartTimeAfterSettlement: incentivesStart, + NumEpochsPaidOver: incentivesEpochs, + }, + } + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + cmd.Flags().AddFlagSet(FlagSetCreatePlan()) + + return cmd +} + +// ParseBondingCurve parses the bonding curve string into a BondingCurve struct +// expected format: "M,N,C" for p(x) = M * x^N + C +func ParseBondingCurve(curveStr string) (types.BondingCurve, error) { + var curve types.BondingCurve + + curveParams := strings.Split(curveStr, ",") + if len(curveParams) != 3 { + return curve, errors.New("invalid bonding curve parameters") + } + + M, err := math.LegacyNewDecFromStr(curveParams[0]) + if err != nil { + return curve, errors.New("invalid M parameter") + } + + N, err := math.LegacyNewDecFromStr(curveParams[1]) + if err != nil { + return curve, errors.New("invalid N parameter") + } + + C, err := math.LegacyNewDecFromStr(curveParams[2]) + if err != nil { + return curve, errors.New("invalid C parameter") + } + + curve = types.NewBondingCurve(M, N, C) + return curve, curve.ValidateBasic() +} + +// buy +// sell +// claim diff --git a/x/iro/cli/tx_trade.go b/x/iro/cli/tx_trade.go new file mode 100644 index 000000000..b4f7bc341 --- /dev/null +++ b/x/iro/cli/tx_trade.go @@ -0,0 +1,83 @@ +package cli + +import ( + "fmt" + + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/dymension/v3/x/iro/types" + "github.com/spf13/cobra" +) + +func CmdBuy() *cobra.Command { + return createBuySellCmd( + "buy [plan-id] [amount] [expected-out-amount]", + "Buy allocation from an IRO plan", + true, + ) +} + +func CmdSell() *cobra.Command { + return createBuySellCmd( + "sell [plan-id] [amount] [expected-out-amount]", + "Sell allocation from an IRO plan", + false, + ) +} + +func createBuySellCmd(use string, short string, isBuy bool) *cobra.Command { + cmd := &cobra.Command{ + Use: use, + Short: short, + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + planID := args[0] + argAmount := args[1] + argExpectedOutAmount := args[2] + + amount, ok := math.NewIntFromString(argAmount) + if !ok { + return fmt.Errorf("invalid amount: %s", argAmount) + } + + expectedOutAmount, ok := math.NewIntFromString(argExpectedOutAmount) + if !ok { + return fmt.Errorf("invalid expected out amount: %s", argExpectedOutAmount) + } + + var msg sdk.Msg + if isBuy { + msg = &types.MsgBuy{ + Buyer: clientCtx.GetFromAddress().String(), + PlanId: planID, + Amount: amount, + ExpectedOutAmount: expectedOutAmount, + } + } else { + msg = &types.MsgSell{ + Seller: clientCtx.GetFromAddress().String(), + PlanId: planID, + Amount: amount, + ExpectedOutAmount: expectedOutAmount, + } + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/iro/keeper/query.go b/x/iro/keeper/query.go index da652e876..bfeb685e1 100644 --- a/x/iro/keeper/query.go +++ b/x/iro/keeper/query.go @@ -3,6 +3,7 @@ package keeper import ( "context" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" appparams "github.com/dymensionxyz/dymension/v3/app/params" "github.com/dymensionxyz/dymension/v3/x/iro/types" @@ -53,7 +54,14 @@ func (k Keeper) QueryCost(goCtx context.Context, req *types.QueryCostRequest) (* return nil, status.Error(codes.NotFound, "plan not found") } - return &types.QueryCostResponse{Cost: &plan.TotalAllocation}, nil + var cost math.Int + if req.Sell { + cost = plan.BondingCurve.Cost(plan.SoldAmt, plan.SoldAmt.Sub(req.Amt)) + } else { + cost = plan.BondingCurve.Cost(plan.SoldAmt, plan.SoldAmt.Add(req.Amt)) + } + costCoin := sdk.NewCoin(appparams.BaseDenom, cost) + return &types.QueryCostResponse{Cost: &costCoin}, nil } // QueryPlan implements types.QueryServer. @@ -92,10 +100,7 @@ func (k Keeper) QueryPlans(goCtx context.Context, req *types.QueryPlansRequest) return nil, status.Error(codes.InvalidArgument, "invalid request") } ctx := sdk.UnwrapSDKContext(goCtx) - - plans := k.GetAllPlans(ctx) - - return &types.QueryPlansResponse{Plans: plans}, nil + return &types.QueryPlansResponse{Plans: k.GetAllPlans(ctx)}, nil } // QueryPrice implements types.QueryServer. diff --git a/x/iro/keeper/trade.go b/x/iro/keeper/trade.go index d6e03a275..bbcc209df 100644 --- a/x/iro/keeper/trade.go +++ b/x/iro/keeper/trade.go @@ -22,7 +22,7 @@ func (m msgServer) Buy(ctx context.Context, req *types.MsgBuy) (*types.MsgBuyRes return nil, err } - err = m.Keeper.Buy(sdk.UnwrapSDKContext(ctx), req.PlanId, buyer, req.Amount.Amount, req.ExpectedOutAmount.Amount) + err = m.Keeper.Buy(sdk.UnwrapSDKContext(ctx), req.PlanId, buyer, req.Amount, req.ExpectedOutAmount) if err != nil { return nil, err } @@ -36,7 +36,7 @@ func (m msgServer) Sell(ctx context.Context, req *types.MsgSell) (*types.MsgSell if err != nil { return nil, err } - err = m.Keeper.Sell(sdk.UnwrapSDKContext(ctx), req.PlanId, seller, req.Amount.Amount, req.ExpectedOutAmount.Amount) + err = m.Keeper.Sell(sdk.UnwrapSDKContext(ctx), req.PlanId, seller, req.Amount, req.ExpectedOutAmount) if err != nil { return nil, err } diff --git a/x/iro/module.go b/x/iro/module.go index 6155851e1..43a709b54 100644 --- a/x/iro/module.go +++ b/x/iro/module.go @@ -81,7 +81,7 @@ func (a AppModuleBasic) GetTxCmd() *cobra.Command { // GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd(types.StoreKey) + return cli.GetQueryCmd() } // ---------------------------------------------------------------------------- diff --git a/x/iro/types/query.pb.go b/x/iro/types/query.pb.go index 5d6116366..a0d9e2bb0 100644 --- a/x/iro/types/query.pb.go +++ b/x/iro/types/query.pb.go @@ -287,7 +287,8 @@ func (m *QueryPlanResponse) GetPlan() *Plan { return nil } -// QueryPlanByRollappRequest is the request type for the Query/QueryPlanByRollapp RPC method. +// QueryPlanByRollappRequest is the request type for the +// Query/QueryPlanByRollapp RPC method. type QueryPlanByRollappRequest struct { RollappId string `protobuf:"bytes,1,opt,name=rollapp_id,json=rollappId,proto3" json:"rollapp_id,omitempty"` } @@ -332,7 +333,8 @@ func (m *QueryPlanByRollappRequest) GetRollappId() string { return "" } -// QueryPlanByRollappResponse is the response type for the Query/QueryPlanByRollapp RPC method. +// QueryPlanByRollappResponse is the response type for the +// Query/QueryPlanByRollapp RPC method. type QueryPlanByRollappResponse struct { Plan *Plan `protobuf:"bytes,1,opt,name=plan,proto3" json:"plan,omitempty"` } @@ -469,9 +471,9 @@ func (m *QueryPriceResponse) GetPrice() *types.Coin { // QueryCostRequest is the request type for the Query/QueryCost RPC method. type QueryCostRequest struct { - PlanId string `protobuf:"bytes,1,opt,name=plan_id,json=planId,proto3" json:"plan_id,omitempty"` - Amt *types.Coin `protobuf:"bytes,2,opt,name=amt,proto3" json:"amt,omitempty"` - Sell bool `protobuf:"varint,3,opt,name=sell,proto3" json:"sell,omitempty"` + PlanId string `protobuf:"bytes,1,opt,name=plan_id,json=planId,proto3" json:"plan_id,omitempty"` + Amt github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amt,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amt"` + Sell bool `protobuf:"varint,3,opt,name=sell,proto3" json:"sell,omitempty"` } func (m *QueryCostRequest) Reset() { *m = QueryCostRequest{} } @@ -514,13 +516,6 @@ func (m *QueryCostRequest) GetPlanId() string { return "" } -func (m *QueryCostRequest) GetAmt() *types.Coin { - if m != nil { - return m.Amt - } - return nil -} - func (m *QueryCostRequest) GetSell() bool { if m != nil { return m.Sell @@ -573,7 +568,8 @@ func (m *QueryCostResponse) GetCost() *types.Coin { return nil } -// QueryClaimedRequest is the request type for the Query/QueryClaimed RPC method. +// QueryClaimedRequest is the request type for the Query/QueryClaimed RPC +// method. type QueryClaimedRequest struct { PlanId string `protobuf:"bytes,1,opt,name=plan_id,json=planId,proto3" json:"plan_id,omitempty"` } @@ -618,7 +614,8 @@ func (m *QueryClaimedRequest) GetPlanId() string { return "" } -// QueryClaimedResponse is the response type for the Query/QueryClaimed RPC method. +// QueryClaimedResponse is the response type for the Query/QueryClaimed RPC +// method. type QueryClaimedResponse struct { ClaimedAmt *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=claimed_amt,json=claimedAmt,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"claimed_amt,omitempty"` } @@ -678,55 +675,56 @@ func init() { } var fileDescriptor_ae2c72bd0c23c1c0 = []byte{ - // 765 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x96, 0xcf, 0x4f, 0xd4, 0x40, - 0x14, 0xc7, 0xb7, 0xb0, 0xac, 0xee, 0xc3, 0x83, 0x0e, 0x24, 0x2e, 0x8d, 0x2e, 0xeb, 0x48, 0x08, - 0x02, 0xdb, 0x81, 0x45, 0x4c, 0xfc, 0x71, 0x90, 0x25, 0x1e, 0x56, 0x2f, 0xda, 0x8b, 0x89, 0x97, - 0x4d, 0xb7, 0xdb, 0xac, 0x8d, 0x6d, 0xa7, 0xb4, 0x85, 0xb0, 0x12, 0x2e, 0xfe, 0x01, 0xc6, 0xc4, - 0xe8, 0x49, 0x13, 0x8f, 0xfe, 0x25, 0x86, 0x23, 0x89, 0x17, 0xe3, 0x81, 0x18, 0xf0, 0x0f, 0x31, - 0xf3, 0xa3, 0xdd, 0xa2, 0xd2, 0xd6, 0x78, 0x62, 0x67, 0xe6, 0xbd, 0xf7, 0xfd, 0xcc, 0xf4, 0xbd, - 0x6f, 0x80, 0xf9, 0xfe, 0xd0, 0xb5, 0xbc, 0xd0, 0xa6, 0xde, 0xee, 0xf0, 0x25, 0x49, 0x16, 0xc4, - 0x0e, 0x28, 0xd9, 0xda, 0xb6, 0x82, 0xa1, 0xe6, 0x07, 0x34, 0xa2, 0x48, 0x4d, 0xc7, 0x69, 0xc9, - 0x42, 0xb3, 0x03, 0xaa, 0x4e, 0x0f, 0xe8, 0x80, 0xf2, 0x30, 0xc2, 0x7e, 0x89, 0x0c, 0x75, 0xc6, - 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0x4f, 0xbb, 0x94, 0xba, 0x52, 0x3c, 0x41, 0x72, 0xae, 0x73, 0x4e, 0x82, 0x9a, 0x99, 0x9c, 0x22, - 0x69, 0x84, 0xda, 0x7e, 0x78, 0x70, 0x5c, 0x57, 0x0e, 0x8f, 0xeb, 0xca, 0x8f, 0xe3, 0xba, 0xf2, - 0xe6, 0xa4, 0x5e, 0x3a, 0x3c, 0xa9, 0x97, 0xbe, 0x9d, 0xd4, 0x4b, 0xcf, 0x56, 0x52, 0xf6, 0x76, - 0x46, 0xc9, 0x9d, 0x35, 0xb2, 0xcb, 0xeb, 0x72, 0xb3, 0xeb, 0x55, 0xf8, 0xff, 0x1f, 0x6b, 0xbf, - 0x02, 0x00, 0x00, 0xff, 0xff, 0xbd, 0xfc, 0x69, 0x05, 0x5a, 0x09, 0x00, 0x00, + // 775 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x96, 0x4f, 0x4f, 0xd4, 0x4e, + 0x18, 0xc7, 0xb7, 0xb0, 0xec, 0xef, 0xb7, 0x83, 0x07, 0x1d, 0x48, 0x5c, 0x1a, 0x2d, 0xeb, 0x48, + 0x08, 0x02, 0x3b, 0x03, 0x8b, 0x98, 0xf8, 0xe7, 0x00, 0x4b, 0x3c, 0xac, 0x5e, 0xb4, 0x17, 0x13, + 0x2f, 0x9b, 0x6e, 0xb7, 0x59, 0x1b, 0xdb, 0x4e, 0x69, 0x0b, 0x61, 0x25, 0x1c, 0xf4, 0x05, 0x18, + 0x13, 0xa3, 0x27, 0x4d, 0x3c, 0xfa, 0x4a, 0x0c, 0x47, 0x12, 0x2f, 0xc6, 0x03, 0x31, 0xe0, 0x0b, + 0x31, 0xf3, 0xa7, 0xdd, 0xae, 0x4a, 0x5b, 0xe2, 0x89, 0x9d, 0x67, 0x9e, 0x67, 0xbe, 0x9f, 0x67, + 0xfa, 0xcc, 0x37, 0x80, 0xf9, 0xde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80, 0x94, 0x3d, 0x15, 0x99, 0x80, 0xb4, 0x3f, 0x15, + 0xbc, 0x6b, 0x56, 0x92, 0xba, 0xeb, 0x0f, 0xf1, 0x2c, 0x30, 0x83, 0x28, 0x30, 0x0b, 0x29, 0x2b, + 0x2b, 0x30, 0x0b, 0x69, 0xd7, 0x41, 0x4d, 0xce, 0xb7, 0x0c, 0x17, 0xb3, 0xf8, 0x98, 0xe1, 0xa4, + 0xf0, 0x3e, 0x2b, 0xe0, 0x42, 0xda, 0x4b, 0x60, 0xfe, 0x8b, 0x1d, 0x75, 0x29, 0x75, 0xa5, 0x78, + 0x81, 0xe4, 0x5c, 0xe7, 0x9c, 0x04, 0x36, 0x32, 0x39, 0x45, 0xd1, 0x10, 0xb5, 0xf5, 0xe0, 0xf0, + 0x44, 0x53, 0x8e, 0x4e, 0x34, 0xe5, 0xc7, 0x89, 0xa6, 0xbc, 0x39, 0xd5, 0x4a, 0x47, 0xa7, 0x5a, + 0xe9, 0xdb, 0xa9, 0x56, 0x7a, 0xba, 0x92, 0xb2, 0xb7, 0x33, 0x8e, 0xdc, 0x5d, 0x23, 0x7b, 0xfc, + 0x5c, 0x6e, 0x76, 0xdd, 0x0a, 0xff, 0xaf, 0x64, 0xed, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3d, + 0x02, 0x68, 0x7d, 0x70, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -751,7 +749,8 @@ type QueryClient interface { QueryPlanByRollapp(ctx context.Context, in *QueryPlanByRollappRequest, opts ...grpc.CallOption) (*QueryPlanByRollappResponse, error) // Price returns the current price for 1 IRO token for the specified plan ID. QueryPrice(ctx context.Context, in *QueryPriceRequest, opts ...grpc.CallOption) (*QueryPriceResponse, error) - // Cost returns the expected cost for buying or selling the specified amount of shares. + // Cost returns the expected cost for buying or selling the specified amount + // of shares. QueryCost(ctx context.Context, in *QueryCostRequest, opts ...grpc.CallOption) (*QueryCostResponse, error) // Claimed returns the claimed amount thus far for the specified plan ID. QueryClaimed(ctx context.Context, in *QueryClaimedRequest, opts ...grpc.CallOption) (*QueryClaimedResponse, error) @@ -840,7 +839,8 @@ type QueryServer interface { QueryPlanByRollapp(context.Context, *QueryPlanByRollappRequest) (*QueryPlanByRollappResponse, error) // Price returns the current price for 1 IRO token for the specified plan ID. QueryPrice(context.Context, *QueryPriceRequest) (*QueryPriceResponse, error) - // Cost returns the expected cost for buying or selling the specified amount of shares. + // Cost returns the expected cost for buying or selling the specified amount + // of shares. QueryCost(context.Context, *QueryCostRequest) (*QueryCostResponse, error) // Claimed returns the claimed amount thus far for the specified plan ID. QueryClaimed(context.Context, *QueryClaimedRequest) (*QueryClaimedResponse, error) @@ -1380,18 +1380,16 @@ func (m *QueryCostRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x18 } - if m.Amt != nil { - { - size, err := m.Amt.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + { + size := m.Amt.Size() + i -= size + if _, err := m.Amt.MarshalTo(dAtA[i:]); err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 if len(m.PlanId) > 0 { i -= len(m.PlanId) copy(dAtA[i:], m.PlanId) @@ -1645,10 +1643,8 @@ func (m *QueryCostRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.Amt != nil { - l = m.Amt.Size() - n += 1 + l + sovQuery(uint64(l)) - } + l = m.Amt.Size() + n += 1 + l + sovQuery(uint64(l)) if m.Sell { n += 2 } @@ -2536,7 +2532,7 @@ func (m *QueryCostRequest) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Amt", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2546,24 +2542,22 @@ func (m *QueryCostRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Amt == nil { - m.Amt = &types.Coin{} - } if err := m.Amt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/iro/types/tx.pb.go b/x/iro/types/tx.pb.go index 81f653dd9..12e1a8135 100644 --- a/x/iro/types/tx.pb.go +++ b/x/iro/types/tx.pb.go @@ -7,8 +7,8 @@ import ( context "context" fmt "fmt" _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types" 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" @@ -270,9 +270,9 @@ type MsgBuy struct { // The ID of the plan. PlanId string `protobuf:"bytes,2,opt,name=plan_id,json=planId,proto3" json:"plan_id,omitempty"` // The amount of tokens to buy. - Amount *types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` // The expected output amount. - ExpectedOutAmount *types.Coin `protobuf:"bytes,4,opt,name=expected_out_amount,json=expectedOutAmount,proto3" json:"expected_out_amount,omitempty"` + ExpectedOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=expected_out_amount,json=expectedOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"expected_out_amount"` } func (m *MsgBuy) Reset() { *m = MsgBuy{} } @@ -322,20 +322,6 @@ func (m *MsgBuy) GetPlanId() string { return "" } -func (m *MsgBuy) GetAmount() *types.Coin { - if m != nil { - return m.Amount - } - return nil -} - -func (m *MsgBuy) GetExpectedOutAmount() *types.Coin { - if m != nil { - return m.ExpectedOutAmount - } - return nil -} - type MsgBuyResponse struct { } @@ -378,9 +364,9 @@ type MsgSell struct { // The ID of the plan. PlanId string `protobuf:"bytes,2,opt,name=plan_id,json=planId,proto3" json:"plan_id,omitempty"` // The amount of tokens to sell. - Amount *types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` // The expected output amount. - ExpectedOutAmount *types.Coin `protobuf:"bytes,4,opt,name=expected_out_amount,json=expectedOutAmount,proto3" json:"expected_out_amount,omitempty"` + ExpectedOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=expected_out_amount,json=expectedOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"expected_out_amount"` } func (m *MsgSell) Reset() { *m = MsgSell{} } @@ -430,20 +416,6 @@ func (m *MsgSell) GetPlanId() string { return "" } -func (m *MsgSell) GetAmount() *types.Coin { - if m != nil { - return m.Amount - } - return nil -} - -func (m *MsgSell) GetExpectedOutAmount() *types.Coin { - if m != nil { - return m.ExpectedOutAmount - } - return nil -} - type MsgSellResponse struct { } @@ -588,61 +560,60 @@ func init() { } var fileDescriptor_41b9ae3e091bbd60 = []byte{ - // 856 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x4f, 0x6f, 0xdb, 0x36, - 0x14, 0x8f, 0x1a, 0xc7, 0xa9, 0x5f, 0x92, 0x26, 0x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, 0x9a, 0xf6, 0x2b, 0x68, 0x68, 0xa3, 0x3e, 0x98, 0x51, 0xa3, 0x40, 0xf6, 0xa3, - 0x39, 0x40, 0x35, 0xf3, 0xb7, 0xb0, 0x64, 0xec, 0xf0, 0x70, 0x96, 0x58, 0x85, 0xb2, 0x3f, 0x9e, - 0x07, 0x55, 0x91, 0xdb, 0x4b, 0x3f, 0xbd, 0x7d, 0xb1, 0x6b, 0xf5, 0x3e, 0x7b, 0x79, 0xde, 0xb1, - 0x5e, 0x9d, 0x77, 0xac, 0xbf, 0xcf, 0x3b, 0xd6, 0xf3, 0x8b, 0xce, 0xc2, 0xab, 0x8b, 0xce, 0xc2, - 0x1f, 0x17, 0x9d, 0x85, 0x6f, 0xf6, 0x26, 0x9e, 0x8f, 0x6b, 0xde, 0xfc, 0xd1, 0x81, 0x77, 0x66, - 0xfe, 0x83, 0xa8, 0xc7, 0x24, 0x68, 0xea, 0xcb, 0xf7, 0xe0, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xf0, 0xe5, 0xa2, 0x50, 0xae, 0x08, 0x00, 0x00, + // 845 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcf, 0x6f, 0xdc, 0x44, + 0x14, 0x8e, 0x93, 0xcd, 0xa6, 0xfb, 0x9a, 0x34, 0xe9, 0xb4, 0x55, 0xb6, 0x96, 0xd8, 0x54, 0x6e, + 0x85, 0x42, 0x4a, 0xed, 0xfc, 0x90, 0x38, 0xe4, 0xd6, 0x8d, 0x04, 0x0a, 0xea, 0x0a, 0xb4, 0xa1, + 0x12, 0x3f, 0x24, 0xac, 0xb1, 0x3d, 0x38, 0x03, 0xf6, 0x8c, 0xe5, 0x19, 0x6f, 0x76, 0x39, 0x21, + 0x24, 0x0e, 0xdc, 0x7a, 0xe4, 0xcc, 0x5f, 0xd0, 0x03, 0x7f, 0x44, 0x8f, 0x15, 0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cc, 0xfd, 0x76, 0xd6, 0x99, 0xfb, 0x7c, 0x7b, 0xcc, 0xea, 0x97, + 0xfc, 0x47, 0x0c, 0xf6, 0xbc, 0xa1, 0xf9, 0xaf, 0x51, 0xc6, 0x0f, 0x9a, 0x7a, 0xa0, 0xef, 0xfd, + 0x1d, 0x00, 0x00, 0xff, 0xff, 0x49, 0x74, 0x51, 0x56, 0x02, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1075,30 +1046,26 @@ func (m *MsgBuy) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.ExpectedOutAmount != nil { - { - size, err := m.ExpectedOutAmount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + { + size := m.ExpectedOutAmount.Size() + i -= size + if _, err := m.ExpectedOutAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err } - i-- - dAtA[i] = 0x22 + i = encodeVarintTx(dAtA, i, uint64(size)) } - if m.Amount != nil { - { - size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err } - i-- - dAtA[i] = 0x1a + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x1a if len(m.PlanId) > 0 { i -= len(m.PlanId) copy(dAtA[i:], m.PlanId) @@ -1159,30 +1126,26 @@ func (m *MsgSell) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.ExpectedOutAmount != nil { - { - size, err := m.ExpectedOutAmount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + { + size := m.ExpectedOutAmount.Size() + i -= size + if _, err := m.ExpectedOutAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err } - i-- - dAtA[i] = 0x22 + i = encodeVarintTx(dAtA, i, uint64(size)) } - if m.Amount != nil { - { - size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err } - i-- - dAtA[i] = 0x1a + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x1a if len(m.PlanId) > 0 { i -= len(m.PlanId) copy(dAtA[i:], m.PlanId) @@ -1372,14 +1335,10 @@ func (m *MsgBuy) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.Amount != nil { - l = m.Amount.Size() - n += 1 + l + sovTx(uint64(l)) - } - if m.ExpectedOutAmount != nil { - l = m.ExpectedOutAmount.Size() - n += 1 + l + sovTx(uint64(l)) - } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.ExpectedOutAmount.Size() + n += 1 + l + sovTx(uint64(l)) return n } @@ -1406,14 +1365,10 @@ func (m *MsgSell) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.Amount != nil { - l = m.Amount.Size() - n += 1 + l + sovTx(uint64(l)) - } - if m.ExpectedOutAmount != nil { - l = m.ExpectedOutAmount.Size() - n += 1 + l + sovTx(uint64(l)) - } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.ExpectedOutAmount.Size() + n += 1 + l + sovTx(uint64(l)) return n } @@ -2082,7 +2037,7 @@ func (m *MsgBuy) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2092,24 +2047,22 @@ func (m *MsgBuy) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Amount == nil { - m.Amount = &types.Coin{} - } if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2118,7 +2071,7 @@ func (m *MsgBuy) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ExpectedOutAmount", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2128,24 +2081,22 @@ func (m *MsgBuy) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if m.ExpectedOutAmount == nil { - m.ExpectedOutAmount = &types.Coin{} - } if err := m.ExpectedOutAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2318,7 +2269,7 @@ func (m *MsgSell) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2328,24 +2279,22 @@ func (m *MsgSell) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Amount == nil { - m.Amount = &types.Coin{} - } if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2354,7 +2303,7 @@ func (m *MsgSell) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ExpectedOutAmount", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2364,24 +2313,22 @@ func (m *MsgSell) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if m.ExpectedOutAmount == nil { - m.ExpectedOutAmount = &types.Coin{} - } if err := m.ExpectedOutAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err }