From b8c353182404cea89a778ed23fc9a092ce7c13f9 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 25 Sep 2024 12:01:13 +0530 Subject: [PATCH] Handle chain id commit bid CLI and update create auction CLI --- x/auction/client/cli/tx.go | 12 ++++++++++-- x/auction/module/autocli.go | 12 +++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/x/auction/client/cli/tx.go b/x/auction/client/cli/tx.go index 4e285f37..7ff1dda0 100644 --- a/x/auction/client/cli/tx.go +++ b/x/auction/client/cli/tx.go @@ -13,7 +13,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cobra" - "github.com/spf13/viper" wnsUtils "git.vdb.to/cerc-io/laconicd/utils" auctiontypes "git.vdb.to/cerc-io/laconicd/x/auction" @@ -49,6 +48,16 @@ func GetCmdCommitBid() *cobra.Command { return err } + // Take chain id passed by user + chainId, _ := cmd.Flags().GetString(flags.FlagChainID) + if chainId == "" { + // Take from config if not provided + chainId = clientCtx.ChainID + if chainId == "" { + return fmt.Errorf("--chain-id required") + } + } + bidAmount, err := sdk.ParseCoinNormalized(args[1]) if err != nil { return err @@ -59,7 +68,6 @@ func GetCmdCommitBid() *cobra.Command { return err } - chainId := viper.GetString("chain-id") auctionId := args[0] reveal := map[string]interface{}{ diff --git a/x/auction/module/autocli.go b/x/auction/module/autocli.go index b1214695..e22afd8e 100644 --- a/x/auction/module/autocli.go +++ b/x/auction/module/autocli.go @@ -81,17 +81,19 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { RpcCommandOptions: []*autocliv1.RpcCommandOptions{ { RpcMethod: "CreateAuction", - Use: "create [kind] [commits-duration] [reveals-duration] [commit-fee] [reveal-fee] [minimum-bid] [max-price] [num-providers]", + Use: "create [commits-duration] [reveals-duration] [commit-fee] [reveal-fee]", Short: "Create an auction", PositionalArgs: []*autocliv1.PositionalArgDescriptor{ - {ProtoField: "kind"}, {ProtoField: "commits_duration"}, {ProtoField: "reveals_duration"}, {ProtoField: "commit_fee"}, {ProtoField: "reveal_fee"}, - {ProtoField: "minimum_bid"}, - {ProtoField: "max_price"}, - {ProtoField: "num_providers"}, + }, + FlagOptions: map[string]*autocliv1.FlagOptions{ + "kind": {Name: "kind", DefaultValue: "vickrey", Usage: "Auction kind (vickrey|provider) (default: vickrey)"}, + "minimum_bid": {Name: "minimum-bid", Usage: "Minimum bid (required for vickrey auctions)"}, + "max_price": {Name: "max-price", Usage: "Max price (required for provider auctions)"}, + "num_providers": {Name: "num-providers", Usage: "Number of desired providers (required for provider auctions)"}, }, }, {