Skip to content
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

Solidity 0.8.27 #224

Merged
merged 3 commits into from
Sep 9, 2024
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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ All notable changes to this project will be documented in this file.
- The `AgentRestrictionsSet` event is emitted whenever restrictions are updated for an agent.
- All agent-scoped functions (e.g., mint, burn) now check the agent’s permissions before executing the transaction, ensuring proper enforcement of these restrictions.

- **Ethers.js Version Upgrade**:
- The project was upgraded from **Ethers v5** to **Ethers v6**, introducing several changes to the API and syntax.
- **Key Changes**:
- Adjusted syntax for contract deployments, interactions, and function calls to comply with Ethers v6.
- Replaced deprecated features from v5 with the new Ethers v6 equivalents, ensuring compatibility and future-proofing the project.
- Updated test suites and helper functions to use the Ethers v6 `Interface` and `Contract` classes, ensuring smooth testing of the updated code.
- This upgrade ensures better performance, enhanced security, and improved developer experience moving forward.

- **Solidity Version Upgrade to 0.8.27**:
- Upgraded Solidity version from **0.8.17** to **0.8.27** across all contracts, bringing in multiple new features and improvements:
- **File-Level Event Declaration**: Events are now declared at the file level, simplifying code structure and improving readability.
- **Custom Errors for Require Statements**: All `require` clauses that previously returned a string reason for failure have been updated to use **custom errors**, making debugging easier and more efficient.
- This upgrade provides a cleaner, more efficient error handling process and improves overall code structure without affecting backward compatibility.

### Updated

- **Token Recovery Function**:
Expand Down
2 changes: 1 addition & 1 deletion contracts/DVA/DVATransferManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* Tokeny sàrl for licensing options.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../roles/AgentRole.sol";
import "../token/IToken.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/DVA/DVATransferManagerProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/DVA/IDVATransferManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* Tokeny sàrl for licensing options.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../roles/AgentRole.sol";
import "../token/IToken.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/DVD/DVDTransferManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* Tokeny sàrl for licensing options.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../roles/AgentRole.sol";
import "../token/IToken.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/ERC-3643/IERC3643.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
// :#%%=
//

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/ERC-3643/IERC3643ClaimTopicsRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// +@@@@%-
// :#%%=
//
pragma solidity 0.8.26;
pragma solidity 0.8.27;

/// Events

Expand Down
2 changes: 1 addition & 1 deletion contracts/ERC-3643/IERC3643Compliance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// +@@@@%-
// :#%%=
//
pragma solidity 0.8.26;
pragma solidity 0.8.27;

/// Events

Expand Down
2 changes: 1 addition & 1 deletion contracts/ERC-3643/IERC3643IdentityRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// +@@@@%-
// :#%%=
//
pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "@onchain-id/solidity/contracts/interface/IIdentity.sol";
import "./IERC3643IdentityRegistryStorage.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/ERC-3643/IERC3643IdentityRegistryStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// +@@@@%-
// :#%%=
//
pragma solidity 0.8.26;
pragma solidity 0.8.27;
import "@onchain-id/solidity/contracts/interface/IIdentity.sol";

/// events
Expand Down
2 changes: 1 addition & 1 deletion contracts/ERC-3643/IERC3643TrustedIssuersRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// +@@@@%-
// :#%%=
//
pragma solidity 0.8.26;
pragma solidity 0.8.27;
import "@onchain-id/solidity/contracts/interface/IClaimIssuer.sol";

/// Events
Expand Down
2 changes: 1 addition & 1 deletion contracts/_testContracts/MockContract.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.8.26;
pragma solidity 0.8.27;

