From 7982c3fe47bad36d45b9de582597b44f19e5ad00 Mon Sep 17 00:00:00 2001 From: marston Date: Wed, 2 Oct 2024 21:42:28 -0400 Subject: [PATCH 1/3] rns events --- x/rns/keeper/bids.go | 8 ++++++ x/rns/keeper/forsale.go | 16 +++++++++++ x/rns/keeper/msg_server_accept_bid.go | 23 +++++++++++++++ x/rns/keeper/msg_server_add_record.go | 22 +++++++++++++++ x/rns/keeper/msg_server_bid.go | 14 +++++++++ x/rns/keeper/msg_server_buy.go | 22 +++++++++++++++ x/rns/keeper/msg_server_cancel_bid.go | 22 +++++++++++++++ x/rns/keeper/msg_server_del_record.go | 22 +++++++++++++++ x/rns/keeper/msg_server_delist.go | 14 +++++++++ x/rns/keeper/msg_server_init.go | 23 +++++++++++++++ x/rns/keeper/msg_server_list.go | 14 +++++++++ x/rns/keeper/msg_server_register.go | 23 +++++++++++++++ x/rns/keeper/msg_server_transfer.go | 25 ++++++++++++++++ x/rns/keeper/msg_server_update.go | 23 +++++++++++++++ x/rns/keeper/names.go | 27 ++++++++++++++++-- x/rns/types/events.go | 33 ++++++++++++++++++++++ x/storage/keeper/msg_server_file_delete.go | 12 ++++---- 17 files changed, 335 insertions(+), 8 deletions(-) create mode 100644 x/rns/types/events.go diff --git a/x/rns/keeper/bids.go b/x/rns/keeper/bids.go index bd1b37c0..5fbc95af 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 fa4a379b..0e98ea28 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 da159ccd..1ba6df7c 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,19 @@ 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), + ), + ) + 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 8f87fde6..8c75dd31 100644 --- a/x/rns/keeper/msg_server_add_record.go +++ b/x/rns/keeper/msg_server_add_record.go @@ -63,5 +63,27 @@ 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), + ), + ) + + 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 d1bf4fac..8d6bf551 100644 --- a/x/rns/keeper/msg_server_bid.go +++ b/x/rns/keeper/msg_server_bid.go @@ -43,5 +43,19 @@ 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), + ), + ) + return &types.MsgBidResponse{}, err } diff --git a/x/rns/keeper/msg_server_buy.go b/x/rns/keeper/msg_server_buy.go index d2018730..d95494e3 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,19 @@ 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), + ), + ) + 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 d7e8882c..16d72a5c 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,19 @@ 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), + ), + ) + 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 040316e3..6edf0c6d 100644 --- a/x/rns/keeper/msg_server_del_record.go +++ b/x/rns/keeper/msg_server_del_record.go @@ -55,5 +55,27 @@ 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), + ), + ) + return &types.MsgDelRecordResponse{}, nil } diff --git a/x/rns/keeper/msg_server_delist.go b/x/rns/keeper/msg_server_delist.go index 67341074..78a636ea 100644 --- a/x/rns/keeper/msg_server_delist.go +++ b/x/rns/keeper/msg_server_delist.go @@ -41,5 +41,19 @@ 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), + ), + ) + return &types.MsgDelistResponse{}, nil } diff --git a/x/rns/keeper/msg_server_init.go b/x/rns/keeper/msg_server_init.go index 3a480292..77b7de38 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,27 @@ 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), + ), + ) + return &types.MsgInitResponse{}, nil } diff --git a/x/rns/keeper/msg_server_list.go b/x/rns/keeper/msg_server_list.go index 57b858ce..3f58d774 100644 --- a/x/rns/keeper/msg_server_list.go +++ b/x/rns/keeper/msg_server_list.go @@ -53,5 +53,19 @@ 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), + ), + ) + return &types.MsgListResponse{}, nil } diff --git a/x/rns/keeper/msg_server_register.go b/x/rns/keeper/msg_server_register.go index eecfcff2..73f6cb30 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,19 @@ 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), + ), + ) + return &types.MsgRegisterNameResponse{}, err } diff --git a/x/rns/keeper/msg_server_transfer.go b/x/rns/keeper/msg_server_transfer.go index 8df3b1b2..b165cc73 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,19 @@ 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), + ), + ) + return &types.MsgTransferResponse{}, err } diff --git a/x/rns/keeper/msg_server_update.go b/x/rns/keeper/msg_server_update.go index d4e1ff6f..dbb564b8 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,19 @@ 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), + ), + ) + return &types.MsgUpdateResponse{}, err } diff --git a/x/rns/keeper/names.go b/x/rns/keeper/names.go index 6e005289..ccd1634d 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 00000000..d0cc431e --- /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" // sign storage deal + + EventTypeJackalMessage = "jackal_message" +) diff --git a/x/storage/keeper/msg_server_file_delete.go b/x/storage/keeper/msg_server_file_delete.go index 159a602b..b6441f51 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), ), ) From 19c24718c3e4e5411b3c804f3521a303acfed848 Mon Sep 17 00:00:00 2001 From: marston Date: Wed, 2 Oct 2024 22:00:12 -0400 Subject: [PATCH 2/3] adding signer & notifications module --- x/notifications/keeper/blocks.go | 8 ++++++++ .../keeper/msg_server_block_senders.go | 8 +++++++- .../keeper/msg_server_create_notifications.go | 7 +++++++ .../keeper/msg_server_delete_notifications.go | 7 +++++++ x/notifications/keeper/notifications.go | 18 ++++++++++++++++++ x/notifications/types/events.go | 17 +++++++++++++++++ x/rns/keeper/msg_server_accept_bid.go | 7 +++++++ x/rns/keeper/msg_server_add_record.go | 1 + x/rns/keeper/msg_server_bid.go | 7 +++++++ x/rns/keeper/msg_server_buy.go | 7 +++++++ x/rns/keeper/msg_server_cancel_bid.go | 7 +++++++ x/rns/keeper/msg_server_del_record.go | 7 +++++++ x/rns/keeper/msg_server_delist.go | 7 +++++++ x/rns/keeper/msg_server_init.go | 7 +++++++ x/rns/keeper/msg_server_list.go | 7 +++++++ x/rns/keeper/msg_server_register.go | 7 +++++++ x/rns/keeper/msg_server_transfer.go | 7 +++++++ x/rns/keeper/msg_server_update.go | 7 +++++++ x/rns/types/events.go | 2 +- 19 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 x/notifications/types/events.go diff --git a/x/notifications/keeper/blocks.go b/x/notifications/keeper/blocks.go index 4613c873..4694b349 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 e4f416b4..03525eea 100644 --- a/x/notifications/keeper/msg_server_block_senders.go +++ b/x/notifications/keeper/msg_server_block_senders.go @@ -2,7 +2,6 @@ package keeper import ( "context" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/jackalLabs/canine-chain/v4/x/notifications/types" @@ -27,5 +26,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 b8335da1..01b3ae5f 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 efcac09b..03681447 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 c6df48d7..dbfe5ac9 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 00000000..1c49f47d --- /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/msg_server_accept_bid.go b/x/rns/keeper/msg_server_accept_bid.go index 1ba6df7c..5cad7330 100644 --- a/x/rns/keeper/msg_server_accept_bid.go +++ b/x/rns/keeper/msg_server_accept_bid.go @@ -98,5 +98,12 @@ func (k msgServer) AcceptBid(goCtx context.Context, msg *types.MsgAcceptBid) (*t ), ) + 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 8c75dd31..b26adb9a 100644 --- a/x/rns/keeper/msg_server_add_record.go +++ b/x/rns/keeper/msg_server_add_record.go @@ -68,6 +68,7 @@ func (k msgServer) AddRecord(goCtx context.Context, msg *types.MsgAddRecord) (*t types.EventAddRecord, sdk.NewAttribute(types.AttributeName, msg.Name), sdk.NewAttribute(types.AttributeOwner, msg.Creator), + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), ), ) diff --git a/x/rns/keeper/msg_server_bid.go b/x/rns/keeper/msg_server_bid.go index 8d6bf551..e571678d 100644 --- a/x/rns/keeper/msg_server_bid.go +++ b/x/rns/keeper/msg_server_bid.go @@ -57,5 +57,12 @@ func (k msgServer) Bid(goCtx context.Context, msg *types.MsgBid) (*types.MsgBidR ), ) + 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 d95494e3..99af80f2 100644 --- a/x/rns/keeper/msg_server_buy.go +++ b/x/rns/keeper/msg_server_buy.go @@ -97,5 +97,12 @@ func (k msgServer) Buy(goCtx context.Context, msg *types.MsgBuy) (*types.MsgBuyR ), ) + 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 16d72a5c..126259e7 100644 --- a/x/rns/keeper/msg_server_cancel_bid.go +++ b/x/rns/keeper/msg_server_cancel_bid.go @@ -66,5 +66,12 @@ func (k msgServer) CancelBid(goCtx context.Context, msg *types.MsgCancelBid) (*t ), ) + 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 6edf0c6d..dce49bf6 100644 --- a/x/rns/keeper/msg_server_del_record.go +++ b/x/rns/keeper/msg_server_del_record.go @@ -77,5 +77,12 @@ func (k msgServer) DelRecord(goCtx context.Context, msg *types.MsgDelRecord) (*t ), ) + 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 78a636ea..849a2f2a 100644 --- a/x/rns/keeper/msg_server_delist.go +++ b/x/rns/keeper/msg_server_delist.go @@ -55,5 +55,12 @@ func (k msgServer) Delist(goCtx context.Context, msg *types.MsgDelist) (*types.M ), ) + 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 77b7de38..ec34dbbd 100644 --- a/x/rns/keeper/msg_server_init.go +++ b/x/rns/keeper/msg_server_init.go @@ -85,5 +85,12 @@ func (k msgServer) Init(goCtx context.Context, msg *types.MsgInit) (*types.MsgIn ), ) + 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 3f58d774..127d6a1d 100644 --- a/x/rns/keeper/msg_server_list.go +++ b/x/rns/keeper/msg_server_list.go @@ -67,5 +67,12 @@ func (k msgServer) List(goCtx context.Context, msg *types.MsgList) (*types.MsgLi ), ) + 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 73f6cb30..8cbde0bd 100644 --- a/x/rns/keeper/msg_server_register.go +++ b/x/rns/keeper/msg_server_register.go @@ -142,5 +142,12 @@ func (k msgServer) RegisterName(goCtx context.Context, msg *types.MsgRegisterNam ), ) + 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 b165cc73..121318dc 100644 --- a/x/rns/keeper/msg_server_transfer.go +++ b/x/rns/keeper/msg_server_transfer.go @@ -82,5 +82,12 @@ func (k msgServer) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*typ ), ) + 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 dbb564b8..a2ee30b2 100644 --- a/x/rns/keeper/msg_server_update.go +++ b/x/rns/keeper/msg_server_update.go @@ -73,5 +73,12 @@ func (k msgServer) Update(goCtx context.Context, msg *types.MsgUpdate) (*types.M ), ) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventUpdate, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + return &types.MsgUpdateResponse{}, err } diff --git a/x/rns/types/events.go b/x/rns/types/events.go index d0cc431e..acf25b69 100644 --- a/x/rns/types/events.go +++ b/x/rns/types/events.go @@ -27,7 +27,7 @@ const ( AttributeValueCategory = ModuleName - AttributeKeySigner = "signer" // sign storage deal + AttributeKeySigner = "signer" EventTypeJackalMessage = "jackal_message" ) From 8764b09244a4c4d90fb157f1f389017434633107 Mon Sep 17 00:00:00 2001 From: marston Date: Wed, 2 Oct 2024 22:00:24 -0400 Subject: [PATCH 3/3] lint --- x/notifications/keeper/msg_server_block_senders.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/notifications/keeper/msg_server_block_senders.go b/x/notifications/keeper/msg_server_block_senders.go index 03525eea..944261c6 100644 --- a/x/notifications/keeper/msg_server_block_senders.go +++ b/x/notifications/keeper/msg_server_block_senders.go @@ -2,6 +2,7 @@ package keeper import ( "context" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/jackalLabs/canine-chain/v4/x/notifications/types"