Skip to content

Commit

Permalink
moving storage events
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell committed Sep 4, 2024
1 parent 59be453 commit 3109fce
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions x/storage/keeper/msg_server_post_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 52 in x/storage/keeper/msg_server_post_file.go

View check run for this annotation

Codecov / codecov/patch

x/storage/keeper/msg_server_post_file.go#L52

Added line #L52 was not covered by tests
}

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
Expand Down Expand Up @@ -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
}

0 comments on commit 3109fce

Please sign in to comment.