diff --git a/go.mod b/go.mod index 70d3ab513..5e26000c1 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/decred/dcrd/dcrec/edwards v1.0.0 github.com/dustin/go-humanize v1.0.1 github.com/dymensionxyz/gerr-cosmos v1.0.0 - github.com/dymensionxyz/sdk-utils v0.2.7 + github.com/dymensionxyz/sdk-utils v0.2.8-0.20240823083607-ea6d7a482d69 github.com/ethereum/go-ethereum v1.10.26 github.com/evmos/ethermint v0.22.0 github.com/gogo/protobuf v1.3.3 diff --git a/go.sum b/go.sum index b957deb8e..5a9e85316 100644 --- a/go.sum +++ b/go.sum @@ -508,8 +508,8 @@ github.com/dymensionxyz/osmosis/osmomath v0.0.6-dymension-v0.1.0.20240820121212- github.com/dymensionxyz/osmosis/osmomath v0.0.6-dymension-v0.1.0.20240820121212-c0e21fa21e43/go.mod h1:SdGCL9CZb14twRAJUSzb7bRE0OoopRpF2Hnd1UhJpFU= github.com/dymensionxyz/osmosis/v15 v15.2.1-0.20240820121212-c0e21fa21e43 h1:ugbpHwwlckB4W/aNXUTEsxaakPFgXi+LAsCtvfJ200Q= github.com/dymensionxyz/osmosis/v15 v15.2.1-0.20240820121212-c0e21fa21e43/go.mod h1:2rsnXAdjYfXtyEw0mNwAdOiAccALYjAPvINGUf9Qg7Y= -github.com/dymensionxyz/sdk-utils v0.2.7 h1:9Hy56ivv81ISIG7x9AMaNo6GABRuEgZQ+MmS2PdfuW0= -github.com/dymensionxyz/sdk-utils v0.2.7/go.mod h1:it9owYOpnIe17+ftTATQNDN4z+mBQx20/2Jm8SK15Rk= +github.com/dymensionxyz/sdk-utils v0.2.8-0.20240823083607-ea6d7a482d69 h1:gecl8M1LJpyfInzTfFFlD48u419jBm0BKNHf/b6ZElc= +github.com/dymensionxyz/sdk-utils v0.2.8-0.20240823083607-ea6d7a482d69/go.mod h1:it9owYOpnIe17+ftTATQNDN4z+mBQx20/2Jm8SK15Rk= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= diff --git a/x/eibc/keeper/handler.go b/x/eibc/keeper/handler.go index 80bcc7f6a..f8d0ca980 100644 --- a/x/eibc/keeper/handler.go +++ b/x/eibc/keeper/handler.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + "github.com/dymensionxyz/sdk-utils/utils/uevent" "github.com/dymensionxyz/sdk-utils/utils/uibc" "github.com/pkg/errors" @@ -52,7 +53,7 @@ func (k Keeper) EIBCDemandOrderHandler(ctx sdk.Context, rollappPacket commontype return fmt.Errorf("set eibc demand order: %w", err) } - if err = ctx.EventManager().EmitTypedEvent(eibcDemandOrder.GetCreatedEvent()); err != nil { + if err = uevent.EmitTypedEvent(ctx, eibcDemandOrder.GetCreatedEvent()); err != nil { return fmt.Errorf("emit event: %w", err) } diff --git a/x/eibc/keeper/keeper.go b/x/eibc/keeper/keeper.go index 764c818ca..e92b74ebe 100644 --- a/x/eibc/keeper/keeper.go +++ b/x/eibc/keeper/keeper.go @@ -8,6 +8,7 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/dymensionxyz/sdk-utils/utils/uevent" commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" @@ -95,7 +96,7 @@ func (k *Keeper) UpdateDemandOrderWithStatus(ctx sdk.Context, demandOrder *types return nil, err } - if err = ctx.EventManager().EmitTypedEvent(demandOrder.GetPacketStatusUpdatedEvent()); err != nil { + if err = uevent.EmitTypedEvent(ctx, demandOrder.GetPacketStatusUpdatedEvent()); err != nil { return nil, fmt.Errorf("emit event: %w", err) } diff --git a/x/eibc/keeper/msg_server.go b/x/eibc/keeper/msg_server.go index 59ecc5973..8385c55dc 100644 --- a/x/eibc/keeper/msg_server.go +++ b/x/eibc/keeper/msg_server.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + "github.com/dymensionxyz/sdk-utils/utils/uevent" commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" "github.com/dymensionxyz/dymension/v3/x/eibc/types" @@ -64,7 +65,7 @@ func (m msgServer) FulfillOrder(goCtx context.Context, msg *types.MsgFulfillOrde return nil, err } - if err = ctx.EventManager().EmitTypedEvent(demandOrder.GetFulfilledEvent()); err != nil { + if err = uevent.EmitTypedEvent(ctx, demandOrder.GetFulfilledEvent()); err != nil { return nil, fmt.Errorf("emit event: %w", err) } @@ -127,7 +128,7 @@ func (m msgServer) UpdateDemandOrder(goCtx context.Context, msg *types.MsgUpdate return nil, err } - if err = ctx.EventManager().EmitTypedEvent(demandOrder.GetUpdatedEvent()); err != nil { + if err = uevent.EmitTypedEvent(ctx, demandOrder.GetUpdatedEvent()); err != nil { return nil, fmt.Errorf("emit event: %w", err) } diff --git a/x/eibc/keeper/msg_server_test.go b/x/eibc/keeper/msg_server_test.go index e9d113a8f..5aa46c2b2 100644 --- a/x/eibc/keeper/msg_server_test.go +++ b/x/eibc/keeper/msg_server_test.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/gogoproto/proto" + "github.com/dymensionxyz/sdk-utils/utils/uevent" "github.com/dymensionxyz/dymension/v3/app/apptesting" commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" @@ -200,7 +201,7 @@ func (suite *KeeperTestSuite) TestFulfillOrderEvent() { if tc.expectedPostFulfillmentEventsCount > 0 { lastEvent, ok := suite.FindLastEventOfType(suite.Ctx.EventManager().Events(), eventName) suite.Require().True(ok) - event, _ := sdk.TypedEventToEvent(tc.expectedPostFulfillmentEvent) + event, _ := uevent.TypedEventToEvent(tc.expectedPostFulfillmentEvent) suite.AssertAttributes(lastEvent, getEventAttributes(event)) } } diff --git a/x/rollapp/keeper/msg_server_create_rollapp.go b/x/rollapp/keeper/msg_server_create_rollapp.go index b5d5a75ce..66a720378 100644 --- a/x/rollapp/keeper/msg_server_create_rollapp.go +++ b/x/rollapp/keeper/msg_server_create_rollapp.go @@ -5,6 +5,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/sdk-utils/utils/uevent" "github.com/dymensionxyz/dymension/v3/x/rollapp/types" ) @@ -27,7 +28,7 @@ func (k msgServer) CreateRollapp(goCtx context.Context, msg *types.MsgCreateRoll return nil, fmt.Errorf("rollapp created hook: %w", err) } - if err := ctx.EventManager().EmitTypedEvent(msg); err != nil { + if err := uevent.EmitTypedEvent(ctx, msg); err != nil { return nil, fmt.Errorf("emit event: %w", err) } diff --git a/x/rollapp/keeper/msg_server_transfer_ownership.go b/x/rollapp/keeper/msg_server_transfer_ownership.go index 55851a279..d6498eca6 100644 --- a/x/rollapp/keeper/msg_server_transfer_ownership.go +++ b/x/rollapp/keeper/msg_server_transfer_ownership.go @@ -6,6 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/sdk-utils/utils/uevent" "github.com/dymensionxyz/dymension/v3/x/rollapp/types" ) @@ -37,7 +38,7 @@ func (k msgServer) TransferOwnership(goCtx context.Context, msg *types.MsgTransf rollapp.Owner = msg.NewOwner k.SetRollapp(ctx, rollapp) - if err := ctx.EventManager().EmitTypedEvent(msg); err != nil { + if err := uevent.EmitTypedEvent(ctx, msg); err != nil { return nil, fmt.Errorf("emit event: %w", err) } diff --git a/x/rollapp/keeper/msg_server_update_rollapp.go b/x/rollapp/keeper/msg_server_update_rollapp.go index 029da7d89..b0d00d3e7 100644 --- a/x/rollapp/keeper/msg_server_update_rollapp.go +++ b/x/rollapp/keeper/msg_server_update_rollapp.go @@ -5,6 +5,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/sdk-utils/utils/uevent" "github.com/dymensionxyz/dymension/v3/x/rollapp/types" ) @@ -19,7 +20,7 @@ func (k msgServer) UpdateRollappInformation(goCtx context.Context, msg *types.Ms k.SetRollapp(ctx, updated) - if err = ctx.EventManager().EmitTypedEvent(msg); err != nil { + if err = uevent.EmitTypedEvent(ctx, msg); err != nil { return nil, fmt.Errorf("emit event: %w", err) } diff --git a/x/sequencer/keeper/msg_server_increase_bond.go b/x/sequencer/keeper/msg_server_increase_bond.go index 91151c71c..414c36af8 100644 --- a/x/sequencer/keeper/msg_server_increase_bond.go +++ b/x/sequencer/keeper/msg_server_increase_bond.go @@ -2,8 +2,11 @@ package keeper import ( "context" + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/sdk-utils/utils/uevent" + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) @@ -28,15 +31,18 @@ func (k msgServer) IncreaseBond(goCtx context.Context, msg *types.MsgIncreaseBon k.UpdateSequencer(ctx, &sequencer, sequencer.Status) // emit a typed event which includes the added amount and the active bond amount - err = ctx.EventManager().EmitTypedEvent( + err = uevent.EmitTypedEvent(ctx, &types.EventIncreasedBond{ Sequencer: msg.Creator, Bond: sequencer.Tokens, AddedAmount: msg.AddAmount, }, ) + if err != nil { + return nil, fmt.Errorf("emit event: %w", err) + } - return &types.MsgIncreaseBondResponse{}, err + return &types.MsgIncreaseBondResponse{}, nil } func (k msgServer) bondUpdateAllowed(ctx sdk.Context, senderAddress string) (types.Sequencer, error) { diff --git a/x/sequencer/keeper/msg_server_update_sequencer.go b/x/sequencer/keeper/msg_server_update_sequencer.go index 47ba8784e..9431bf9bf 100644 --- a/x/sequencer/keeper/msg_server_update_sequencer.go +++ b/x/sequencer/keeper/msg_server_update_sequencer.go @@ -5,6 +5,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/sdk-utils/utils/uevent" "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) @@ -36,7 +37,7 @@ func (k msgServer) UpdateSequencerInformation(goCtx context.Context, msg *types. k.SetSequencer(ctx, sequencer) - if err := ctx.EventManager().EmitTypedEvent(&sequencer); err != nil { + if err := uevent.EmitTypedEvent(ctx, &sequencer); err != nil { return nil, fmt.Errorf("emit event: %w", err) } diff --git a/x/sponsorship/keeper/hooks.go b/x/sponsorship/keeper/hooks.go index e55d819c8..dcbb5bb06 100644 --- a/x/sponsorship/keeper/hooks.go +++ b/x/sponsorship/keeper/hooks.go @@ -8,6 +8,7 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/dymensionxyz/sdk-utils/utils/uevent" "github.com/dymensionxyz/dymension/v3/x/sponsorship/types" ) @@ -79,7 +80,7 @@ func (h Hooks) afterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, return fmt.Errorf("cannot process hook: %w", err) } - err = ctx.EventManager().EmitTypedEvent(&types.EventVotingPowerUpdate{ + err = uevent.EmitTypedEvent(ctx, &types.EventVotingPowerUpdate{ Voter: delAddr.String(), Validator: valAddr.String(), Distribution: result.distribution, @@ -88,7 +89,7 @@ func (h Hooks) afterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, VotingPowerDiff: result.vpDiff, }) if err != nil { - return err + return fmt.Errorf("emit event: %w", err) } return nil @@ -128,7 +129,7 @@ func (h Hooks) beforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, return fmt.Errorf("cannot process hook: %w", err) } - err = ctx.EventManager().EmitTypedEvent(&types.EventVotingPowerUpdate{ + err = uevent.EmitTypedEvent(ctx, &types.EventVotingPowerUpdate{ Voter: delAddr.String(), Validator: valAddr.String(), Distribution: result.distribution, @@ -137,7 +138,7 @@ func (h Hooks) beforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, VotingPowerDiff: result.vpDiff, }) if err != nil { - return err + return fmt.Errorf("emit event: %w", err) } return nil diff --git a/x/sponsorship/keeper/msg_server.go b/x/sponsorship/keeper/msg_server.go index ba40c0271..d68dab2e8 100644 --- a/x/sponsorship/keeper/msg_server.go +++ b/x/sponsorship/keeper/msg_server.go @@ -2,9 +2,11 @@ package keeper import ( "context" + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/dymensionxyz/sdk-utils/utils/uevent" "github.com/dymensionxyz/dymension/v3/x/sponsorship/types" ) @@ -34,13 +36,13 @@ func (m MsgServer) Vote(goCtx context.Context, msg *types.MsgVote) (*types.MsgVo return nil, err } - err = ctx.EventManager().EmitTypedEvent(&types.EventVote{ + err = uevent.EmitTypedEvent(ctx, &types.EventVote{ Voter: msg.Voter, Vote: vote, Distribution: distr, }) if err != nil { - return nil, err + return nil, fmt.Errorf("emit event: %w", err) } return &types.MsgVoteResponse{}, nil @@ -61,12 +63,12 @@ func (m MsgServer) RevokeVote(goCtx context.Context, msg *types.MsgRevokeVote) ( return nil, err } - err = ctx.EventManager().EmitTypedEvent(&types.EventRevokeVote{ + err = uevent.EmitTypedEvent(ctx, &types.EventRevokeVote{ Voter: msg.Voter, Distribution: distr, }) if err != nil { - return nil, err + return nil, fmt.Errorf("emit event: %w", err) } return &types.MsgRevokeVoteResponse{}, nil @@ -93,13 +95,13 @@ func (m MsgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) } sdkCtx := sdk.UnwrapSDKContext(ctx) - err = sdkCtx.EventManager().EmitTypedEvent(&types.EventUpdateParams{ + err = uevent.EmitTypedEvent(sdkCtx, &types.EventUpdateParams{ Authority: msg.Authority, NewParams: msg.NewParams, OldParams: oldParams, }) if err != nil { - return nil, err + return nil, fmt.Errorf("emit event: %w", err) } return &types.MsgUpdateParamsResponse{}, nil