Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing events for admin-related methods #1177

Closed
wants to merge 2 commits into from

Conversation

tkxkd0159
Copy link

@tkxkd0159 tkxkd0159 commented Jan 26, 2023

closes #1173

@tkxkd0159 tkxkd0159 requested a review from alpe as a code owner January 26, 2023 04:39
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov
Copy link

codecov bot commented Jan 26, 2023

Codecov Report

Merging #1177 (8a2d601) into main (0084796) will increase coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1177      +/-   ##
==========================================
+ Coverage   57.53%   57.61%   +0.07%     
==========================================
  Files          53       53              
  Lines        7289     7306      +17     
==========================================
+ Hits         4194     4209      +15     
- Misses       2800     2801       +1     
- Partials      295      296       +1     
Impacted Files Coverage Δ
x/wasm/keeper/keeper.go 87.72% <100.00%> (+0.01%) ⬆️

Copy link
Contributor

@alpe alpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your PR! 👏
I had started some work yesterday already to speed this up but wasn't ready to push. You may want to 👀 at #1179 for inspiration or you review mine and we close this.

I would ask for tests in your PR. The coverage of setAdmin was not great before. I like to improve the coverage while working in an area. This helps with regression

))
} else {
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeClearContractAdmin,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of 2 different events first but then merged them into 1 to make it easier for clients to subscribe to updates. When the admin is cleared, the new admin value would be empty.

Copy link
Author

@tkxkd0159 tkxkd0159 Jan 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your option as well. I just thought about this and I decided to distinguish those events from the view of a message as a unit of action. (if the admin is cleared, nobody can update the admin after that and only gov can do this)

types.EventTypeSetAccessConfig,
sdk.NewAttribute(types.AttributeKeyCodeID, strconv.FormatUint(codeID, 10)),
sdk.NewAttribute(types.AttributeKeyCodePermission, newConfig.Permission.String()),
sdk.NewAttribute(types.AttributeKeyAuthorizedAddresses, strings.Join(newConfig.Addresses, ", ")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newConfig.Address field is deprecated but we need to support this for some time, until fully removed.
The authorized addresses are not always set. I would prefer to set the attribute only for certain permissions where a value would be expected.

nit: the space in the join pattern makes it easier to read for humans but adds a bit more complexity for the clients. Either they find the pattern or have to trim each address.

Copy link
Author

@tkxkd0159 tkxkd0159 Jan 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The authorized addresses are not always set. I would prefer to set the attribute only for certain permissions where a value would be expected.

I think it's fine to always add addresses attributes in schema perspective. The addresses field will just be left empty(Join nil), and the client can process the event data appropriately according to the CodePermission.

@tkxkd0159
Copy link
Author

tkxkd0159 commented Jan 26, 2023

Thanks a lot for your PR! clap I had started some work yesterday already to speed this up but wasn't ready to push. You may want to eyes at #1179 for inspiration or you review mine and we close this.

Thank you for your comment @alpe and i am fine whichever option you choose. If you wanna close this PR, I will review yours if it need it or I will add tests for this PR If this PR continue.

@alpe
Copy link
Contributor

alpe commented Jan 27, 2023

I will close this PR now in favour of #1179 just to speed up the process for v0.31 since you had no strong opinion about the implementation.
I appreciate your contribution very much and I am sorry for the duplicate work. Please keep adding issues and PRs to improve the project 🌻

@alpe alpe closed this Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing events for admin-related methods
2 participants