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

Improve encapsulation on lifecycle, ownership and payments #1269

Merged

Conversation

come-maiz
Copy link
Contributor

This is part of #1174
Requires #1254.

  • πŸ“˜ I've reviewed the OpenZeppelin Contributor Guidelines
  • βœ… I've added tests where applicable to test my new functionality.
  • πŸ“– I've made sure that my contracts are well-documented.
  • 🎨 I've run the JS/Solidity linters and fixed any issues (npm run lint:all:fix).

@come-maiz come-maiz added kind:improvement contracts Smart contract code. breaking change Changes that break backwards compatibility of the public API. labels Sep 3, 2018
@frangio frangio added this to the v2.0 milestone Sep 3, 2018
@frangio frangio force-pushed the refactor/1174/private-state-vars branch from bcc442e to fe431bf Compare September 3, 2018 21:39
@frangio
Copy link
Contributor

frangio commented Sep 3, 2018

Rebased on master.

/**
* @return the address of the owner.
*/
function getOwner() public view returns(address) {
Copy link
Contributor

@frangio frangio Sep 3, 2018

Choose a reason for hiding this comment

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

I'm not fond of starting this convention of getters prefixed with get. I feel like it goes against the rest of the ecosystem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what we discussed about having verbs on function names. I won't like it, but I can remove the gets and try to convince the ecosystem to use them before 3.0.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I'd prefer to remove the get.

* @return the current state of the escrow.
*/
function getState() public view returns(State) {
return state_;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

any idea how to test this?
When I do something like:
(await this.escrow.getState()).should.be.equal(1);
I get:
AssertionError: expected { Object (s, e, ...) } to equal 1
I might be doing something dumb here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the error just means that they're not the same thing. Try using should.be.bignumber.equal to get a nicer error message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that helped, thanks!

frangio
frangio previously approved these changes Sep 5, 2018
Copy link
Contributor

@frangio frangio left a comment

Choose a reason for hiding this comment

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

Thanks @ElOpio! πŸ˜„

}

/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = address(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

This line should stay because it's not part of _transferOwnership. But we've removed Claimable in #1274.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, #1274 is not merged yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed, and no test failed πŸ‘Ž

@frangio frangio dismissed their stale review September 5, 2018 13:58

Should not be merged until previous comment is fixed or #1274 is merged.

@frangio
Copy link
Contributor

frangio commented Sep 5, 2018

@ElOpio Can you fix the merge conflicts please?

@@ -40,5 +40,6 @@ contract Claimable is Ownable {
*/
function claimOwnership() public onlyPendingOwner {
_transferOwnership(pendingOwner_);
pendingOwner = address(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing underscore suffix! 😣

Copy link
Contributor Author

Choose a reason for hiding this comment

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

goddammit! I should have breakfast first :D

@come-maiz
Copy link
Contributor Author

@frangio resolved

@come-maiz
Copy link
Contributor Author

There's something weird with the coverage report. The lines it report uncovered have specific tests added on this PR, and that lead to full coverage on previous commits. Maybe, I broke something on one merge, or maybe it's coveralls being nuts.

Copy link
Contributor

@frangio frangio left a comment

Choose a reason for hiding this comment

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

I'm not sure why coverage decreased either. It could be related to only testing those functions with actual members of the mapping... But this shouldn't be a problem. Let's merge anyway. Thanks!

@frangio frangio merged commit 45c0c07 into OpenZeppelin:master Sep 5, 2018
@come-maiz come-maiz deleted the refactor/1174/private-state-vars branch September 6, 2018 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Changes that break backwards compatibility of the public API. contracts Smart contract code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants