forked from cerc-io/laconicd
Add service provider auctions (#59)
Part of [Service provider auctions](https://www.notion.so/Service-provider-auctions-a7b63697d818479493ec145ea6ea3c1c) - Add a new type of auction for service providers - Add a command to release provider auction funds - Remove unused auction module params Co-authored-by: IshaVenikar <ishavenikar7@gmail.com> Co-authored-by: Isha Venikar <ishavenikar@Ishas-MacBook-Air.local> Reviewed-on: cerc-io/laconicd#59 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
co-authored by
IshaVenikar
Isha Venikar
parent
df43322ef3
commit
52e8d322fa
+40
-16
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@@ -12,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"
|
||||
@@ -48,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
|
||||
@@ -58,7 +68,6 @@ func GetCmdCommitBid() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
chainId := viper.GetString("chain-id")
|
||||
auctionId := args[0]
|
||||
|
||||
reveal := map[string]interface{}{
|
||||
@@ -132,48 +141,63 @@ func GetCmdRevealBid() *cobra.Command {
|
||||
|
||||
func GetCmdCreateAuction() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "create [commits-duration] [reveals-duration] [commit-fee] [reveal-fee] [minimum-bid]",
|
||||
Use: "create [kind] [commits-duration] [reveals-duration] [commit-fee] [reveal-fee] [minimum-bid] [max-price] [num-providers]",
|
||||
Short: "Create auction.",
|
||||
Args: cobra.ExactArgs(5),
|
||||
Args: cobra.ExactArgs(8),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
commitsDuration, err := time.ParseDuration(args[0])
|
||||
kind := args[0]
|
||||
|
||||
commitsDuration, err := time.ParseDuration(args[1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
revealsDuration, err := time.ParseDuration(args[1])
|
||||
revealsDuration, err := time.ParseDuration(args[2])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
commitFee, err := sdk.ParseCoinNormalized(args[2])
|
||||
commitFee, err := sdk.ParseCoinNormalized(args[3])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
revealFee, err := sdk.ParseCoinNormalized(args[3])
|
||||
revealFee, err := sdk.ParseCoinNormalized(args[4])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
minimumBid, err := sdk.ParseCoinNormalized(args[4])
|
||||
minimumBid, err := sdk.ParseCoinNormalized(args[5])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params := auctiontypes.Params{
|
||||
CommitsDuration: commitsDuration,
|
||||
RevealsDuration: revealsDuration,
|
||||
CommitFee: commitFee,
|
||||
RevealFee: revealFee,
|
||||
MinimumBid: minimumBid,
|
||||
maxPrice, err := sdk.ParseCoinNormalized(args[6])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
msg := auctiontypes.NewMsgCreateAuction(params, clientCtx.GetFromAddress())
|
||||
|
||||
numProviders, err := strconv.ParseInt(args[7], 10, 32)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := auctiontypes.NewMsgCreateAuction(
|
||||
kind,
|
||||
commitsDuration,
|
||||
revealsDuration,
|
||||
commitFee,
|
||||
revealFee,
|
||||
minimumBid,
|
||||
maxPrice,
|
||||
int32(numProviders),
|
||||
clientCtx.GetFromAddress(),
|
||||
)
|
||||
err = msg.ValidateBasic()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user