emit subscribable events for core module auctions

master
michael 2022-09-21 20:31:20 +00:00
parent d51de8f3bc
commit bfa30082f1
5 changed files with 63 additions and 0 deletions

View File

@ -81,6 +81,14 @@ func (k Keeper) FinalizeExpiredAuctions(ctx sdk.Context) {
// end auction // end auction
k.SetAuction(ctx, auction) k.SetAuction(ctx, auction)
// emit finalization event
ctx.EventManager().EmitEvent(
sdk.NewEvent(types.AuctionFinalizedEventType,
sdk.NewAttribute(types.AuctionFinalizedIndex, auction.Index),
),
)
} }
return nil return nil

View File

@ -70,5 +70,13 @@ func (k msgServer) ClaimFunds(goCtx context.Context, msg *types.MsgClaimFunds) (
auction.Remaining = newRemaining.String() auction.Remaining = newRemaining.String()
k.Keeper.SetAuction(ctx, auction) k.Keeper.SetAuction(ctx, auction)
ctx.EventManager().EmitEvent(
sdk.NewEvent(types.LeaseFundsClaimedEventType,
sdk.NewAttribute(types.LeaseFundsClaimedEventCreator, msg.Creator),
sdk.NewAttribute(types.LeaseFundsClaimedAmountClaimed, subAmt.String()),
sdk.NewAttribute(types.LeaseFundsClaimedAmountRemaining, auction.Remaining),
),
)
return &types.MsgClaimFundsResponse{}, nil return &types.MsgClaimFundsResponse{}, nil
} }

View File

@ -112,6 +112,15 @@ found:
k.Keeper.SetNextAuction(ctx, types.NextAuction{AuctionId: next.AuctionId}) k.Keeper.SetNextAuction(ctx, types.NextAuction{AuctionId: next.AuctionId})
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.AuctionCreatedEventType,
sdk.NewAttribute(types.AuctionCreatedIndex, auction.Index),
sdk.NewAttribute(types.AuctionCreatedEventCreator, msg.Creator),
sdk.NewAttribute(types.AuctionCreatedCeiling, msg.Ceiling),
),
)
return &types.MsgNewAuctionResponse{ return &types.MsgNewAuctionResponse{
AuctionId: strconv.FormatUint(next.AuctionId, 10), AuctionId: strconv.FormatUint(next.AuctionId, 10),
}, nil }, nil

View File

@ -104,5 +104,15 @@ bidderVerified:
return nil, fmt.Errorf("failed to add bid: %s", err) return nil, fmt.Errorf("failed to add bid: %s", err)
} }
// emit bid event
ctx.EventManager().EmitEvent(
sdk.NewEvent(types.BidCreatedEventType,
sdk.NewAttribute(types.BidCreatedEventCreator, msg.Creator),
sdk.NewAttribute(types.BidCreatedAuctionIndex, msg.AuctionIndex),
sdk.NewAttribute(types.BidCreatedAmount, msg.Amount),
),
)
return &types.MsgNewBidResponse{}, nil return &types.MsgNewBidResponse{}, nil
} }

View File

@ -28,3 +28,31 @@ const (
const ( const (
LockedUsersKey = "LockedUsers-value-" LockedUsersKey = "LockedUsers-value-"
) )
// Module Events
const (
AuctionCreatedEventType = "auction-created"
AuctionCreatedEventCreator = "creator"
AuctionCreatedIndex = "auction-id"
AuctionCreatedCeiling = "ceiling"
)
const (
BidCreatedEventType = "bid-created"
BidCreatedEventCreator = "creator"
BidCreatedAuctionIndex = "auction-id"
BidCreatedAmount = "amount"
)
const (
AuctionFinalizedEventType = "auction-finalized"
AuctionFinalizedIndex = "auction-id"
)
const (
LeaseFundsClaimedEventType = "lease-claimed"
LeaseFundsClaimedEventCreator = "claimer"
LeaseFundsClaimedAmountClaimed = "amount-claimed"
LeaseFundsClaimedAmountRemaining = "amount-remaining"
)