Skip to content

Commit

Permalink
Bumping OpenZeppeling for bytecode optimized base classes
Browse files Browse the repository at this point in the history
  • Loading branch information
cristovaoth committed Oct 7, 2023
1 parent dd1fd41 commit be8b73d
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion contracts/test/TestGuardableModifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ contract TestGuardableModifier is GuardableModifier {

function setUp(bytes memory initializeParams) public override initializer {
setupModules();
__Ownable_init();
__Ownable_init(msg.sender);
(address _avatar, address _target) = abi.decode(
initializeParams,
(address, address)
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/TestModifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ contract TestModifier is Modifier {

function setUp(bytes memory initializeParams) public override initializer {
setupModules();
__Ownable_init();
__Ownable_init(msg.sender);
(address _avatar, address _target) = abi.decode(
initializeParams,
(address, address)
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/TestModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ contract TestModule is GuardableModule {
}

function setUp(bytes memory initializeParams) public override initializer {
__Ownable_init();
__Ownable_init(msg.sender);
(address _avatar, address _target) = abi.decode(
initializeParams,
(address, address)
Expand Down
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default {
solidity: {
compilers: [
{
version: "0.8.6",
version: "0.8.20",
settings: {
optimizer: {
enabled: true,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
"dependencies": {
"@gnosis.pm/mock-contract": "^4.0.0",
"@gnosis.pm/safe-contracts": "1.3.0",
"@openzeppelin/contracts": "^4.8.1",
"@openzeppelin/contracts-upgradeable": "^4.8.1",
"@openzeppelin/contracts": "^5.0.0",
"@openzeppelin/contracts-upgradeable": "^5.0.0",
"ethers": "^5.7.1"
}
}
16 changes: 8 additions & 8 deletions test/02_Module.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ describe("Module", async () => {
it("reverts if caller is not the owner", async () => {
const { iAvatar, module } = await loadFixture(setupTests);

const [, wallet1] = await hre.ethers.getSigners();
const [owner, wallet1] = await hre.ethers.getSigners();

await module.transferOwnership(wallet1.address);
await expect(module.setAvatar(iAvatar.address)).to.be.revertedWith(
"Ownable: caller is not the owner"
);
await expect(module.setAvatar(iAvatar.address))
.to.be.revertedWithCustomError(module, "OwnableUnauthorizedAccount")
.withArgs(owner.address);
});

it("allows owner to set avatar", async () => {
Expand All @@ -64,11 +64,11 @@ describe("Module", async () => {
describe("setTarget", async () => {
it("reverts if caller is not the owner", async () => {
const { iAvatar, module } = await loadFixture(setupTests);
const [, wallet1] = await hre.ethers.getSigners();
const [owner, wallet1] = await hre.ethers.getSigners();
await module.transferOwnership(wallet1.address);
await expect(module.setTarget(iAvatar.address)).to.be.revertedWith(
"Ownable: caller is not the owner"
);
await expect(module.setTarget(iAvatar.address))
.to.be.revertedWithCustomError(module, "OwnableUnauthorizedAccount")
.withArgs(owner.address);
});

it("allows owner to set avatar", async () => {
Expand Down
10 changes: 6 additions & 4 deletions test/03_Modifier.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ describe("Modifier", async () => {

const [, user2] = await hre.ethers.getSigners();

await expect(
modifier.connect(user2).enableModule(user2.address)
).to.be.revertedWith("Ownable: caller is not the owner");
await expect(modifier.connect(user2).enableModule(user2.address))
.to.be.revertedWithCustomError(modifier, "OwnableUnauthorizedAccount")
.withArgs(user2.address);
});

it("reverts if module is zero address", async () => {
Expand Down Expand Up @@ -103,7 +103,9 @@ describe("Modifier", async () => {
const [, user2] = await hre.ethers.getSigners();
await expect(
modifier.connect(user2).disableModule(SENTINEL_MODULES, user2.address)
).to.be.revertedWith("Ownable: caller is not the owner");
)
.to.be.revertedWithCustomError(modifier, "OwnableUnauthorizedAccount")
.withArgs(user2.address);
});

it("reverts if module is zero address", async () => {
Expand Down
6 changes: 3 additions & 3 deletions test/04_Guard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ describe("Guardable", async () => {
it("reverts if reverts if caller is not the owner", async () => {
const { module } = await loadFixture(setupTests);
const [, user1] = await hre.ethers.getSigners();
await expect(
module.connect(user1).setGuard(user1.address)
).to.be.revertedWith("Ownable: caller is not the owner");
await expect(module.connect(user1).setGuard(user1.address))
.to.be.revertedWithCustomError(module, "OwnableUnauthorizedAccount")
.withArgs(user1.address);
});

it("reverts if guard does not implement ERC165", async () => {
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -793,15 +793,15 @@
table "^6.8.0"
undici "^5.14.0"

"@openzeppelin/contracts-upgradeable@^4.8.1":
version "4.8.3"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.8.3.tgz#6b076a7b751811b90fe3a172a7faeaa603e13a3f"
integrity sha512-SXDRl7HKpl2WDoJpn7CK/M9U4Z8gNXDHHChAKh0Iz+Wew3wu6CmFYBeie3je8V0GSXZAIYYwUktSrnW/kwVPtg==
"@openzeppelin/contracts-upgradeable@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-5.0.0.tgz#859c00c55f04b6dda85b3c88bce507d65019888f"
integrity sha512-D54RHzkOKHQ8xUssPgQe2d/U92mwaiBDY7qCCVGq6VqwQjsT3KekEQ3bonev+BLP30oZ0R1U6YC8/oLpizgC5Q==

"@openzeppelin/contracts@^4.8.1":
version "4.8.3"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.8.3.tgz#cbef3146bfc570849405f59cba18235da95a252a"
integrity sha512-bQHV8R9Me8IaJoJ2vPG4rXcL7seB7YVuskr4f+f5RyOStSZetwzkWtoqDMl5erkBJy0lDRUnIR2WIkPiC0GJlg==
"@openzeppelin/contracts@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-5.0.0.tgz#ee0e4b4564f101a5c4ee398cd4d73c0bd92b289c"
integrity sha512-bv2sdS6LKqVVMLI5+zqnNrNU/CA+6z6CmwFXm/MzmOPBRSO5reEJN7z0Gbzvs0/bv/MZZXNklubpwy3v2+azsw==

"@pkgjs/parseargs@^0.11.0":
version "0.11.0"
Expand Down Expand Up @@ -5978,4 +5978,4 @@ yocto-queue@^0.1.0:
zksync-web3@^0.14.3:
version "0.14.3"
resolved "https://registry.yarnpkg.com/zksync-web3/-/zksync-web3-0.14.3.tgz#64ac2a16d597464c3fc4ae07447a8007631c57c9"
integrity sha512-hT72th4AnqyLW1d5Jlv8N2B/qhEnl2NePK2A3org7tAa24niem/UAaHMkEvmWI3SF9waYUPtqAtjpf+yvQ9zvQ==
integrity sha512-hT72th4AnqyLW1d5Jlv8N2B/qhEnl2NePK2A3org7tAa24niem/UAaHMkEvmWI3SF9waYUPtqAtjpf+yvQ9zvQ==

0 comments on commit be8b73d

Please sign in to comment.