From 0c3c9eb18a9dddc5ab18b0021c40c349918a69b3 Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Mon, 25 Sep 2023 19:13:39 +0200 Subject: [PATCH 1/3] feat(uibc): quota reset log --- x/uibc/module/abci.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/uibc/module/abci.go b/x/uibc/module/abci.go index 4b72338e46..6b030094cb 100644 --- a/x/uibc/module/abci.go +++ b/x/uibc/module/abci.go @@ -19,6 +19,8 @@ func BeginBlock(ctx sdk.Context, k keeper.Keeper) { if quotaExpires == nil || quotaExpires.Before(ctx.BlockTime()) { if err = k.ResetAllQuotas(); err != nil { ctx.Logger().Error("can't get quota exipre", "error", err) + } else { + ctx.Logger().With("module", "uibc").Info("IBC Quota Reset") } } } From 7413f95f084cf66263ec60c2c66e19e589249554 Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Mon, 25 Sep 2023 20:02:00 +0200 Subject: [PATCH 2/3] emit event --- x/uibc/module/abci.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/x/uibc/module/abci.go b/x/uibc/module/abci.go index 6b030094cb..39d4c928c3 100644 --- a/x/uibc/module/abci.go +++ b/x/uibc/module/abci.go @@ -1,6 +1,8 @@ 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" @@ -8,19 +10,23 @@ import ( // 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 { - ctx.Logger().With("module", "uibc").Info("IBC Quota Reset") + logger.Info("IBC Quota Reset") + ctx.EventManager().EmitEvent( + sdk.NewEvent("/umee/uibc/v1/QuotaReset", + sdk.NewAttribute("next_expire", quotaExpires.UTC().Format(time.RFC3339)))) } } } From 6d1f0bc31ccca6587ba7142e5ff142b884bb1d4f Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Mon, 25 Sep 2023 20:03:58 +0200 Subject: [PATCH 3/3] type update --- x/uibc/module/abci.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/uibc/module/abci.go b/x/uibc/module/abci.go index 39d4c928c3..4c5df229be 100644 --- a/x/uibc/module/abci.go +++ b/x/uibc/module/abci.go @@ -25,7 +25,7 @@ func BeginBlock(ctx sdk.Context, k keeper.Keeper) { } else { logger.Info("IBC Quota Reset") ctx.EventManager().EmitEvent( - sdk.NewEvent("/umee/uibc/v1/QuotaReset", + sdk.NewEvent("/umee/uibc/v1/EventQuotaReset", sdk.NewAttribute("next_expire", quotaExpires.UTC().Format(time.RFC3339)))) } }