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: Ownable2Step #352

Merged
merged 19 commits into from
Nov 15, 2024
Merged

feat: Ownable2Step #352

merged 19 commits into from
Nov 15, 2024

Conversation

ggonzalez94
Copy link
Collaborator

@ggonzalez94 ggonzalez94 commented Oct 16, 2024

Resolves #290

  • Introduce a new Ownable2Step contract
  • Make onlyOwner() internal in Ownable and implement MethodError to be able to use the error in our new contract(we've already seen we will need this for others)
  • Propose we use nextest instead of vainilla cargo test in the CI. It is faster(not as relevant right now) and the output is so much nicer

PR Checklist

  • Unit Tests
  • e2e Tests
  • Documentation

Copy link

netlify bot commented Oct 16, 2024

Deploy Preview for contracts-stylus canceled.

Name Link
🔨 Latest commit 3405f76
🔍 Latest deploy log https://app.netlify.com/sites/contracts-stylus/deploys/67368dcbbcce1100080acd26

@ggonzalez94 ggonzalez94 marked this pull request as draft October 16, 2024 21:18
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 72.54902% with 28 lines in your changes missing coverage. Please review.

Project coverage is 65.3%. Comparing base (0815bdd) to head (3405f76).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
contracts/src/access/ownable_two_step.rs 72.3% 21 Missing ⚠️
contracts/src/access/ownable.rs 73.0% 7 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
contracts/src/access/ownable.rs 58.2% <73.0%> (-4.8%) ⬇️
contracts/src/access/ownable_two_step.rs 72.3% <72.3%> (ø)

@ggonzalez94 ggonzalez94 marked this pull request as ready for review November 7, 2024 08:33
@ggonzalez94 ggonzalez94 changed the title [Draft] Ownable 2 step [feat: Ownable2Step Nov 7, 2024
@ggonzalez94 ggonzalez94 changed the title [feat: Ownable2Step feat: Ownable2Step Nov 7, 2024
Comment on lines 115 to 124
/// Leaves the contract without owner. It will not be possible to call
/// [`Self::only_owner`] functions. Can only be called by the current owner.
///
/// NOTE: Renouncing ownership will leave the contract without an owner,
/// thereby disabling any functionality that is only available to the owner.
///
/// # Errors
///
/// If not called by the owner, then the error
/// [`OwnableError::UnauthorizedAccount`]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is copied from Ownable. Is there a way to reference to that documentation as we do in solidiy? e.g. here

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this could help #302 (comment)

to: Address,
value: U256,
) -> Result<(), Vec<u8>> {
self.ownable._ownable.only_owner()?;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I decided to not add again only_owner as a function of the Ownable2Step contract, since anyone inheriting from it can still access it and we are not making it public anymore. I do understand that this way of accessing is not the most ergonomic, but I still think it is better than just re-implementing it. But open to suggestions of course :)

Copy link
Collaborator

@bidzyyys bidzyyys left a comment

Choose a reason for hiding this comment

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

Missing update in CHANGELOG.md

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ggonzalez94 we should have consistent formatting in our *.yml files. You can change it everywhere or revert this change in this file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It got automatically formatted, what plugin or extension are you using so that I can use the same for md? :)

examples/ownable-two-step/Cargo.toml Outdated Show resolved Hide resolved
contracts/src/access/ownable_two_step.rs Show resolved Hide resolved
contracts/src/access/ownable_two_step.rs Outdated Show resolved Hide resolved
contracts/src/access/ownable_two_step.rs Show resolved Hide resolved
contracts/src/access/ownable_two_step.rs Outdated Show resolved Hide resolved
contracts/src/access/ownable_two_step.rs Outdated Show resolved Hide resolved
contracts/src/access/ownable_two_step.rs Outdated Show resolved Hide resolved
contracts/src/access/ownable_two_step.rs Show resolved Hide resolved
contracts/src/access/ownable_two_step.rs Outdated Show resolved Hide resolved
@bidzyyys bidzyyys self-requested a review November 8, 2024 15:21
Copy link
Collaborator

@bidzyyys bidzyyys left a comment

Choose a reason for hiding this comment

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

LGTM

@bidzyyys bidzyyys self-requested a review November 14, 2024 23:55
Copy link
Collaborator

@bidzyyys bidzyyys left a comment

Choose a reason for hiding this comment

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

LGTM

@bidzyyys bidzyyys assigned bidzyyys and unassigned bidzyyys Nov 15, 2024
@bidzyyys bidzyyys merged commit 27514ba into main Nov 15, 2024
24 checks passed
@bidzyyys bidzyyys deleted the ownable-2-step branch November 15, 2024 00:12
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.

[Feature]: Ownable2Step
3 participants