Skip to content

Commit

Permalink
Adding Common Events (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell authored May 15, 2024
2 parents abb1488 + 155dfcb commit 3b33be7
Show file tree
Hide file tree
Showing 24 changed files with 193 additions and 1 deletion.
7 changes: 7 additions & 0 deletions x/filetree/keeper/msg_server_add_editors.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,12 @@ func (k msgServer) AddEditors(goCtx context.Context, msg *types.MsgAddEditors) (
sdk.NewAttribute(types.AttributeKeyFileAddress, msg.Address),
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)
return &types.MsgAddEditorsResponse{}, nil
}
7 changes: 7 additions & 0 deletions x/filetree/keeper/msg_server_add_viewers.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,12 @@ func (k msgServer) AddViewers(goCtx context.Context, msg *types.MsgAddViewers) (
sdk.NewAttribute(types.AttributeKeyFileAddress, msg.Address),
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)
return &types.MsgAddViewersResponse{}, nil
}
7 changes: 7 additions & 0 deletions x/filetree/keeper/msg_server_change_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,12 @@ func (k msgServer) ChangeOwner(goCtx context.Context, msg *types.MsgChangeOwner)
sdk.NewAttribute(types.AttributeKeyFileAddress, msg.Address),
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)
return &types.MsgChangeOwnerResponse{}, nil
}
7 changes: 7 additions & 0 deletions x/filetree/keeper/msg_server_delete_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,12 @@ func (k msgServer) DeleteFile(goCtx context.Context, msg *types.MsgDeleteFile) (
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)
return &types.MsgDeleteFileResponse{}, nil
}
9 changes: 8 additions & 1 deletion x/filetree/keeper/msg_server_make_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/jackalLabs/canine-chain/v3/x/filetree/types"
)

func (k msgServer) MakeRootFolder(ctx sdk.Context, creator string, viewers string, editors string, trackingNumber string) {
func (k Keeper) MakeRootFolder(ctx sdk.Context, creator string, viewers string, editors string, trackingNumber string) {
merklePath := types.MerklePath("s")

h1 := sha256.New() // making full address
Expand Down Expand Up @@ -49,5 +49,12 @@ func (k msgServer) ProvisionFileTree(goCtx context.Context, msg *types.MsgProvis
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)
return &types.MsgProvisionFileTreeResponse{}, nil
}
7 changes: 7 additions & 0 deletions x/filetree/keeper/msg_server_post_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,12 @@ func (k msgServer) PostFile(goCtx context.Context, msg *types.MsgPostFile) (*typ
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgPostFileResponse{Path: fullMerklePath}, nil
}
7 changes: 7 additions & 0 deletions x/filetree/keeper/msg_server_postkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,12 @@ func (k msgServer) PostKey(goCtx context.Context, msg *types.MsgPostKey) (*types
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgPostKeyResponse{}, nil
}
7 changes: 7 additions & 0 deletions x/filetree/keeper/msg_server_remove_editors.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,12 @@ func (k msgServer) RemoveEditors(goCtx context.Context, msg *types.MsgRemoveEdit
sdk.NewAttribute(types.AttributeKeyFileAddress, msg.Address),
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)
return &types.MsgRemoveEditorsResponse{}, nil
}
7 changes: 7 additions & 0 deletions x/filetree/keeper/msg_server_remove_viewers.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,12 @@ func (k msgServer) RemoveViewers(goCtx context.Context, msg *types.MsgRemoveView
sdk.NewAttribute(types.AttributeKeyFileAddress, msg.Address),
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)
return &types.MsgRemoveViewersResponse{}, nil
}
7 changes: 7 additions & 0 deletions x/filetree/keeper/msg_server_reset_editors.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,12 @@ func (k msgServer) ResetEditors(goCtx context.Context, msg *types.MsgResetEditor
sdk.NewAttribute(types.AttributeKeyFileAddress, msg.Address),
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)
return &types.MsgResetEditorsResponse{}, nil
}
7 changes: 7 additions & 0 deletions x/filetree/keeper/msg_server_reset_viewers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,12 @@ func (k msgServer) ResetViewers(goCtx context.Context, msg *types.MsgResetViewer
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgResetViewersResponse{}, nil
}
2 changes: 2 additions & 0 deletions x/filetree/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ const (
AttributeKeySigner = "signer"
AttributeKeyNewOwner = "new_owner"
AttributeKeyKey = "key"

EventTypeJackalMessage = "jackal_message"
)
14 changes: 14 additions & 0 deletions x/storage/keeper/msg_server_attest.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ func (k msgServer) Attest(goCtx context.Context, msg *types.MsgAttest) (*types.M
ctx.Logger().Debug(err.Error())
}

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgAttestResponse{}, nil
}

