diff --git a/README.md b/README.md index 11a2e088..b52f0185 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,23 @@ +![](https://github.com/dl-solarity/solidity-lib/assets/47551140/f5c3929c-657e-4a27-84a2-e5f1bf14e4e9) + [![npm](https://img.shields.io/npm/v/@solarity/solidity-lib.svg)](https://www.npmjs.com/package/@solarity/solidity-lib) [![Coverage Status](https://codecov.io/gh/dl-solarity/solidity-lib/graph/badge.svg)](https://codecov.io/gh/dl-solarity/solidity-lib) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![GitPOAP Badge](https://public-api.gitpoap.io/v1/repo/dl-solarity/solidity-lib/badge)](https://www.gitpoap.io/gh/dl-solarity/solidity-lib) -# Solidity Library by Distributed Lab - -**Solidity Library for savvies by DL** +# Solidity Library for savvies by Distributed Lab -The library consists of modules and utilities that are built with a help of [Openzeppelin Contracts](https://github.com/OpenZeppelin/openzeppelin-contracts) (4.9.2) and go far beyond mediocre solidity. +The library consists of modules and utilities that are built with a help of [Openzeppelin Contracts](https://github.com/OpenZeppelin/openzeppelin-contracts) (4.9.2) and **go far beyond mediocre solidity**. - Implementation of [**Contracts Registry**](https://eips.ethereum.org/EIPS/eip-6224) pattern -- Versatile **RBAC** smart contract +- Versatile **RBAC** and **MultiOwnable** smart contracts - Enhanced and simplified [**Diamond**](https://eips.ethereum.org/EIPS/eip-2535) pattern - Heap based priority queue library - Memory data structures (Vector) - Optimized [**Incremental Merkle Tree**](https://github.com/runtimeverification/deposit-contract-verification/blob/master/deposit-contract-verification.pdf) data structure - Novel **ReturnDataProxy** contract -- Utilities to ease work with ERC20 decimals, arrays, and sets +- Lightweight **SBT** implementation +- Utilities to ease work with ERC20 decimals, arrays, sets and ZK proofs ## Overview diff --git a/contracts/access-control/MultiOwnable.sol b/contracts/access-control/MultiOwnable.sol index a7fdbe61..a2edc49a 100644 --- a/contracts/access-control/MultiOwnable.sol +++ b/contracts/access-control/MultiOwnable.sol @@ -39,23 +39,23 @@ abstract contract MultiOwnable is IMultiOwnable, Initializable { _addOwners(msg.sender.asSingletonArray()); } - function addOwners(address[] memory newOwners_) public virtual override onlyOwner { + function addOwners(address[] memory newOwners_) public override onlyOwner { _addOwners(newOwners_); } - function removeOwners(address[] memory oldOwners_) public virtual override onlyOwner { + function removeOwners(address[] memory oldOwners_) public override onlyOwner { _removeOwners(oldOwners_); } - function renounceOwnership() public virtual override onlyOwner { + function renounceOwnership() public override onlyOwner { _removeOwners(msg.sender.asSingletonArray()); } - function getOwners() public view virtual override returns (address[] memory) { + function getOwners() public view override returns (address[] memory) { return _owners.values(); } - function isOwner(address address_) public view virtual override returns (bool) { + function isOwner(address address_) public view override returns (bool) { return _owners.contains(address_); } diff --git a/contracts/compound-rate-keeper/AbstractCompoundRateKeeper.sol b/contracts/compound-rate-keeper/AbstractCompoundRateKeeper.sol index 1fd06144..16332624 100644 --- a/contracts/compound-rate-keeper/AbstractCompoundRateKeeper.sol +++ b/contracts/compound-rate-keeper/AbstractCompoundRateKeeper.sol @@ -157,7 +157,7 @@ abstract contract AbstractCompoundRateKeeper is ICompoundRateKeeper, Initializab * @notice The internal function to set the capitalization rate * @param capitalizationRate_ new capitalization rate */ - function _setCapitalizationRate(uint256 capitalizationRate_) internal { + function _setCapitalizationRate(uint256 capitalizationRate_) internal virtual { _update(); _changeCapitalizationRate(capitalizationRate_); } @@ -166,7 +166,7 @@ abstract contract AbstractCompoundRateKeeper is ICompoundRateKeeper, Initializab * @notice The internal function to set the capitalization period * @param capitalizationPeriod_ new capitalization period */ - function _setCapitalizationPeriod(uint64 capitalizationPeriod_) internal { + function _setCapitalizationPeriod(uint64 capitalizationPeriod_) internal virtual { _update(); _changeCapitalizationPeriod(capitalizationPeriod_); } diff --git a/contracts/contracts-registry/AbstractContractsRegistry.sol b/contracts/contracts-registry/AbstractContractsRegistry.sol index dd874e78..e9addb9d 100644 --- a/contracts/contracts-registry/AbstractContractsRegistry.sol +++ b/contracts/contracts-registry/AbstractContractsRegistry.sol @@ -101,7 +101,7 @@ abstract contract AbstractContractsRegistry is Initializable { * @notice The function that injects the dependencies into the given contract * @param name_ the name of the contract */ - function _injectDependencies(string memory name_) internal { + function _injectDependencies(string memory name_) internal virtual { _injectDependenciesWithData(name_, bytes("")); } @@ -110,7 +110,10 @@ abstract contract AbstractContractsRegistry is Initializable { * @param name_ the name of the contract * @param data_ the extra context data */ - function _injectDependenciesWithData(string memory name_, bytes memory data_) internal { + function _injectDependenciesWithData( + string memory name_, + bytes memory data_ + ) internal virtual { address contractAddress_ = _contracts[name_]; require(contractAddress_ != address(0), "ContractsRegistry: this mapping doesn't exist"); @@ -126,7 +129,7 @@ abstract contract AbstractContractsRegistry is Initializable { * * It is the Owner's responsibility to ensure the compatibility between implementations */ - function _upgradeContract(string memory name_, address newImplementation_) internal { + function _upgradeContract(string memory name_, address newImplementation_) internal virtual { _upgradeContractAndCall(name_, newImplementation_, bytes("")); } @@ -142,7 +145,7 @@ abstract contract AbstractContractsRegistry is Initializable { string memory name_, address newImplementation_, bytes memory data_ - ) internal { + ) internal virtual { address contractToUpgrade_ = _contracts[name_]; require(contractToUpgrade_ != address(0), "ContractsRegistry: this mapping doesn't exist"); @@ -159,7 +162,7 @@ abstract contract AbstractContractsRegistry is Initializable { * @param name_ the name to associate the contract with * @param contractAddress_ the address of the contract */ - function _addContract(string memory name_, address contractAddress_) internal { + function _addContract(string memory name_, address contractAddress_) internal virtual { require(contractAddress_ != address(0), "ContractsRegistry: zero address is forbidden"); _contracts[name_] = contractAddress_; @@ -173,7 +176,7 @@ abstract contract AbstractContractsRegistry is Initializable { * @param name_ the name to associate the contract with * @param contractAddress_ the address of the implementation */ - function _addProxyContract(string memory name_, address contractAddress_) internal { + function _addProxyContract(string memory name_, address contractAddress_) internal virtual { _addProxyContractAndCall(name_, contractAddress_, bytes("")); } @@ -188,7 +191,7 @@ abstract contract AbstractContractsRegistry is Initializable { string memory name_, address contractAddress_, bytes memory data_ - ) internal { + ) internal virtual { require(contractAddress_ != address(0), "ContractsRegistry: zero address is forbidden"); address proxyAddr_ = address( @@ -208,7 +211,10 @@ abstract contract AbstractContractsRegistry is Initializable { * @param name_ the name to associate the contract with * @param contractAddress_ the address of the proxy */ - function _justAddProxyContract(string memory name_, address contractAddress_) internal { + function _justAddProxyContract( + string memory name_, + address contractAddress_ + ) internal virtual { require(contractAddress_ != address(0), "ContractsRegistry: zero address is forbidden"); _contracts[name_] = contractAddress_; @@ -225,7 +231,7 @@ abstract contract AbstractContractsRegistry is Initializable { * @notice The function to remove the contract from the ContractsRegistry * @param name_ the associated name with the contract */ - function _removeContract(string memory name_) internal { + function _removeContract(string memory name_) internal virtual { address contractAddress_ = _contracts[name_]; require(contractAddress_ != address(0), "ContractsRegistry: this mapping doesn't exist"); diff --git a/contracts/contracts-registry/pools/AbstractPoolContractsRegistry.sol b/contracts/contracts-registry/pools/AbstractPoolContractsRegistry.sol index d6e18dd2..85e71bf0 100644 --- a/contracts/contracts-registry/pools/AbstractPoolContractsRegistry.sol +++ b/contracts/contracts-registry/pools/AbstractPoolContractsRegistry.sol @@ -121,7 +121,7 @@ abstract contract AbstractPoolContractsRegistry is Initializable, AbstractDepend function _setNewImplementations( string[] memory names_, address[] memory newImplementations_ - ) internal { + ) internal virtual { for (uint256 i = 0; i < names_.length; i++) { if (address(_beacons[names_[i]]) == address(0)) { _beacons[names_[i]] = new ProxyBeacon(); @@ -143,7 +143,7 @@ abstract contract AbstractPoolContractsRegistry is Initializable, AbstractDepend string memory name_, uint256 offset_, uint256 limit_ - ) internal { + ) internal virtual { _injectDependenciesToExistingPoolsWithData(name_, bytes(""), offset_, limit_); } @@ -159,7 +159,7 @@ abstract contract AbstractPoolContractsRegistry is Initializable, AbstractDepend bytes memory data_, uint256 offset_, uint256 limit_ - ) internal { + ) internal virtual { EnumerableSet.AddressSet storage _namedPools = _pools[name_]; uint256 to_ = (offset_ + limit_).min(_namedPools.length()).max(offset_); @@ -178,7 +178,7 @@ abstract contract AbstractPoolContractsRegistry is Initializable, AbstractDepend * @param name_ the pool's associated name * @param poolAddress_ the proxy address of the pool */ - function _addProxyPool(string memory name_, address poolAddress_) internal { + function _addProxyPool(string memory name_, address poolAddress_) internal virtual { _pools[name_].add(poolAddress_); } } diff --git a/contracts/contracts-registry/pools/pool-factory/AbstractPoolFactory.sol b/contracts/contracts-registry/pools/pool-factory/AbstractPoolFactory.sol index 8b2eb300..70e123f0 100644 --- a/contracts/contracts-registry/pools/pool-factory/AbstractPoolFactory.sol +++ b/contracts/contracts-registry/pools/pool-factory/AbstractPoolFactory.sol @@ -73,7 +73,7 @@ abstract contract AbstractPoolFactory is AbstractDependant { address poolRegistry_, string memory poolType_, address poolProxy_ - ) internal { + ) internal virtual { (bool success, ) = poolRegistry_.call( abi.encodeWithSignature("addProxyPool(string,address)", poolType_, poolProxy_) ); diff --git a/contracts/package.json b/contracts/package.json index 61c3771d..ca499951 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -1,6 +1,6 @@ { "name": "@solarity/solidity-lib", - "version": "2.5.8", + "version": "2.5.9", "license": "MIT", "author": "Distributed Lab", "readme": "README.md", diff --git a/package.json b/package.json index 6f8126a3..24a26f89 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@solarity/solidity-lib", - "version": "2.5.8", + "version": "2.5.9", "license": "MIT", "author": "Distributed Lab", "description": "Solidity Library by Distributed Lab",