Skip to content

Remove PermanentOwnable and ProxyBeacon as they have been deprecated due to OpenZeppelin upgrade. Adjust tests accordingly. #135

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

Merged
merged 5 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 0 additions & 50 deletions contracts/access/APermanentOwnable.sol

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/contracts-registry/AContractsRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ abstract contract AContractsRegistry is Initializable {
* @notice The initialization function
*/
function __AContractsRegistry_init() internal onlyInitializing {
_proxyUpgrader = new AdminableProxyUpgrader();
_proxyUpgrader = new AdminableProxyUpgrader(address(this));
}

/**
Expand Down
13 changes: 7 additions & 6 deletions contracts/contracts-registry/pools/APoolContractsRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
pragma solidity ^0.8.21;

import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

import {Paginator} from "../../libs/arrays/Paginator.sol";

import {ADependant} from "../../contracts-registry/ADependant.sol";

import {ProxyBeacon} from "../../proxy/beacon/ProxyBeacon.sol";

/**
* @notice The PoolContractsRegistry module
*
Expand All @@ -31,7 +30,7 @@ abstract contract APoolContractsRegistry is Initializable, ADependant {

address internal _contractsRegistry;

mapping(string => ProxyBeacon) private _beacons;
mapping(string => UpgradeableBeacon) private _beacons;
mapping(string => EnumerableSet.AddressSet) private _pools; // name => pool

error NoMappingExists(string poolName);
Expand Down Expand Up @@ -134,7 +133,9 @@ abstract contract APoolContractsRegistry is Initializable, ADependant {
) internal virtual {
for (uint256 i = 0; i < names_.length; i++) {
if (address(_beacons[names_[i]]) == address(0)) {
_beacons[names_[i]] = ProxyBeacon(_deployProxyBeacon());
_beacons[names_[i]] = UpgradeableBeacon(
_deployProxyBeacon(newImplementations_[i])
);
}

if (_beacons[names_[i]].implementation() != newImplementations_[i]) {
Expand Down Expand Up @@ -196,7 +197,7 @@ abstract contract APoolContractsRegistry is Initializable, ADependant {
* @notice The utility function to deploy a Proxy Beacon contract to be used within the registry
* @return the address of a Proxy Beacon
*/
function _deployProxyBeacon() internal virtual returns (address) {
return address(new ProxyBeacon());
function _deployProxyBeacon(address implementation_) internal virtual returns (address) {
return address(new UpgradeableBeacon(implementation_, address(this)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
pragma solidity ^0.8.22;

import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";

import {ADependant} from "../../../contracts-registry/ADependant.sol";
import {APoolContractsRegistry} from "../APoolContractsRegistry.sol";

import {PublicBeaconProxy} from "../../../proxy/beacon/PublicBeaconProxy.sol";

/**
* @notice The PoolContractsRegistry module
*
Expand Down Expand Up @@ -43,7 +42,7 @@ abstract contract APoolFactory is ADependant {
) internal virtual returns (address) {
return
address(
new PublicBeaconProxy(
new BeaconProxy(
APoolContractsRegistry(poolRegistry_).getProxyBeacon(poolType_),
bytes("")
)
Expand All @@ -61,7 +60,7 @@ abstract contract APoolFactory is ADependant {
) internal virtual returns (address) {
return
address(
new PublicBeaconProxy{salt: salt_}(
new BeaconProxy{salt: salt_}(
APoolContractsRegistry(poolRegistry_).getProxyBeacon(poolType_),
bytes("")
)
Expand Down Expand Up @@ -98,7 +97,7 @@ abstract contract APoolFactory is ADependant {
) internal view virtual returns (address) {
bytes32 bytecodeHash = keccak256(
abi.encodePacked(
type(PublicBeaconProxy).creationCode,
type(BeaconProxy).creationCode,
abi.encode(
APoolContractsRegistry(poolRegistry_).getProxyBeacon(poolType_),
bytes("")
Expand Down
15 changes: 0 additions & 15 deletions contracts/mock/access/PermanentOwnableMock.sol

This file was deleted.

7 changes: 4 additions & 3 deletions contracts/proxy/adminable/AdminableProxyUpgrader.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;

import {APermanentOwnable} from "../../access/APermanentOwnable.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

import {IAdminableProxy} from "./AdminableProxy.sol";

/**
* @notice The proxies module
*
* This is the lightweight helper contract that may be used as a AdminableProxy admin.
*/
contract AdminableProxyUpgrader is APermanentOwnable {
constructor() APermanentOwnable(msg.sender) {}
contract AdminableProxyUpgrader is Ownable {
constructor(address initialOwner_) Ownable(initialOwner_) {}

/**
* @notice The function to upgrade the implementation contract
Expand Down
42 changes: 0 additions & 42 deletions contracts/proxy/beacon/ProxyBeacon.sol

This file was deleted.

24 changes: 0 additions & 24 deletions contracts/proxy/beacon/PublicBeaconProxy.sol

This file was deleted.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solarity/solidity-lib",
"version": "3.0.0-rc.1",
"version": "3.0.0-rc.2",
"license": "MIT",
"author": "Distributed Lab",
"readme": "README.md",
Expand Down
49 changes: 0 additions & 49 deletions test/access/PermanentOwnable.test.ts

This file was deleted.

15 changes: 3 additions & 12 deletions test/contracts-registry/pools/pool-factory/PoolFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Reverter } from "@/test/helpers/reverter";

import {
PoolFactoryMock,
PublicBeaconProxy,
BeaconProxy,
PoolContractsRegistryMock,
ContractsRegistryPoolMock,
PoolMock,
Expand Down Expand Up @@ -97,12 +97,11 @@ describe("PoolFactory", () => {
expect(await poolContractsRegistry.countPools(NAME_2)).to.equal(0n);

const PoolMock = await ethers.getContractFactory("PoolMock");
const PublicBeaconProxy = await ethers.getContractFactory("PublicBeaconProxy");
const BeaconProxy = await ethers.getContractFactory("BeaconProxy");

const pool = <PoolMock>PoolMock.attach((await poolContractsRegistry.listPools(NAME_1, 0, 1))[0]);
const beaconProxy = <PublicBeaconProxy>PublicBeaconProxy.attach(await pool.getAddress());
const beaconProxy = <BeaconProxy>BeaconProxy.attach(await pool.getAddress());

expect(await beaconProxy.implementation()).to.equal(await poolImpl.getAddress());
expect(await pool.token()).not.to.equal(ethers.ZeroAddress);
});

Expand Down Expand Up @@ -177,20 +176,12 @@ describe("PoolFactory", () => {
expect(pools).to.deep.equal([predictedAddress1, predictedAddress2]);

const PoolMock = await ethers.getContractFactory("PoolMock");
const PublicBeaconProxy = await ethers.getContractFactory("PublicBeaconProxy");

const poolProxies = await Promise.all(pools.map(async (pool: string) => <PoolMock>PoolMock.attach(pool)));
const beaconProxies = await Promise.all(
pools.map(async (pool: string) => <PublicBeaconProxy>PublicBeaconProxy.attach(pool)),
);

const tokens = await Promise.all(poolProxies.map(async (poolProxy: PoolMock) => await poolProxy.token()));
const implementations = await Promise.all(
beaconProxies.map(async (beaconProxy: PublicBeaconProxy) => await beaconProxy.implementation()),
);

expect(tokens).to.deep.equal([await token.getAddress(), await token.getAddress()]);
expect(implementations).to.deep.equal([await poolImpl.getAddress(), await poolImpl.getAddress()]);
});

it("should revert when deploying the pool with the same salt", async () => {
Expand Down
Loading