Skip to content

Commit

Permalink
feat(uibc): quota reset event (#2264)
Browse files Browse the repository at this point in the history
* feat(uibc): quota reset log

* emit event

* type update
  • Loading branch information
robert-zaremba authored Sep 26, 2023
1 parent 3c58f67 commit 5596d9f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions x/uibc/module/abci.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
package uibc

import (
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/umee-network/umee/v6/x/uibc/quota/keeper"
)

// BeginBlock implements BeginBlock for the x/uibc module.
func BeginBlock(ctx sdk.Context, k keeper.Keeper) {
logger := ctx.Logger().With("module", "uibc")
quotaExpires, err := k.GetExpire()
if err != nil {
// TODO, use logger as argument
ctx.Logger().Error("can't get quota exipre", "error", err)
logger.Error("can't get quota exipre", "error", err)
return
}

// reset quotas
if quotaExpires == nil || quotaExpires.Before(ctx.BlockTime()) {
if err = k.ResetAllQuotas(); err != nil {
ctx.Logger().Error("can't get quota exipre", "error", err)
logger.Error("can't get quota exipre", "error", err)
} else {
logger.Info("IBC Quota Reset")
ctx.EventManager().EmitEvent(
sdk.NewEvent("/umee/uibc/v1/EventQuotaReset",
sdk.NewAttribute("next_expire", quotaExpires.UTC().Format(time.RFC3339))))
}
}
}
Expand Down

0 comments on commit 5596d9f

Please sign in to comment.