Skip to content

Commit

Permalink
Merge branch 'master' into feat/oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvolear authored Oct 4, 2023
2 parents 65d4e6b + f59cdc0 commit a1c363e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
19 changes: 16 additions & 3 deletions contracts/contracts-registry/AbstractContractsRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@ abstract contract AbstractContractsRegistry is Initializable {
) internal virtual {
require(contractAddress_ != address(0), "ContractsRegistry: zero address is forbidden");

address proxyAddr_ = address(
new TransparentUpgradeableProxy(contractAddress_, address(_proxyUpgrader), data_)
);
address proxyAddr_ = _deployProxy(contractAddress_, address(_proxyUpgrader), data_);

_contracts[name_] = proxyAddr_;
_isProxy[proxyAddr_] = true;
Expand Down Expand Up @@ -241,4 +239,19 @@ abstract contract AbstractContractsRegistry is Initializable {

emit ContractRemoved(name_);
}

/**
* @notice The utility function to deploy a Transparent Proxy contract to be used within the registry
* @param contractAddress_ the implementation address
* @param admin_ the proxy admin to be set
* @param data_ the proxy initialization data
* @return the address of a Transparent Proxy
*/
function _deployProxy(
address contractAddress_,
address admin_,
bytes memory data_
) internal virtual returns (address) {
return address(new TransparentUpgradeableProxy(contractAddress_, admin_, data_));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract contract AbstractPoolContractsRegistry is Initializable, AbstractDepend
address internal _contractsRegistry;

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

/**
* @notice The proxy initializer function
Expand Down Expand Up @@ -124,7 +124,7 @@ abstract contract AbstractPoolContractsRegistry is Initializable, AbstractDepend
) internal virtual {
for (uint256 i = 0; i < names_.length; i++) {
if (address(_beacons[names_[i]]) == address(0)) {
_beacons[names_[i]] = new ProxyBeacon();
_beacons[names_[i]] = ProxyBeacon(_deployProxyBeacon());
}

if (_beacons[names_[i]].implementation() != newImplementations_[i]) {
Expand Down Expand Up @@ -181,4 +181,12 @@ abstract contract AbstractPoolContractsRegistry is Initializable, AbstractDepend
function _addProxyPool(string memory name_, address poolAddress_) internal virtual {
_pools[name_].add(poolAddress_);
}

/**
* @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());
}
}
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solarity/solidity-lib",
"version": "2.5.10",
"version": "2.5.12",
"license": "MIT",
"author": "Distributed Lab",
"readme": "README.md",
Expand Down
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": "2.5.10",
"version": "2.5.12",
"license": "MIT",
"author": "Distributed Lab",
"description": "Solidity Library by Distributed Lab",
Expand Down

0 comments on commit a1c363e

Please sign in to comment.