Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] proposal events #324

Merged
merged 1 commit into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/terra-project/core
go 1.13

require (
github.com/cosmos/cosmos-sdk v0.37.6
github.com/cosmos/cosmos-sdk v0.37.7
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d // indirect
github.com/gorilla/mux v1.7.2
github.com/otiai10/copy v1.0.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8Nz
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosmos/cosmos-sdk v0.37.6 h1:l7urou9aTPqW/x3Hq+SAWn6OHDzjma+1OVi0TT+O36M=
github.com/cosmos/cosmos-sdk v0.37.6/go.mod h1:63Y8V75rRDzUrtRUwy+5cBOy5mr6xytI11PBk53tBrE=
github.com/cosmos/cosmos-sdk v0.37.7 h1:3RpPXxEShRjx2tSgB9/RTtah4wTYom+vF8ZogPum6RM=
github.com/cosmos/cosmos-sdk v0.37.7/go.mod h1:63Y8V75rRDzUrtRUwy+5cBOy5mr6xytI11PBk53tBrE=
github.com/cosmos/go-bip39 v0.0.0-20180618194314-52158e4697b8/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
Expand Down
2 changes: 1 addition & 1 deletion x/treasury/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func EndBlocker(ctx sdk.Context, k Keeper) {
taxCap := k.UpdateTaxCap(ctx)

ctx.EventManager().EmitEvent(
sdk.NewEvent(types.EventTypePolichUpdate,
sdk.NewEvent(types.EventTypePolicyUpdate,
sdk.NewAttribute(types.AttributeKeyTaxRate, taxRate.String()),
sdk.NewAttribute(types.AttributeKeyRewardWeight, rewardWeight.String()),
sdk.NewAttribute(types.AttributeKeyTaxCap, taxCap.String()),
Expand Down
16 changes: 16 additions & 0 deletions x/treasury/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

"github.com/terra-project/core/x/treasury/internal/types"
)

// NewTreasuryPolicyUpdateHandler custom gov proposal handler
Expand Down Expand Up @@ -32,6 +34,13 @@ func handleTaxRateUpdateProposal(ctx sdk.Context, k Keeper, p TaxRateUpdatePropo
// Set the new tax rate to the store
k.SetTaxRate(ctx, newTaxRate)

// Emit gov handler events
ctx.EventManager().EmitEvent(
sdk.NewEvent(types.EventTypeTaxRateUpdate,
sdk.NewAttribute(types.AttributeKeyTaxRate, newTaxRate.String()),
),
)

logger := k.Logger(ctx)
logger.Info(fmt.Sprintf("updated tax-rate to %s", newTaxRate))
return nil
Expand All @@ -46,6 +55,13 @@ func handleRewardWeightUpdateProposal(ctx sdk.Context, k Keeper, p RewardWeightU
// Set the new reward rate to the store
k.SetRewardWeight(ctx, newRewardWeight)

// Emit gov handler events
ctx.EventManager().EmitEvent(
sdk.NewEvent(types.EventTypeRewardWeightUpdate,
sdk.NewAttribute(types.AttributeKeyRewardWeight, newRewardWeight.String()),
),
)

logger := k.Logger(ctx)
logger.Info(fmt.Sprintf("updated reward-weight to %s", newRewardWeight))
return nil
Expand Down
1 change: 0 additions & 1 deletion x/treasury/internal/test_common.go

This file was deleted.

4 changes: 3 additions & 1 deletion x/treasury/internal/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package types

// Treasury module event types
const (
EventTypePolichUpdate = "policy_update"
EventTypePolicyUpdate = "policy_update"
EventTypeTaxRateUpdate = "tax_rate_update"
EventTypeRewardWeightUpdate = "reward_weight_update"

AttributeKeyTaxRate = "tax_rate"
AttributeKeyRewardWeight = "reward_weight"
Expand Down