contract MockContract {
address _irRegistry;
Expand Down
2 changes: 1 addition & 1 deletion contracts/_testContracts/TestERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../compliance/modular/modules/CountryAllowModule.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/_testContracts/v_3_5_2/LegacyIA.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.26;
pragma solidity 0.8.27;

abstract contract ContextLegacy {
function _msgSender() internal view virtual returns (address) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/_testContracts/v_3_5_2/LegacyProxy.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.26;
pragma solidity 0.8.27;

interface IImplementationAuthorityLegacy {
function getImplementation() external view returns (address);
Expand Down
2 changes: 1 addition & 1 deletion contracts/_testContracts/v_3_5_2/LegacyToken_3_5_2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// File: @onchain-id/solidity/contracts/interface/IERC734Legacy.sol

// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.26;
pragma solidity 0.8.27;

/**
* @dev interface of the ERC734 (Key Holder) standard as defined in the EIP.
Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/legacy/BasicCompliance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../../roles/AgentRole.sol";
import "./ICompliance.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/legacy/DefaultCompliance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "./BasicCompliance.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/legacy/ICompliance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

interface ICompliance {
/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/legacy/features/ApproveTransfer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../BasicCompliance.sol";

Expand All @@ -82,7 +82,7 @@
* note that the approved transfer has to be exactly of the approved amount `_amount`
* `_token` is the address of the token that is allowed to be transferred
*/
event TransferApproved(address _from, address _to, uint _amount, address _token);

Check warning on line 85 in contracts/compliance/legacy/features/ApproveTransfer.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Rule is set with explicit type [var/s: uint]

/**
* this event is emitted when a transfer approval is removed
Expand All @@ -92,7 +92,7 @@
* `_amount` is the amount of tokens that `_from` was allowed to send to `_to`
* `_token` is the address of the token that was allowed to be transferred
*/
event ApprovalRemoved(address _from, address _to, uint _amount, address _token);

Check warning on line 95 in contracts/compliance/legacy/features/ApproveTransfer.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Rule is set with explicit type [var/s: uint]

/**
* @dev removes approval on a transfer previously approved
Expand All @@ -104,7 +104,7 @@
* Only Admin can call this function, i.e. owner of compliance contract OR token agent
* emits an `ApprovalRemoved` event
*/
function removeApproval(address _from, address _to, uint _amount) external onlyAdmin {

Check warning on line 107 in contracts/compliance/legacy/features/ApproveTransfer.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Rule is set with explicit type [var/s: uint]
bytes32 transferId = _calculateTransferID (_from, _to, _amount, address(tokenBound));
require(_transfersApproved[transferId], "transfer not approved yet");
_transfersApproved[transferId] = false;
Expand All @@ -122,7 +122,7 @@
* Only Admin can call this function, i.e. owner of compliance contract OR token agent
* emits a `TransferApproved` event, an `ApprovalRemoved` event and a `Transfer` event
*/
function approveAndTransfer(address _from, address _to, uint _amount) external {

Check warning on line 125 in contracts/compliance/legacy/features/ApproveTransfer.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Rule is set with explicit type [var/s: uint]
approveTransfer(_from, _to, _amount);
tokenBound.transferFrom(_from, _to, _amount);
}
Expand All @@ -136,7 +136,7 @@
* Only Admin can call this function, i.e. owner of compliance contract OR token agent
* emits a `TransferApproved` event
*/
function approveTransfer(address _from, address _to, uint _amount) public onlyAdmin {

Check warning on line 139 in contracts/compliance/legacy/features/ApproveTransfer.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Rule is set with explicit type [var/s: uint]
bytes32 transferId = _calculateTransferID (_from, _to, _amount, address(tokenBound));
require(!_transfersApproved[transferId], "transfer already approved");
_transfersApproved[transferId] = true;
Expand Down Expand Up @@ -207,7 +207,7 @@
* emits an `ApprovalRemoved` event if transfer was pre-approved, i.e. if function call was done by a regular
* token holder, token agents bypassing the approval requirements
*/
function _transferProcessed(address _from, address _to, uint _amount) internal {

Check warning on line 210 in contracts/compliance/legacy/features/ApproveTransfer.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Rule is set with explicit type [var/s: uint]
bytes32 transferId = _calculateTransferID (_from, _to, _amount, address(tokenBound));
if (_transfersApproved[transferId]) {
_transfersApproved[transferId] = false;
Expand All @@ -227,7 +227,7 @@
function _calculateTransferID (
address _from,
address _to,
uint _amount,

Check warning on line 230 in contracts/compliance/legacy/features/ApproveTransfer.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Rule is set with explicit type [var/s: uint]
address _token
) internal pure returns (bytes32){
bytes32 transferId = keccak256(abi.encode(_from, _to, _amount, _token));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../BasicCompliance.sol";

Expand Down Expand Up @@ -95,7 +95,7 @@
* emits _countries.length `AddedRestrictedCountry` events
*/
function batchRestrictCountries(uint16[] calldata _countries) external {
for (uint i = 0; i < _countries.length; i++) {

Check warning on line 98 in contracts/compliance/legacy/features/CountryRestrictions.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Rule is set with explicit type [var/s: uint]
addCountryRestriction(_countries[i]);
}
}
Expand All @@ -108,7 +108,7 @@
* emits _countries.length `RemovedRestrictedCountry` events
*/
function batchUnrestrictCountries(uint16[] calldata _countries) external {
for (uint i = 0; i < _countries.length; i++) {

Check warning on line 111 in contracts/compliance/legacy/features/CountryRestrictions.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Rule is set with explicit type [var/s: uint]
removeCountryRestriction(_countries[i]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../BasicCompliance.sol";

Expand Down Expand Up @@ -95,7 +95,7 @@
* emits an `WhitelistedCountry` event
*/
function batchWhitelistCountries(uint16[] memory _countries) external {
for (uint i = 0; i < _countries.length; i++) {

Check warning on line 98 in contracts/compliance/legacy/features/CountryWhitelisting.sol

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Rule is set with explicit type [var/s: uint]
whitelistCountry(_countries[i]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/legacy/features/DayMonthLimits.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../BasicCompliance.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../BasicCompliance.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/legacy/features/MaxBalance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../BasicCompliance.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/legacy/features/SupplyLimit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../BasicCompliance.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/legacy/test/ApproveTransferTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../features/ApproveTransfer.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../features/CountryRestrictions.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../features/CountryWhitelisting.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/legacy/test/DayMonthLimitsTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../features/DayMonthLimits.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../features/ExchangeMonthlyLimits.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/legacy/test/MaxBalanceTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../features/MaxBalance.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/legacy/test/SupplyLimitTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../features/SupplyLimit.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/modular/IModularCompliance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../../ERC-3643/IERC3643Compliance.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/modular/MCStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

contract MCStorage {
/// token linked to the compliance contract
Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/modular/ModularCompliance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "../../token/IToken.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/compliance/modular/modules/AbstractModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "./IModule.sol";
import "../../../errors/InvalidArgumentErrors.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* Tokeny sàrl for licensing options.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../IModularCompliance.sol";
import "../../../token/IToken.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* Tokeny sàrl for licensing options.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../IModularCompliance.sol";
import "../../../token/IToken.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* Tokeny sàrl for licensing options.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../IModularCompliance.sol";
import "../../../token/IToken.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* Tokeny sàrl for licensing options.
*/

pragma solidity 0.8.26;
pragma solidity 0.8.27;

import "../IModularCompliance.sol";
import "../../../token/IToken.sol";
Expand Down
Loading
Loading