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