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

[Upgrade] Add owner getter and setter to Asset and Catalyst #1345

Draft
wants to merge 8 commits into
base: feat/hardhat-updates-verification
Choose a base branch
from

Conversation

wojciech-turek
Copy link
Member

@wojciech-turek wojciech-turek commented Dec 8, 2023

Description

This PR builds on top of #1342 and requires that PR to be merged before this one.

  • Catalyst and Asset have a new function called owner and transferOwnership that sets the private variable _owner.
  • Added tests to cover the new functionalities
  • Added deploy scripts and update hardhat config file

Testing

Run the deployment process in the deploy package by calling yarn void:deploy

@wojciech-turek wojciech-turek requested a review from a team as a code owner December 8, 2023 09:23
@wojciech-turek wojciech-turek requested review from mvanmeerbeck and adjisb and removed request for a team December 8, 2023 09:23
Copy link

openzeppelin-code bot commented Dec 8, 2023

[Upgrade] Add owner getter and setter to Asset and Catalyst

Generated at commit: 6692dd16be962857d03fab4747195d2d2063c9d9

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
0
0
0
5
18
23
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@wojciech-turek wojciech-turek changed the title Ownable Upgrade [Upgrade] Add owner getter and setter to Asset and Catalyst Dec 8, 2023
@@ -384,5 +384,21 @@ contract Asset is
return "ASSET";
}

uint256[49] private __gap;
address private _owner;
Copy link
Contributor

Choose a reason for hiding this comment

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

Move to line 59?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I have declared it there so its all close together, but yeah will move it up

@@ -324,5 +324,21 @@ contract Catalyst is
return "CATALYST";
}

uint256[49] private __gap;
address private _owner;
Copy link
Contributor

Choose a reason for hiding this comment

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

Move to line 52?

Copy link
Member Author

Choose a reason for hiding this comment

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

Same


/// @notice Sets the owner of the contract
/// @param newOwner address of the new owner
function transferOwnership(address newOwner) external {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not onlyRole(DEFAULT_ADMIN_ROLE) ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the main reason is to be able to provide custom revert message.
Otherwise we could switch to using the modifier.

/// @notice Sets the owner of the contract
/// @param newOwner address of the new owner
function transferOwnership(address newOwner) external {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Asset: Unauthorized");
Copy link
Contributor

Choose a reason for hiding this comment

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

same

Comment on lines +20 to +30
if ((await read('Asset', 'owner')) === ethers.constants.AddressZero) {
await catchUnknownSigner(
execute(
'Asset',
{from: assetAdmin, log: true},
'transferOwnership',
assetAdmin
)
);
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

is better to split this in a separated step, because if something goes wrong it is easier to re-run it separately

Copy link
Member Author

Choose a reason for hiding this comment

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

If the deployment of the upgrade fails this won't be called, and its a function that we likely call only once during the upgrade process.

I feel like its integral to this upgrade.

Comment on lines +22 to +32
if ((await read('Catalyst', 'owner')) === ethers.constants.AddressZero) {
await catchUnknownSigner(
execute(
'Catalyst',
{from: catalystAdmin, log: true},
'transferOwnership',
catalystAdmin
)
);
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

is better to split this in a separated step, because if something goes wrong it is easier to re-run it separately

@wojciech-turek wojciech-turek marked this pull request as draft January 13, 2024 19:56
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.

3 participants