diff --git a/proto/arkeo/arkeo/events.proto b/proto/arkeo/arkeo/events.proto new file mode 100644 index 00000000..055fe6eb --- /dev/null +++ b/proto/arkeo/arkeo/events.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package arkeo.arkeo; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/arkeonetwork/arkeo/x/arkeo/types"; + +message EventBondProvider { + string creator = 1; + string provider = 2 [ (gogoproto.casttype) = "github.com/arkeonetwork/arkeo/common.PubKey" ]; + string service = 3; + string bond = 4 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} diff --git a/x/arkeo/keeper/events.go b/x/arkeo/keeper/events.go index 16b8d684..fab0012e 100644 --- a/x/arkeo/keeper/events.go +++ b/x/arkeo/keeper/events.go @@ -7,10 +7,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k msgServer) BondProviderEvent(ctx cosmos.Context, bond cosmos.Int, msg *types.MsgBondProvider) { - ctx.EventManager().EmitEvents( - sdk.Events{ - types.NewBondProviderEvent(bond, msg), +func (k msgServer) EmitBondProviderEvent(ctx cosmos.Context, bond cosmos.Int, msg *types.MsgBondProvider) error { + return ctx.EventManager().EmitTypedEvent( + &types.EventBondProvider{ + Provider: msg.Provider, + Creator: msg.Creator, + Service: msg.Service, + Bond: msg.Bond, }, ) } diff --git a/x/arkeo/keeper/msg_server_bond_provider.go b/x/arkeo/keeper/msg_server_bond_provider.go index 06f5e307..6c8e7261 100644 --- a/x/arkeo/keeper/msg_server_bond_provider.go +++ b/x/arkeo/keeper/msg_server_bond_provider.go @@ -89,15 +89,14 @@ func (k msgServer) BondProviderHandle(ctx cosmos.Context, msg *types.MsgBondProv provider.Bond = provider.Bond.Add(msg.Bond) if provider.Bond.IsZero() { k.RemoveProvider(ctx, provider.PubKey, provider.Service) - k.BondProviderEvent(ctx, provider.Bond, msg) - return nil + return k.EmitBondProviderEvent(ctx, provider.Bond, msg) } provider.LastUpdate = ctx.BlockHeight() err = k.SetProvider(ctx, provider) if err == nil { - k.BondProviderEvent(ctx, provider.Bond, msg) + return k.EmitBondProviderEvent(ctx, provider.Bond, msg) } return err }