cairo-contracts icon indicating copy to clipboard operation
cairo-contracts copied to clipboard

Feature/transfer-ownership-pattern-#275

Open ctrlc03 opened this issue 2 years ago • 17 comments

Resolves #304. This PR implements code in the Ownable contract to introduce a two step transfer ownership process plus zero address checks.

This is optional as the original pattern is still present, however now contract owners can propose a new owner rather than directly transfer ownership. The new owner is required to accept the request before ownership is transferred. Both the owner and the proposed owner can cancel the request.

The PR contains:

  • updated ownable.sol contract with zero address checks added too.
  • updated mock Ownable contract in the test directory.

ctrlc03 avatar Apr 12 '22 11:04 ctrlc03

Het @ctrlc03 thank you for submitting this PR. This looks really cool! We've been deliberating on using namespace in the contracts and reconsidering new conventions for function naming (see the discussion in #267). Unfortunately, reviewing PRs has been blocked because of this, but we'll take a look at this as soon as we can!

andrew-fleming avatar Apr 18 '22 16:04 andrew-fleming

Hey @ctrlc03, just checking in. We updated the Ownable library, so it's no longer a blocker. No pressure, but did you want to continue working on this? Let us know either way :)

andrew-fleming avatar May 23 '22 17:05 andrew-fleming

Hey @ctrlc03, just checking in. We updated the Ownable library, so it's no longer a blocker. No pressure, but did you want to continue working on this? Let us know either way :)

Hey @andrew-fleming - awesome, I will then be updating it in the coming days. Was still running with issues when running the tests with Tox but will try to sort it out.

ctrlc03 avatar May 23 '22 18:05 ctrlc03

Hey, @ctrlc03! Just checking in. Were you able to make any headway on this PR? Again, no pressure! Let us know if you're too busy. We can take over and finish this up

andrew-fleming avatar Jun 02 '22 02:06 andrew-fleming

Hey, @ctrlc03! Just checking in. Were you able to make any headway on this PR? Again, no pressure! Let us know if you're too busy. We can take over and finish this up

My apologies, been crazy busy lately. Finishing up now - writing up the tests hoping that they finally work on my setup :)

ctrlc03 avatar Jun 02 '22 10:06 ctrlc03

My apologies, been crazy busy lately. Finishing up now - writing up the tests hoping that they finally work on my setup :)

No worries! And that's excellent to hear!

andrew-fleming avatar Jun 02 '22 15:06 andrew-fleming

My apologies, been crazy busy lately. Finishing up now - writing up the tests hoping that they finally work on my setup :)

No worries! And that's excellent to hear!

Code and tests are ready and working! I've replied by email to your previous comment, unsure you saw that. Basically asking (as a git noob) what's the best way to push the changes considering that this PR runs on an outdated version of the contracts. I have made the changes on a separate branch, just not sure if I should be pushing a new PR, or overwrite here (that might mess up something?).

ctrlc03 avatar Jun 02 '22 16:06 ctrlc03

Hmm I unfortunately did not receive said email, but I'll answer here. First, make sure your forked repo is up to date by going to fetch upstream and click fetch and merge. Then, in your local branch, write in the command line: git pull origin main. It's good practice if you want to go through the conflicts and resolve them. There's other tricks with git, but this approach is simple and easy. If, however, there's a ridiculous amount of conflicts (rebasing hell), it might be easier to just close the PR and create a new one

andrew-fleming avatar Jun 02 '22 18:06 andrew-fleming

Good luck, let me know how it goes!

andrew-fleming avatar Jun 02 '22 18:06 andrew-fleming

Good luck, let me know how it goes!

I somehow made it! lost the past commits but I think that's fine. The code works and so do tests. I've added a couple new events and one check on the cancelOwnershipRequest -> basically it checks that the proposed owner is not already zero, to prevent re-setting it to zero. Let me know if that's ok.

ctrlc03 avatar Jun 02 '22 19:06 ctrlc03

