diff --git a/x/plans/README.md b/x/plans/README.md index 80751bae34..961e6dde89 100644 --- a/x/plans/README.md +++ b/x/plans/README.md @@ -22,6 +22,7 @@ This document focuses on the plans' technical aspects and does not include curre * [Queries](#queries) * [Transactions](#transactions) * [Proposals](#proposals) +* [Events](#events) ## Concepts @@ -249,3 +250,12 @@ A valid `plans-del` JSON proposal format: } ``` +## Events + +The plans module has the following events: + +| Event | When it happens | +| ---------- | --------------- | +| `add_new_plan_to_storage` | a successful addition of a plan | +| `del_plan_from_storage` | a successful deletion of a plan | + diff --git a/x/plans/proposal_handler.go b/x/plans/proposal_handler.go index 8b8c9b5658..13ee49d075 100644 --- a/x/plans/proposal_handler.go +++ b/x/plans/proposal_handler.go @@ -39,7 +39,7 @@ func handlePlansAddProposal(ctx sdk.Context, k keeper.Keeper, p *types.PlansAddP } details := map[string]string{"planDetails": planElem.String()} - utils.LogLavaEvent(ctx, logger, "add_new_plan_to_storage", details, "Gov Proposal Accepted Plans") + utils.LogLavaEvent(ctx, logger, types.PlanAddEventName, details, "Gov Proposal Accepted Plans") } return nil } @@ -56,7 +56,7 @@ func handlePlansDelProposal(ctx sdk.Context, k keeper.Keeper, p *types.PlansDelP } details := map[string]string{"index": index} - utils.LogLavaEvent(ctx, logger, "del_plan_from_storage", details, "Gov Proposal Accepted Plans") + utils.LogLavaEvent(ctx, logger, types.PlanDelEventName, details, "Gov Proposal Accepted Plans") } return nil } diff --git a/x/plans/types/types.go b/x/plans/types/types.go index 7ce14cd374..5dc7dd3b36 100644 --- a/x/plans/types/types.go +++ b/x/plans/types/types.go @@ -5,3 +5,8 @@ const ( MAX_LEN_PLAN_DESCRIPTION = 500 MAX_LEN_PLAN_TYPE = 20 ) + +const ( + PlanAddEventName = "add_new_plan_to_storage" + PlanDelEventName = "del_plan_from_storage" +) diff --git a/x/projects/README.md b/x/projects/README.md index 0888e028d9..58fe6de472 100644 --- a/x/projects/README.md +++ b/x/projects/README.md @@ -20,6 +20,7 @@ Note that the plans module is closely connected to the subscription and projects * [Project Policy YAML](#project-policy-yaml) * [Project Keys YAML](#project-keys-yaml) * [Proposals](#proposals) +* [Events](#events) ## Concepts @@ -205,3 +206,14 @@ All fields are mandatory. ## Proposals The projects module does not support any proposals. + +## Events + +The projects module has the following events: + +| Event | When it happens | +| ---------- | --------------- | +| `add_key_to_project_event` | a successful addition of a project key | +| `del_key_from_project_event` | a successful deletion of a project key | +| `set_admin_policy_event` | a successful set of project's admin policy | +| `set_subscription_policy_event` | a successful set of project's subscription policy | \ No newline at end of file diff --git a/x/projects/keeper/project.go b/x/projects/keeper/project.go index 88a33c8e60..0f74d5ee94 100644 --- a/x/projects/keeper/project.go +++ b/x/projects/keeper/project.go @@ -278,6 +278,7 @@ func (k Keeper) SetProjectPolicy(ctx sdk.Context, projectIDs []string, policy *p ) } + projectIDsStr := "" for _, projectID := range projectIDs { projectNextEpoch, _, err := k.getProjectForBlock(ctx, projectID, nextEpoch) if err != nil { @@ -326,6 +327,20 @@ func (k Keeper) SetProjectPolicy(ctx sdk.Context, projectIDs []string, policy *p utils.Attribute{Key: "block", Value: ctxBlock}, ) } + + projectIDsStr += projectID + ", " + } + + details := map[string]string{ + "creator": key, + "project_ids": projectIDsStr, + "policy": policy.String(), + } + + if setPolicyEnum == types.SET_ADMIN_POLICY { + utils.LogLavaEvent(ctx, k.Logger(ctx), types.SetAdminPolicyEventName, details, "set admin policy successfully") + } else if setPolicyEnum == types.SET_SUBSCRIPTION_POLICY { + utils.LogLavaEvent(ctx, k.Logger(ctx), types.SetSubscriptionPolicyEventName, details, "set admin policy successfully") } return nil diff --git a/x/projects/types/types.go b/x/projects/types/types.go index 05c76964d3..45fa0a1573 100644 --- a/x/projects/types/types.go +++ b/x/projects/types/types.go @@ -13,6 +13,8 @@ const ( ) const ( - AddProjectKeyEventName = "add_key_to_project_event" - DelProjectKeyEventName = "del_key_from_project_event" + AddProjectKeyEventName = "add_key_to_project_event" + DelProjectKeyEventName = "del_key_from_project_event" + SetAdminPolicyEventName = "set_admin_policy_event" + SetSubscriptionPolicyEventName = "set_subscription_policy_event" )