diff --git a/x/notifications/keeper/blocks.go b/x/notifications/keeper/blocks.go index 4613c8736..4694b349d 100644 --- a/x/notifications/keeper/blocks.go +++ b/x/notifications/keeper/blocks.go @@ -14,6 +14,14 @@ func (k Keeper) SetBlock(ctx sdk.Context, block types.Block) { block.Address, block.BlockedAddress, ), b) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventBlock, + sdk.NewAttribute(types.AttributeBlocker, block.Address), + sdk.NewAttribute(types.AttributeBlockee, block.BlockedAddress), + ), + ) } // IsBlocked returns if a user is blocked diff --git a/x/notifications/keeper/msg_server_block_senders.go b/x/notifications/keeper/msg_server_block_senders.go index e4f416b4e..944261c66 100644 --- a/x/notifications/keeper/msg_server_block_senders.go +++ b/x/notifications/keeper/msg_server_block_senders.go @@ -27,5 +27,12 @@ func (k msgServer) BlockSenders(goCtx context.Context, msg *types.MsgBlockSender } + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventBlockSenders, + sdk.NewAttribute(types.AttributeSigner, msg.Creator), + ), + ) + return &types.MsgBlockSendersResponse{}, nil } diff --git a/x/notifications/keeper/msg_server_create_notifications.go b/x/notifications/keeper/msg_server_create_notifications.go index b8335da18..01b3ae5fe 100644 --- a/x/notifications/keeper/msg_server_create_notifications.go +++ b/x/notifications/keeper/msg_server_create_notifications.go @@ -39,5 +39,12 @@ func (k msgServer) CreateNotification(goCtx context.Context, msg *types.MsgCreat k.SetNotification(ctx, noti) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventCreateNotification, + sdk.NewAttribute(types.AttributeSigner, msg.Creator), + ), + ) + return &types.MsgCreateNotificationResponse{}, nil } diff --git a/x/notifications/keeper/msg_server_delete_notifications.go b/x/notifications/keeper/msg_server_delete_notifications.go index efcac09b5..03681447f 100644 --- a/x/notifications/keeper/msg_server_delete_notifications.go +++ b/x/notifications/keeper/msg_server_delete_notifications.go @@ -13,5 +13,12 @@ func (k msgServer) DeleteNotification(goCtx context.Context, msg *types.MsgDelet k.RemoveNotification(ctx, msg.Creator, msg.From, msg.Time) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventRemoveNotification, + sdk.NewAttribute(types.AttributeSigner, msg.Creator), + ), + ) + return &types.MsgDeleteNotificationResponse{}, nil } diff --git a/x/notifications/keeper/notifications.go b/x/notifications/keeper/notifications.go index c6df48d7f..dbfe5ac95 100644 --- a/x/notifications/keeper/notifications.go +++ b/x/notifications/keeper/notifications.go @@ -17,6 +17,15 @@ func (k Keeper) SetNotification(ctx sdk.Context, notification types.Notification notification.From, notification.Time, ), b) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventSetNotification, + sdk.NewAttribute(types.AttributeTo, notification.To), + sdk.NewAttribute(types.AttributeFrom, notification.From), + sdk.NewAttribute(types.AttributeWhen, fmt.Sprintf("%d", notification.Time)), + ), + ) } // GetNotification returns a notification from its index @@ -55,6 +64,15 @@ func (k Keeper) RemoveNotification( from, timeStamp, )) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventRemoveNotification, + sdk.NewAttribute(types.AttributeTo, to), + sdk.NewAttribute(types.AttributeFrom, from), + sdk.NewAttribute(types.AttributeWhen, fmt.Sprintf("%d", timeStamp)), + ), + ) } // GetAllNotifications returns all notifications diff --git a/x/notifications/types/events.go b/x/notifications/types/events.go new file mode 100644 index 000000000..1c49f47d5 --- /dev/null +++ b/x/notifications/types/events.go @@ -0,0 +1,17 @@ +package types + +const ( + EventBlockSenders = "block_senders" + EventBlock = "block" + EventRemoveNotification = "notification_removed" + EventCreateNotification = "create_notification" + EventSetNotification = "set_notification" + + AttributeBlocker = "blocker" + AttributeBlockee = "blockee" + AttributeTo = "to" + AttributeFrom = "from" + AttributeWhen = "when" + + AttributeSigner = "signer" +) diff --git a/x/rns/keeper/bids.go b/x/rns/keeper/bids.go index bd1b37c0a..5fbc95aff 100644 --- a/x/rns/keeper/bids.go +++ b/x/rns/keeper/bids.go @@ -13,6 +13,14 @@ func (k Keeper) SetBids(ctx sdk.Context, bids types.Bids) { store.Set(types.BidsKey( bids.Index, ), b) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventSetBid, + sdk.NewAttribute(types.AttributeName, bids.Name), + sdk.NewAttribute(types.AttributeBidder, bids.Bidder), + ), + ) } // GetBids returns a bids from its index diff --git a/x/rns/keeper/forsale.go b/x/rns/keeper/forsale.go index fa4a379bf..0e98ea28a 100644 --- a/x/rns/keeper/forsale.go +++ b/x/rns/keeper/forsale.go @@ -13,6 +13,15 @@ func (k Keeper) SetForsale(ctx sdk.Context, forsale types.Forsale) { store.Set(types.ForsaleKey( forsale.Name, ), b) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventSetSale, + sdk.NewAttribute(types.AttributeName, forsale.Name), + sdk.NewAttribute(types.AttributeOwner, forsale.Owner), + sdk.NewAttribute(types.AttributePrice, forsale.Price), + ), + ) } // GetForsale returns a forsale from its index @@ -42,6 +51,13 @@ func (k Keeper) RemoveForsale( store.Delete(types.ForsaleKey( name, )) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventRemoveSale, + sdk.NewAttribute(types.AttributeName, name), + ), + ) } // GetAllForsale returns all forsale diff --git a/x/rns/keeper/msg_server_accept_bid.go b/x/rns/keeper/msg_server_accept_bid.go index da159ccd7..5cad7330e 100644 --- a/x/rns/keeper/msg_server_accept_bid.go +++ b/x/rns/keeper/msg_server_accept_bid.go @@ -67,6 +67,15 @@ func (k Keeper) AcceptOneBid(ctx sdk.Context, sender string, name string, bidder // Write whois information to the store k.SetNames(ctx, whois) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventAcceptBid, + sdk.NewAttribute(types.AttributeName, fmt.Sprintf("%s.%s", whois.Name, whois.Tld)), + sdk.NewAttribute(types.AttributeBidder, bid.Bidder), + sdk.NewAttribute(types.AttributeOwner, whois.Value), + ), + ) + return nil } @@ -75,5 +84,26 @@ func (k msgServer) AcceptBid(goCtx context.Context, msg *types.MsgAcceptBid) (*t err := k.AcceptOneBid(ctx, msg.Creator, msg.Name, msg.From) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeJackalMessage, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventAcceptBid, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + return &types.MsgAcceptBidResponse{}, err } diff --git a/x/rns/keeper/msg_server_add_record.go b/x/rns/keeper/msg_server_add_record.go index 8f87fde66..b26adb9aa 100644 --- a/x/rns/keeper/msg_server_add_record.go +++ b/x/rns/keeper/msg_server_add_record.go @@ -63,5 +63,28 @@ func (k msgServer) AddRecord(goCtx context.Context, msg *types.MsgAddRecord) (*t k.SetNames(ctx, whois) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventAddRecord, + sdk.NewAttribute(types.AttributeName, msg.Name), + sdk.NewAttribute(types.AttributeOwner, msg.Creator), + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeJackalMessage, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + return &types.MsgAddRecordResponse{}, nil } diff --git a/x/rns/keeper/msg_server_bid.go b/x/rns/keeper/msg_server_bid.go index d1bf4fac5..e571678d0 100644 --- a/x/rns/keeper/msg_server_bid.go +++ b/x/rns/keeper/msg_server_bid.go @@ -43,5 +43,26 @@ func (k msgServer) Bid(goCtx context.Context, msg *types.MsgBid) (*types.MsgBidR err := k.AddBid(ctx, msg.Creator, msg.Name, msg.Bid.String()) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeJackalMessage, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventSetBid, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + return &types.MsgBidResponse{}, err } diff --git a/x/rns/keeper/msg_server_buy.go b/x/rns/keeper/msg_server_buy.go index d2018730b..99af80f2c 100644 --- a/x/rns/keeper/msg_server_buy.go +++ b/x/rns/keeper/msg_server_buy.go @@ -67,6 +67,14 @@ func (k Keeper) BuyName(ctx sdk.Context, sender string, nm string) error { name.Data = "{}" k.SetNames(ctx, name) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventBuyName, + sdk.NewAttribute(types.AttributeName, nm), + sdk.NewAttribute(types.AttributeOwner, sender), + ), + ) + return nil } @@ -75,5 +83,26 @@ func (k msgServer) Buy(goCtx context.Context, msg *types.MsgBuy) (*types.MsgBuyR err := k.BuyName(ctx, msg.Creator, msg.Name) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeJackalMessage, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventBuyName, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + return &types.MsgBuyResponse{}, err } diff --git a/x/rns/keeper/msg_server_cancel_bid.go b/x/rns/keeper/msg_server_cancel_bid.go index d7e8882cb..126259e79 100644 --- a/x/rns/keeper/msg_server_cancel_bid.go +++ b/x/rns/keeper/msg_server_cancel_bid.go @@ -36,6 +36,14 @@ func (k Keeper) CancelOneBid(ctx sdk.Context, sender string, name string) error k.RemoveBids(ctx, fmt.Sprintf("%s%s", sender, name)) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventRemoveBid, + sdk.NewAttribute(types.AttributeName, name), + sdk.NewAttribute(types.AttributeOwner, sender), + ), + ) + return nil } @@ -44,5 +52,26 @@ func (k msgServer) CancelBid(goCtx context.Context, msg *types.MsgCancelBid) (*t err := k.CancelOneBid(ctx, msg.Creator, msg.Name) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeJackalMessage, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventRemoveBid, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + return &types.MsgCancelBidResponse{}, err } diff --git a/x/rns/keeper/msg_server_del_record.go b/x/rns/keeper/msg_server_del_record.go index 040316e37..dce49bf69 100644 --- a/x/rns/keeper/msg_server_del_record.go +++ b/x/rns/keeper/msg_server_del_record.go @@ -55,5 +55,34 @@ func (k msgServer) DelRecord(goCtx context.Context, msg *types.MsgDelRecord) (*t val.Subdomains = dms k.SetNames(ctx, val) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventRemoveRecord, + sdk.NewAttribute(types.AttributeName, msg.Name), + sdk.NewAttribute(types.AttributeOwner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeJackalMessage, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventRemoveRecord, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + return &types.MsgDelRecordResponse{}, nil } diff --git a/x/rns/keeper/msg_server_delist.go b/x/rns/keeper/msg_server_delist.go index 673410742..849a2f2a3 100644 --- a/x/rns/keeper/msg_server_delist.go +++ b/x/rns/keeper/msg_server_delist.go @@ -41,5 +41,26 @@ func (k msgServer) Delist(goCtx context.Context, msg *types.MsgDelist) (*types.M k.RemoveForsale(ctx, mname) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeJackalMessage, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventRemoveSale, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + return &types.MsgDelistResponse{}, nil } diff --git a/x/rns/keeper/msg_server_init.go b/x/rns/keeper/msg_server_init.go index 3a4802925..ec34dbbd0 100644 --- a/x/rns/keeper/msg_server_init.go +++ b/x/rns/keeper/msg_server_init.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" "strings" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -62,5 +63,34 @@ func (k msgServer) Init(goCtx context.Context, msg *types.MsgInit) (*types.MsgIn // Write whois information to the store k.SetNames(ctx, newWhois) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventInit, + sdk.NewAttribute(types.AttributeName, fmt.Sprintf("%s.%s", newWhois.Name, newWhois.Tld)), + sdk.NewAttribute(types.AttributeOwner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeJackalMessage, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventInit, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + return &types.MsgInitResponse{}, nil } diff --git a/x/rns/keeper/msg_server_list.go b/x/rns/keeper/msg_server_list.go index 57b858ce2..127d6a1dd 100644 --- a/x/rns/keeper/msg_server_list.go +++ b/x/rns/keeper/msg_server_list.go @@ -53,5 +53,26 @@ func (k msgServer) List(goCtx context.Context, msg *types.MsgList) (*types.MsgLi k.SetForsale(ctx, newsale) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeJackalMessage, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventSetSale, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + return &types.MsgListResponse{}, nil } diff --git a/x/rns/keeper/msg_server_register.go b/x/rns/keeper/msg_server_register.go index eecfcff24..8cbde0bdd 100644 --- a/x/rns/keeper/msg_server_register.go +++ b/x/rns/keeper/msg_server_register.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" "strings" sdk "github.com/cosmos/cosmos-sdk/types" @@ -87,6 +88,14 @@ func (k Keeper) RegisterRNSName(ctx sdk.Context, sender string, nm string, data k.SetPrimaryName(ctx, newWhois.Value, newWhois.Name, newWhois.Tld) } + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventRegister, + sdk.NewAttribute(types.AttributeName, fmt.Sprintf("%s.%s", newWhois.Name, newWhois.Tld)), + sdk.NewAttribute(types.AttributeOwner, sender), + ), + ) + return nil } @@ -119,5 +128,26 @@ func (k msgServer) RegisterName(goCtx context.Context, msg *types.MsgRegisterNam err := k.RegisterRNSName(ctx, msg.Creator, msg.Name, msg.Data, msg.Years, msg.SetPrimary) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeJackalMessage, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventRegister, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + return &types.MsgRegisterNameResponse{}, err } diff --git a/x/rns/keeper/msg_server_transfer.go b/x/rns/keeper/msg_server_transfer.go index 8df3b1b2f..121318dc8 100644 --- a/x/rns/keeper/msg_server_transfer.go +++ b/x/rns/keeper/msg_server_transfer.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" "strings" sdk "github.com/cosmos/cosmos-sdk/types" @@ -49,6 +50,16 @@ func (k Keeper) TransferName(ctx sdk.Context, creator string, receiever string, // Write whois information to the store k.SetNames(ctx, whois) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTransfer, + sdk.NewAttribute(types.AttributeName, fmt.Sprintf("%s.%s", whois.Name, whois.Tld)), + sdk.NewAttribute(types.AttributeOwner, creator), + sdk.NewAttribute(types.AttributeReceiver, receiever), + ), + ) + return nil } @@ -57,5 +68,26 @@ func (k msgServer) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*typ err := k.TransferName(ctx, msg.Creator, msg.Receiver, msg.Name) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeJackalMessage, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTransfer, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + return &types.MsgTransferResponse{}, err } diff --git a/x/rns/keeper/msg_server_update.go b/x/rns/keeper/msg_server_update.go index d4e1ff6fa..a2ee30b2d 100644 --- a/x/rns/keeper/msg_server_update.go +++ b/x/rns/keeper/msg_server_update.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" "strings" sdk "github.com/cosmos/cosmos-sdk/types" @@ -41,6 +42,14 @@ func (k Keeper) UpdateName(ctx sdk.Context, sender string, nm string, data strin // Write whois information to the store k.SetNames(ctx, whois) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventUpdate, + sdk.NewAttribute(types.AttributeName, fmt.Sprintf("%s.%s", whois.Name, whois.Tld)), + sdk.NewAttribute(types.AttributeOwner, sender), + ), + ) + return nil } @@ -50,5 +59,26 @@ func (k msgServer) Update(goCtx context.Context, msg *types.MsgUpdate) (*types.M err := k.UpdateName(ctx, msg.Creator, msg.Name, msg.Data) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeJackalMessage, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventUpdate, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + return &types.MsgUpdateResponse{}, err } diff --git a/x/rns/keeper/names.go b/x/rns/keeper/names.go index 6e005289f..ccd1634d9 100644 --- a/x/rns/keeper/names.go +++ b/x/rns/keeper/names.go @@ -16,6 +16,13 @@ func (k Keeper) SetPrimaryName(ctx sdk.Context, owner, name, tld string) { store.Set(types.PrimaryNameKey( owner, ), []byte(fmt.Sprintf("%s.%s", name, tld))) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventSetPrimaryName, + sdk.NewAttribute(types.AttributeName, fmt.Sprintf("%s.%s", name, tld)), + sdk.NewAttribute(types.AttributeValue, owner), + ), + ) } func (k Keeper) GetPrimaryName( @@ -46,6 +53,15 @@ func (k Keeper) SetNames(ctx sdk.Context, names types.Names) { names.Name, names.Tld, ), b) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventSetName, + sdk.NewAttribute(types.AttributeName, fmt.Sprintf("%s.%s", names.Name, names.Tld)), + sdk.NewAttribute(types.AttributeValue, names.Value), + sdk.NewAttribute(types.AttributeExpires, fmt.Sprintf("%d", names.Expires)), + ), + ) } // GetNames returns a names from its index @@ -82,6 +98,13 @@ func (k Keeper) RemoveNames( name, tld, )) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventRemoveName, + sdk.NewAttribute(types.AttributeName, fmt.Sprintf("%s.%s", name, tld)), + ), + ) } // GetAllNames returns all names @@ -100,9 +123,9 @@ func (k Keeper) GetAllNames(ctx sdk.Context) (list []types.Names) { return } -// quickly checks if there are any domains registered +// CheckExistence quickly checks if there are any domains registered func (k Keeper) CheckExistence(ctx sdk.Context) bool { - // intializing the iterator + // initializing the iterator store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.NamesKeyPrefix)) iterator := sdk.KVStorePrefixIterator(store, []byte{}) diff --git a/x/rns/types/events.go b/x/rns/types/events.go new file mode 100644 index 000000000..acf25b691 --- /dev/null +++ b/x/rns/types/events.go @@ -0,0 +1,33 @@ +package types + +const ( + EventSetPrimaryName = "set_primary_name" + EventSetName = "set_name" + EventRemoveName = "remove_name" + EventSetBid = "add_bid" + EventAcceptBid = "accept_bid" + EventAddRecord = "add_record" + EventBuyName = "buy_name" + EventRemoveBid = "remove_bid" + EventRemoveRecord = "remove_record" + EventRemoveSale = "remove_sale" + EventSetSale = "add_sale" + EventInit = "init_rns" + EventRegister = "register" + EventTransfer = "transfer_name" + EventUpdate = "update" + + AttributeName = "name" + AttributeOwner = "owner" + AttributeValue = "value" + AttributeExpires = "expires" + AttributeBidder = "bidder" + AttributePrice = "price" + AttributeReceiver = "receiver" + + AttributeValueCategory = ModuleName + + AttributeKeySigner = "signer" + + EventTypeJackalMessage = "jackal_message" +) diff --git a/x/storage/keeper/msg_server_file_delete.go b/x/storage/keeper/msg_server_file_delete.go index 159a602b0..b6441f51a 100644 --- a/x/storage/keeper/msg_server_file_delete.go +++ b/x/storage/keeper/msg_server_file_delete.go @@ -15,23 +15,23 @@ func (k msgServer) DeleteFile(goCtx context.Context, msg *types.MsgDeleteFile) ( ctx.EventManager().EmitEvent( sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + types.EventTypeCancelContract, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + sdk.NewAttribute(types.AttributeKeyContract, hex.EncodeToString(msg.Merkle)), ), ) ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeCancelContract, + types.EventTypeJackalMessage, sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), - sdk.NewAttribute(types.AttributeKeyContract, hex.EncodeToString(msg.Merkle)), ), ) ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeJackalMessage, - sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), ), )