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

feat: add p/demo/ownable #1314

Merged
merged 20 commits into from
Nov 2, 2023
Merged

feat: add p/demo/ownable #1314

merged 20 commits into from
Nov 2, 2023

Conversation

leohhhn
Copy link
Contributor

@leohhhn leohhhn commented Oct 28, 2023

Description

This PR adds the Ownable package to p/demo, allowing users to have simple ownership control in realms, at top-level, as well as per-object ownership through Golang's embedding & anonymous embedding features.

Inspired by OpenZeppelin's Ownable, with minor modifications.

Ignore commits before Oct 25th, they were added by mistake.

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • [] Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Oct 28, 2023
@codecov
Copy link

codecov bot commented Oct 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (199cd29) 47.87% compared to head (534f96b) 47.91%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1314      +/-   ##
==========================================
+ Coverage   47.87%   47.91%   +0.04%     
==========================================
  Files         372      372              
  Lines       63019    63019              
==========================================
+ Hits        30168    30196      +28     
+ Misses      30384    30362      -22     
+ Partials     2467     2461       -6     

see 7 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leohhhn leohhhn marked this pull request as ready for review October 29, 2023 00:00
@leohhhn leohhhn requested a review from a team as a code owner October 29, 2023 00:00
examples/gno.land/p/demo/ownable/ownable_test.gno Outdated Show resolved Hide resolved
examples/gno.land/p/demo/ownable/ownable.gno Outdated Show resolved Hide resolved
examples/gno.land/p/demo/ownable/ownable.gno Outdated Show resolved Hide resolved
examples/gno.land/p/demo/ownable/ownable_test.gno Outdated Show resolved Hide resolved
Copy link
Member

@gfanton gfanton left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@ajnavarro ajnavarro left a comment

Choose a reason for hiding this comment

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

Looks mostly good for me, just a small nit about Getters and Setters conventions in Go.

The only thing that bothers me is that the Ownable logic is not thread-safe (you can have race conditions modifying the owner variable, causing problems), maybe is not a problem on Gno.

examples/gno.land/p/demo/ownable/ownable.gno Outdated Show resolved Hide resolved
Copy link
Contributor

@harry-hov harry-hov left a comment

Choose a reason for hiding this comment

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

Left some minor suggestions. Rest LGTM 💯

examples/gno.land/p/demo/ownable/ownable.gno Outdated Show resolved Hide resolved
examples/gno.land/p/demo/ownable/ownable_test.gno Outdated Show resolved Hide resolved
examples/gno.land/p/demo/ownable/ownable_test.gno Outdated Show resolved Hide resolved
@gfanton gfanton merged commit 0076e48 into gnolang:master Nov 2, 2023
182 checks passed
@leohhhn leohhhn mentioned this pull request Nov 2, 2023
7 tasks
gfanton pushed a commit to gfanton/gno that referenced this pull request Nov 9, 2023
thehowl added a commit that referenced this pull request Nov 9, 2023
## Description


This PR adds the `Pausable` package to p/demo, allowing realms to have
pausability. It relies on the already existing `Ownable` package for
access control, #1314.

Inspired by OpenZeppelin's
[Pausable](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.3/contracts/security/Pausable.sol).

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

---------

Co-authored-by: Morgan Bazalgette <morgan@morganbaz.com>
moul pushed a commit to moul/gno that referenced this pull request Nov 14, 2023
moul pushed a commit to moul/gno that referenced this pull request Nov 14, 2023
## Description


This PR adds the `Pausable` package to p/demo, allowing realms to have
pausability. It relies on the already existing `Ownable` package for
access control, gnolang#1314.

Inspired by OpenZeppelin's
[Pausable](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.3/contracts/security/Pausable.sol).

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

---------

Co-authored-by: Morgan Bazalgette <morgan@morganbaz.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants