mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-24 15:25:18 +00:00
tidy up events
This commit is contained in:
parent
f86d0f3c3b
commit
4039086e8d
@ -36,7 +36,7 @@ func (k Keeper) StartSurplusAuction(ctx sdk.Context, seller string, lot sdk.Coin
|
|||||||
types.EventTypeAuctionStart,
|
types.EventTypeAuctionStart,
|
||||||
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auction.GetID())),
|
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auction.GetID())),
|
||||||
sdk.NewAttribute(types.AttributeKeyAuctionType, auction.GetType()),
|
sdk.NewAttribute(types.AttributeKeyAuctionType, auction.GetType()),
|
||||||
sdk.NewAttribute(types.AttributeKeyBidDenom, auction.Bid.Denom),
|
sdk.NewAttribute(types.AttributeKeyBid, auction.Bid.String()),
|
||||||
sdk.NewAttribute(types.AttributeKeyLot, auction.Lot.String()),
|
sdk.NewAttribute(types.AttributeKeyLot, auction.Lot.String()),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -77,7 +77,7 @@ func (k Keeper) StartDebtAuction(ctx sdk.Context, buyer string, bid sdk.Coin, in
|
|||||||
types.EventTypeAuctionStart,
|
types.EventTypeAuctionStart,
|
||||||
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auction.GetID())),
|
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auction.GetID())),
|
||||||
sdk.NewAttribute(types.AttributeKeyAuctionType, auction.GetType()),
|
sdk.NewAttribute(types.AttributeKeyAuctionType, auction.GetType()),
|
||||||
sdk.NewAttribute(types.AttributeKeyBidDenom, auction.Bid.Denom),
|
sdk.NewAttribute(types.AttributeKeyBid, auction.Bid.String()),
|
||||||
sdk.NewAttribute(types.AttributeKeyLot, auction.Lot.String()),
|
sdk.NewAttribute(types.AttributeKeyLot, auction.Lot.String()),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -122,9 +122,9 @@ func (k Keeper) StartCollateralAuction(
|
|||||||
types.EventTypeAuctionStart,
|
types.EventTypeAuctionStart,
|
||||||
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auction.GetID())),
|
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auction.GetID())),
|
||||||
sdk.NewAttribute(types.AttributeKeyAuctionType, auction.GetType()),
|
sdk.NewAttribute(types.AttributeKeyAuctionType, auction.GetType()),
|
||||||
sdk.NewAttribute(types.AttributeKeyBidDenom, auction.Bid.Denom),
|
sdk.NewAttribute(types.AttributeKeyBid, auction.Bid.String()),
|
||||||
sdk.NewAttribute(types.AttributeKeyLot, auction.Lot.String()),
|
sdk.NewAttribute(types.AttributeKeyLot, auction.Lot.String()),
|
||||||
sdk.NewAttribute(types.AttributeKeyMaxBidAmount, auction.MaxBid.String()),
|
sdk.NewAttribute(types.AttributeKeyMaxBid, auction.MaxBid.String()),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return auctionID, nil
|
return auctionID, nil
|
||||||
@ -352,7 +352,7 @@ func (k Keeper) PlaceReverseBidCollateral(ctx sdk.Context, a types.CollateralAuc
|
|||||||
return a, err
|
return a, err
|
||||||
}
|
}
|
||||||
for i, payout := range lotPayouts {
|
for i, payout := range lotPayouts {
|
||||||
// if due to rounding, for whatever reason, the lot amount is 0, don't execute the following code
|
// if the payout amount is 0, don't send 0 coins
|
||||||
if payout.IsPositive() {
|
if payout.IsPositive() {
|
||||||
err = k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, a.LotReturns.Addresses[i], sdk.NewCoins(payout))
|
err = k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, a.LotReturns.Addresses[i], sdk.NewCoins(payout))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -488,7 +488,7 @@ func (k Keeper) CloseAuction(ctx sdk.Context, auctionID uint64) error {
|
|||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
types.EventTypeAuctionClose,
|
types.EventTypeAuctionClose,
|
||||||
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auction.GetID())),
|
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auction.GetID())),
|
||||||
// TODO: add closed height here to facilitate the query of the auction after it closes
|
sdk.NewAttribute(types.AttributeKeyCloseBlock, fmt.Sprintf("%d", ctx.BlockHeight()))
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return nil
|
return nil
|
||||||
|
@ -11,8 +11,7 @@ import (
|
|||||||
// https://en.wikipedia.org/wiki/Largest_remainder_method
|
// https://en.wikipedia.org/wiki/Largest_remainder_method
|
||||||
// see also: https://stackoverflow.com/questions/13483430/how-to-make-rounded-percentages-add-up-to-100
|
// see also: https://stackoverflow.com/questions/13483430/how-to-make-rounded-percentages-add-up-to-100
|
||||||
func splitIntIntoWeightedBuckets(amount sdk.Int, buckets []sdk.Int) []sdk.Int {
|
func splitIntIntoWeightedBuckets(amount sdk.Int, buckets []sdk.Int) []sdk.Int {
|
||||||
// TODO: ideally change algorithm to work with -ve numbers. Limiting to +ve numbers until them
|
// Limit input to +ve numbers as algorithm hasn't been designed to work with -ve numbers.
|
||||||
// TODO: negative buckets don't make sense in this context
|
|
||||||
if amount.IsNegative() {
|
if amount.IsNegative() {
|
||||||
panic("negative amount")
|
panic("negative amount")
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,13 @@ The `x/auction` module emits the following events:
|
|||||||
|
|
||||||
## Triggered By Other Modules
|
## Triggered By Other Modules
|
||||||
|
|
||||||
| Type | Attribute Key | Attribute Value |
|
| Type | Attribute Key | Attribute Value |
|
||||||
|---------------|---------------|---------------------|
|
|---------------|---------------|-----------------|
|
||||||
| auction_start | auction_id | {auction ID} |
|
| auction_start | auction_id | {auction ID} |
|
||||||
| auction_start | auction_type | {auction type} |
|
| auction_start | auction_type | {auction type} |
|
||||||
| auction_start | lot_denom | {auction lot denom} |
|
| auction_start | lot | {coin amount} |
|
||||||
| auction_start | bid_denom | {auction bid denom} |
|
| auction_start | bid | {coin amount} |
|
||||||
|
| auction_start | max_bid | {coin amount} |
|
||||||
|
|
||||||
## Handlers
|
## Handlers
|
||||||
|
|
||||||
@ -19,8 +20,8 @@ The `x/auction` module emits the following events:
|
|||||||
|-------------|---------------|--------------------|
|
|-------------|---------------|--------------------|
|
||||||
| auction_bid | auction_id | {auction ID} |
|
| auction_bid | auction_id | {auction ID} |
|
||||||
| auction_bid | bidder | {latest bidder} |
|
| auction_bid | bidder | {latest bidder} |
|
||||||
| auction_bid | bid_amount | {coin amount} |
|
| auction_bid | bid | {coin amount} |
|
||||||
| auction_bid | lot_amount | {coin amount} |
|
| auction_bid | lot | {coin amount} |
|
||||||
| auction_bid | end_time | {auction end time} |
|
| auction_bid | end_time | {auction end time} |
|
||||||
| message | module | auction |
|
| message | module | auction |
|
||||||
| message | sender | {sender address} |
|
| message | sender | {sender address} |
|
||||||
@ -30,3 +31,4 @@ The `x/auction` module emits the following events:
|
|||||||
| Type | Attribute Key | Attribute Value |
|
| Type | Attribute Key | Attribute Value |
|
||||||
|---------------|---------------|-----------------|
|
|---------------|---------------|-----------------|
|
||||||
| auction_close | auction_id | {auction ID} |
|
| auction_close | auction_id | {auction ID} |
|
||||||
|
| auction_close | close_block | {block height} |
|
||||||
|
@ -1,21 +1,18 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
// Events for auction module
|
// Events for the module
|
||||||
const (
|
const (
|
||||||
EventTypeAuctionStart = "auction_start"
|
EventTypeAuctionStart = "auction_start"
|
||||||
EventTypeAuctionBid = "auction_bid"
|
EventTypeAuctionBid = "auction_bid"
|
||||||
EventTypeAuctionClose = "auction_close"
|
EventTypeAuctionClose = "auction_close"
|
||||||
|
|
||||||
AttributeValueCategory = ModuleName
|
AttributeValueCategory = ModuleName
|
||||||
AttributeKeyAuctionID = "auction_id"
|
AttributeKeyAuctionID = "auction_id"
|
||||||
AttributeKeyAuctionType = "auction_type"
|
AttributeKeyAuctionType = "auction_type"
|
||||||
AttributeKeyBidder = "bidder"
|
AttributeKeyBidder = "bidder"
|
||||||
AttributeKeyBidDenom = "bid_denom"
|
AttributeKeyLot = "lot"
|
||||||
AttributeKeyLotDenom = "lot_denom"
|
AttributeKeyMaxBid = "max_bid"
|
||||||
AttributeKeyLot = "lot"
|
AttributeKeyBid = "bid"
|
||||||
AttributeKeyMaxBidAmount = "max_bid"
|
AttributeKeyEndTime = "end_time"
|
||||||
AttributeKeyBidAmount = "bid_amount"
|
AttributeKeyCloseBlock = "close_block"
|
||||||
AttributeKeyBid = "bid"
|
|
||||||
AttributeKeyLotAmount = "lot_amount"
|
|
||||||
AttributeKeyEndTime = "end_time"
|
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user