From c8b6268a3d53271fe38e5c7aaf03675dd29971c2 Mon Sep 17 00:00:00 2001 From: Federico Giacon <58218759+fedgiac@users.noreply.github.com> Date: Wed, 27 Jan 2021 11:39:54 +0100 Subject: [PATCH] Authenticator not as explicit proxy --- src/contracts/GPv2AllowListAuthentication.sol | 20 ++++++++++++------- src/deploy/001_authenticator.ts | 5 ++--- test/AllowListStorageReader.test.ts | 3 ++- test/GPv2AllowListAuthenticator.test.ts | 9 +++++---- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/contracts/GPv2AllowListAuthentication.sol b/src/contracts/GPv2AllowListAuthentication.sol index 6af6285f..ac9fd1b1 100644 --- a/src/contracts/GPv2AllowListAuthentication.sol +++ b/src/contracts/GPv2AllowListAuthentication.sol @@ -8,20 +8,26 @@ import "./interfaces/GPv2Authentication.sol"; /// @title Gnosis Protocol v2 Access Control Contract /// @author Gnosis Developers -contract GPv2AllowListAuthentication is - GPv2Authentication, - StorageAccessible, - OwnableUpgradeable -{ +contract GPv2AllowListAuthentication is GPv2Authentication, StorageAccessible { using EnumerableSet for EnumerableSet.AddressSet; + address public manager; EnumerableSet.AddressSet private solvers; - function addSolver(address solver) external onlyOwner { + function setManager(address _manager) public { + manager = _manager; + } + + modifier onlyManager() { + require(manager == msg.sender, "caller is not the manager"); + _; + } + + function addSolver(address solver) external onlyManager { solvers.add(solver); } - function removeSolver(address solver) external onlyOwner { + function removeSolver(address solver) external onlyManager { solvers.remove(solver); } diff --git a/src/deploy/001_authenticator.ts b/src/deploy/001_authenticator.ts index d84b159a..98ffff32 100644 --- a/src/deploy/001_authenticator.ts +++ b/src/deploy/001_authenticator.ts @@ -58,9 +58,8 @@ const deployAuthenticator: DeployFunction = async function ({ gasLimit: 2000000, deterministicDeployment: SALT, log: true, - // proxy: { - // owner: owner, - // }, + proxy: "setManager", + args: [owner], }); }; diff --git a/test/AllowListStorageReader.test.ts b/test/AllowListStorageReader.test.ts index 45fd57b8..73d3221a 100644 --- a/test/AllowListStorageReader.test.ts +++ b/test/AllowListStorageReader.test.ts @@ -21,7 +21,8 @@ describe("GPv2AllowListAuthentication", () => { ); reader = await AllowListStorageReader.deploy(); - authenticator = await GPv2AllowListAuthentication.connect(owner).deploy(); + authenticator = await GPv2AllowListAuthentication.deploy(); + await authenticator.setManager(owner.address); allowListReader = new AllowListReader(authenticator, reader); }); diff --git a/test/GPv2AllowListAuthenticator.test.ts b/test/GPv2AllowListAuthenticator.test.ts index 05fa35d9..2cd3f110 100644 --- a/test/GPv2AllowListAuthenticator.test.ts +++ b/test/GPv2AllowListAuthenticator.test.ts @@ -13,14 +13,15 @@ describe("GPv2AllowListAuthentication", () => { ); authenticator = await GPv2AllowListAuthentication.deploy(); + await authenticator.setManager(owner.address); }); describe("constructor", () => { it("should set the owner", async () => { - expect(await authenticator.owner()).to.equal(owner.address); + expect(await authenticator.manager()).to.equal(owner.address); }); it("deployer is not the owner", async () => { - expect(await authenticator.owner()).not.to.be.equal(deployer.address); + expect(await authenticator.manager()).not.to.be.equal(deployer.address); }); }); @@ -33,7 +34,7 @@ describe("GPv2AllowListAuthentication", () => { it("should not allow non-owner to add solver", async () => { await expect( authenticator.connect(nonOwner).addSolver(solver.address), - ).to.be.revertedWith("caller is not the owner"); + ).to.be.revertedWith("caller is not the manager"); }); }); @@ -46,7 +47,7 @@ describe("GPv2AllowListAuthentication", () => { it("should not allow non-owner to remove solver", async () => { await expect( authenticator.connect(nonOwner).removeSolver(solver.address), - ).to.be.revertedWith("caller is not the owner"); + ).to.be.revertedWith("caller is not the manager"); }); });