From 3109fce37bd03b81ced8e4865c4c00906338f79f Mon Sep 17 00:00:00 2001 From: marston Date: Tue, 3 Sep 2024 23:39:55 -0400 Subject: [PATCH 1/2] moving storage events --- x/storage/keeper/msg_server_post_file.go | 56 ++++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/x/storage/keeper/msg_server_post_file.go b/x/storage/keeper/msg_server_post_file.go index 09619637..d57f6273 100644 --- a/x/storage/keeper/msg_server_post_file.go +++ b/x/storage/keeper/msg_server_post_file.go @@ -40,6 +40,34 @@ func (k msgServer) PostFile(goCtx context.Context, msg *types.MsgPostFile) (*typ res := &types.MsgPostFileResponse{ProviderIps: ips, StartBlock: ctx.BlockHeight()} + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + b := False // pay once event + if msg.Expires > 0 { + b = True + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeSignContract, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + sdk.NewAttribute(types.AttributeKeyContract, hex.EncodeToString(msg.Merkle)), + sdk.NewAttribute(types.AttributeKeyPayOnce, b), + ), + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeJackalMessage, + sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), + ), + ) + totalSize := msg.FileSize * msg.MaxProofs if msg.Expires > 0 { // if the file is posted as a one-time payment kbs := totalSize / 1000 @@ -112,33 +140,5 @@ func (k msgServer) PostFile(goCtx context.Context, msg *types.MsgPostFile) (*typ k.SetStoragePaymentInfo(ctx, paymentInfo) - ctx.EventManager().EmitEvent( - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - ) - - b := False // pay once event - if msg.Expires > 0 { - b = True - } - - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeSignContract, - sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), - sdk.NewAttribute(types.AttributeKeyContract, hex.EncodeToString(msg.Merkle)), - sdk.NewAttribute(types.AttributeKeyPayOnce, b), - ), - ) - - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeJackalMessage, - sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), - ), - ) - return res, nil } From 573edbc0fcad38c29b5a1003d1a1b931d17e05b6 Mon Sep 17 00:00:00 2001 From: marston Date: Tue, 3 Sep 2024 23:59:54 -0400 Subject: [PATCH 2/2] adding start event --- x/storage/keeper/msg_server_post_file.go | 1 + x/storage/types/events.go | 1 + 2 files changed, 2 insertions(+) diff --git a/x/storage/keeper/msg_server_post_file.go b/x/storage/keeper/msg_server_post_file.go index d57f6273..934b4070 100644 --- a/x/storage/keeper/msg_server_post_file.go +++ b/x/storage/keeper/msg_server_post_file.go @@ -58,6 +58,7 @@ func (k msgServer) PostFile(goCtx context.Context, msg *types.MsgPostFile) (*typ sdk.NewAttribute(types.AttributeKeySigner, msg.Creator), sdk.NewAttribute(types.AttributeKeyContract, hex.EncodeToString(msg.Merkle)), sdk.NewAttribute(types.AttributeKeyPayOnce, b), + sdk.NewAttribute(types.AttributeKeyStart, fmt.Sprintf("%d", ctx.BlockHeight())), ), ) diff --git a/x/storage/types/events.go b/x/storage/types/events.go index 930b0fd2..0cd1e69f 100644 --- a/x/storage/types/events.go +++ b/x/storage/types/events.go @@ -16,6 +16,7 @@ const ( AttributeKeySigner = "signer" // sign storage deal AttributeKeyContract = "file" AttributeKeyPayOnce = "pay_once" + AttributeKeyStart = "start" EventTypeJackalMessage = "jackal_message" )