Sorry for coming in late to the discussion. I will say that I don't mind if this functionality is added by default in Ownable. It gives the user of Ownable a choice to use either one-step or two-step ownership transfer depending on their situation. I'm considering that this is how we should implement the feature in the Solidity contracts, though haven't discussed it with the team yet.

frangio avatar Jun 08 '22 22:06 frangio

...I will say that I don't mind if this functionality is added by default in Ownable. It gives the user of Ownable a choice to use either one-step or two-step ownership transfer depending on their situation. I'm considering that this is how we should implement the feature in the Solidity contracts, though haven't discussed it with the team yet.

Thanks for your input^ My concern with adding the functionality by default is with standardizing the interface. I think it'd make the distinction easier for users if we treated the two-step pattern as an Ownable extension (similar to ERC721Enumerable's relationship to ERC721). Since this feature is forthcoming in OZ's Solidity implementation, we'll follow suit either way.

@ctrlc03 😅 I'm really sorry! I think it's best to wait on the Solidity implementation and use their design as a template for interoperability. I know you put a lot of hard work in on this and I very much appreciate the effort 🙏

andrew-fleming avatar Jun 13 '22 16:06 andrew-fleming

...I will say that I don't mind if this functionality is added by default in Ownable. It gives the user of Ownable a choice to use either one-step or two-step ownership transfer depending on their situation. I'm considering that this is how we should implement the feature in the Solidity contracts, though haven't discussed it with the team yet.

Thanks for your input^ My concern with adding the functionality by default is with standardizing the interface. I think it'd make the distinction easier for users if we treated the two-step pattern as an Ownable extension (similar to ERC721Enumerable's relationship to ERC721). Since this feature is forthcoming in OZ's Solidity implementation, we'll follow suit either way.

@ctrlc03 😅 I'm really sorry! I think it's best to wait on the Solidity implementation and use their design as a template for interoperability. I know you put a lot of hard work in on this and I very much appreciate the effort 🙏

No worries! Let's keep this on standby for now :) thanks for your help so far with this!

ctrlc03 avatar Jun 13 '22 18:06 ctrlc03

No worries! Let's keep this on standby for now :) thanks for your help so far with this!

My pleasure, and thank you!

andrew-fleming avatar Jun 13 '22 18:06 andrew-fleming

Hi Andrew, Git noob here, I have made all changes locally in a separate branch as I couldn’t pull from main, however, what’s the best way to submit the new changes considering all other files changed too in the original repo?

Should we close the PR and re submit or is there another way?

Thanks

On Thu, 2 Jun 2022 at 03:42, Andrew Fleming @.***> wrote:

Hey, @ctrlc03 https://github.com/ctrlc03! Just checking in. Were you able to make any headway on this PR? Again, no pressure! Let us know if you're too busy. We can take over and finish this up

— Reply to this email directly, view it on GitHub https://github.com/OpenZeppelin/cairo-contracts/pull/275#issuecomment-1144358362, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWI6QCWAUOM3VFOQQWH3WG3VNANPRANCNFSM5TGYY7HQ . You are receiving this because you were mentioned.Message ID: @.***>

ctrlc03 avatar Oct 11 '22 06:10 ctrlc03

Hey, @ctrlc03!

So when there's conflicts in a PR, it's a good idea to checkout that branch, git merge, and fix the conflicts. It might make sense to just make a new PR since this PR is so old.

And that's great that you have changes for this issue! We have Ownable2Step to follow now as a blueprint :)

andrew-fleming avatar Oct 12 '22 05:10 andrew-fleming

Hey, @ctrlc03!

So when there's conflicts in a PR, it's a good idea to checkout that branch, git merge, and fix the conflicts. It might make sense to just make a new PR since this PR is so old.

And that's great that you have changes for this issue! We have Ownable2Step to follow now as a blueprint :)

Hey! yup good shout, I'll work on a new PR in the next days :)

ctrlc03 avatar Oct 12 '22 16:10 ctrlc03