Skip to content

Commit

Permalink
fixed virtual functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvolear committed Oct 3, 2023
1 parent 6b9de32 commit de75041
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 29 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
10 changes: 5 additions & 5 deletions contracts/access-control/MultiOwnable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/compound-rate-keeper/AbstractCompoundRateKeeper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
}
Expand All @@ -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_);
}
Expand Down
24 changes: 15 additions & 9 deletions contracts/contracts-registry/AbstractContractsRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(""));
}

Expand All @@ -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");
Expand All @@ -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(""));
}

Expand All @@ -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");
Expand All @@ -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_;
Expand All @@ -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(""));
}

Expand All @@ -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(
Expand All @@ -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_;
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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_);
}

Expand All @@ -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_);
Expand All @@ -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_);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
);
Expand Down
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.8",
"version": "2.5.9",
"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.8",
"version": "2.5.9",
"license": "MIT",
"author": "Distributed Lab",
"description": "Solidity Library by Distributed Lab",
Expand Down

0 comments on commit de75041

Please sign in to comment.