Expand Down Expand Up @@ -171,6 +178,13 @@ func (k msgServer) RequestAttestationForm(goCtx context.Context, msg *types.MsgR
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgRequestAttestationFormResponse{
Providers: providerAddresses,
Success: success,
Expand Down
7 changes: 7 additions & 0 deletions x/storage/keeper/msg_server_buy_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ func (k msgServer) BuyStorage(goCtx context.Context, msg *types.MsgBuyStorage) (
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgBuyStorageResponse{}, nil
}

Expand Down
7 changes: 7 additions & 0 deletions x/storage/keeper/msg_server_file_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,12 @@ func (k msgServer) DeleteFile(goCtx context.Context, msg *types.MsgDeleteFile) (
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgDeleteFileResponse{}, nil
}
16 changes: 16 additions & 0 deletions x/storage/keeper/msg_server_init_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"fmt"

types2 "github.com/jackalLabs/canine-chain/v3/x/filetree/types"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/jackalLabs/canine-chain/v3/x/storage/types"
Expand Down Expand Up @@ -50,6 +52,13 @@ func (k msgServer) InitProvider(goCtx context.Context, msg *types.MsgInitProvide

k.SetProviders(ctx, provider)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types2.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgInitProviderResponse{}, nil
}

Expand Down Expand Up @@ -88,5 +97,12 @@ func (k msgServer) ShutdownProvider(goCtx context.Context, msg *types.MsgShutdow
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgShutdownProviderResponse{}, nil
}
7 changes: 7 additions & 0 deletions x/storage/keeper/msg_server_post_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,12 @@ func (k msgServer) PostFile(goCtx context.Context, msg *types.MsgPostFile) (*typ
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return res, nil
}
7 changes: 7 additions & 0 deletions x/storage/keeper/msg_server_postproof.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,12 @@ func (k msgServer) PostProof(goCtx context.Context, msg *types.MsgPostProof) (*t
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgPostProofResponse{Success: true, ErrorMessage: ""}, nil
}
16 changes: 16 additions & 0 deletions x/storage/keeper/msg_server_provider_claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package keeper
import (
"context"

types2 "github.com/jackalLabs/canine-chain/v3/x/filetree/types"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/jackalLabs/canine-chain/v3/x/storage/types"
Expand Down Expand Up @@ -38,6 +40,13 @@ func (k msgServer) AddProviderClaimer(goCtx context.Context, msg *types.MsgAddCl
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types2.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgAddClaimerResponse{}, nil
}

Expand Down Expand Up @@ -77,5 +86,12 @@ func (k msgServer) RemoveProviderClaimer(goCtx context.Context, msg *types.MsgRe
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgRemoveClaimerResponse{}, nil
}
16 changes: 16 additions & 0 deletions x/storage/keeper/msg_server_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package keeper
import (
"context"

types2 "github.com/jackalLabs/canine-chain/v3/x/filetree/types"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/jackalLabs/canine-chain/v3/x/storage/types"
Expand Down Expand Up @@ -67,6 +69,13 @@ func (k msgServer) Report(goCtx context.Context, msg *types.MsgReport) (*types.M
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types2.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgReportResponse{}, nil
}

Expand Down Expand Up @@ -147,6 +156,13 @@ func (k msgServer) RequestReportForm(goCtx context.Context, msg *types.MsgReques
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgRequestReportFormResponse{
Providers: providerAddresses,
Success: success,
Expand Down
7 changes: 7 additions & 0 deletions x/storage/keeper/msg_server_set_provider_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,12 @@ func (k msgServer) SetProviderIP(goCtx context.Context, msg *types.MsgSetProvide
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)
return &types.MsgSetProviderIPResponse{}, nil
}
7 changes: 7 additions & 0 deletions x/storage/keeper/msg_server_set_provider_keybase.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,12 @@ func (k msgServer) SetProviderKeybase(goCtx context.Context, msg *types.MsgSetPr
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgSetProviderKeybaseResponse{}, nil
}
7 changes: 7 additions & 0 deletions x/storage/keeper/msg_server_set_provider_totalspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,12 @@ func (k msgServer) SetProviderTotalSpace(goCtx context.Context, msg *types.MsgSe
),
)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeJackalMessage,
sdk.NewAttribute(types.AttributeKeySigner, msg.Creator),
),
)

return &types.MsgSetProviderTotalSpaceResponse{}, nil
}
2 changes: 2 additions & 0 deletions x/storage/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ const (
AttributeKeySigner = "signer" // sign storage deal
AttributeKeyContract = "file"
AttributeKeyPayOnce = "pay_once"

EventTypeJackalMessage = "jackal_message"
)

0 comments on commit 3b33be7

Please sign in to comment.