Add service provider auctions #59
@ -1,6 +1,6 @@
|
||||
# cerc-io laconic gql
|
||||
|
||||
> Browser : http://localhost:9473 for gql
|
||||
> Browser : <http://localhost:9473> for gql
|
||||
|
||||
## Run gqlgen
|
||||
|
||||
|
@ -133,7 +133,7 @@ func GetCmdRevealBid() *cobra.Command {
|
||||
|
||||
func GetCmdCreateAuction() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "create [commits-duration] [reveals-duration] [commit-fee] [reveal-fee] [minimum-bid] [max-price] [kind] [num-providers]",
|
||||
Use: "create [kind] [commits-duration] [reveals-duration] [commit-fee] [reveal-fee] [minimum-bid] [max-price] [num-providers]",
|
||||
Short: "Create auction.",
|
||||
Args: cobra.ExactArgs(8),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
@ -142,45 +142,46 @@ func GetCmdCreateAuction() *cobra.Command {
|
||||
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
|
||||
}
|
||||
|
||||
maxPrice, err := sdk.ParseCoinNormalized(args[5])
|
||||
maxPrice, err := sdk.ParseCoinNormalized(args[6])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
kind := args[6]
|
||||
|
||||
numProvidersInt, err := strconv.Atoi(args[7])
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid num-providers value: %w", err)
|
||||
return err
|
||||
}
|
||||
numProviders := int32(numProvidersInt)
|
||||
|
||||
msg := auctiontypes.NewMsgCreateAuction(
|
||||
kind,
|
||||
commitsDuration,
|
||||
revealsDuration,
|
||||
commitFee,
|
||||
@ -188,7 +189,6 @@ func GetCmdCreateAuction() *cobra.Command {
|
||||
minimumBid,
|
||||
maxPrice,
|
||||
numProviders,
|
||||
kind,
|
||||
clientCtx.GetFromAddress(),
|
||||
)
|
||||
err = msg.ValidateBasic()
|
||||
|
@ -81,14 +81,17 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
|
||||
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
|
||||
{
|
||||
RpcMethod: "CreateAuction",
|
||||
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 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"},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -17,6 +17,7 @@ var (
|
||||
|
||||
// NewMsgCreateAuction is the constructor function for MsgCreateAuction.
|
||||
func NewMsgCreateAuction(
|
||||
kind string,
|
||||
commitsDuration time.Duration,
|
||||
revealsDuration time.Duration,
|
||||
commitFee sdk.Coin,
|
||||
@ -24,7 +25,6 @@ func NewMsgCreateAuction(
|
||||
minimumBid sdk.Coin,
|
||||
maxPrice sdk.Coin,
|
||||
numProviders int32,
|
||||
kind string,
|
||||
signer sdk.AccAddress,
|
||||
) MsgCreateAuction {
|
||||
fmt.Print(signer.String())
|
||||
@ -56,20 +56,30 @@ func (msg MsgCreateAuction) ValidateBasic() error {
|
||||
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer)
|
||||
}
|
||||
|
||||
if msg.Kind != AuctionKindVickrey && msg.Kind != AuctionKindProvider {
|
||||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("auction kind should be one of %s | %s", AuctionKindVickrey, AuctionKindProvider))
|
||||
}
|
||||
|
||||
if msg.CommitsDuration <= 0 {
|
||||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "commit phase duration invalid.")
|
||||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "commit phase duration invalid")
|
||||
}
|
||||
|
||||
if msg.RevealsDuration <= 0 {
|
||||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "reveal phase duration invalid.")
|
||||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "reveal phase duration invalid")
|
||||
}
|
||||
|
||||
if msg.Kind == AuctionKindVickrey && !msg.MinimumBid.IsPositive() {
|
||||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "minimum bid should be greater than zero.")
|
||||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("minimum bid should be greater than zero for %s auction", AuctionKindVickrey))
|
||||
}
|
||||
|
||||
if msg.Kind == AuctionKindProvider && !msg.MaxPrice.IsPositive() {
|
||||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "maximum price should be greater than zero.")
|
||||
if msg.Kind == AuctionKindProvider {
|
||||
if !msg.MaxPrice.IsPositive() {
|
||||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("max price should be greater than zero for %s auction", AuctionKindProvider))
|
||||
}
|
||||
|
||||
if msg.NumProviders <= 0 {
|
||||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("num providers should be greater than zero for %s auction", AuctionKindProvider))
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -289,14 +289,14 @@ func (k Keeper) createAuthority(ctx sdk.Context, name string, owner string, isRo
|
||||
|
||||
// Create an auction.
|
||||
msg := auctiontypes.NewMsgCreateAuction(
|
||||
auctiontypes.AuctionKindVickrey,
|
||||
moduleParams.AuthorityAuctionCommitsDuration,
|
||||
moduleParams.AuthorityAuctionRevealsDuration,
|
||||
moduleParams.AuthorityAuctionCommitFee,
|
||||
moduleParams.AuthorityAuctionRevealFee,
|
||||
moduleParams.AuthorityAuctionMinimumBid,
|
||||
sdk.NewCoin("alnt", math.NewInt(0)),
|
||||
int32(1),
|
||||
auctiontypes.AuctionKindVickrey,
|
||||
0,
|
||||
ownerAddress,
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user