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

refactor: update contracts to allow compiling with solc versions 0.8.7, .6 and .5 #738

Merged
merged 4 commits into from
Oct 10, 2023
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
34 changes: 24 additions & 10 deletions .github/workflows/solc_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
name: Solidity Compiler Versions

on:
workflow_dispatch:

# Used to check pragma settings for `.sol` files are correct before releasing
push:
branches:
- "develop"
# compare gas diff only when editing Solidity smart contract code
paths:
- "contracts/**/*.sol"

pull_request:
types: [opened]

Expand All @@ -16,10 +26,9 @@ jobs:
strategy:
matrix:
solc: [
# TODO: wait for a patch release of @erc725/smart-contracts to compile on these 3 versions
# "0.8.5",
# "0.8.6",
# "0.8.7",
"0.8.5",
"0.8.6",
"0.8.7",
"0.8.8",
"0.8.9",
"0.8.10",
Expand Down Expand Up @@ -55,17 +64,22 @@ jobs:
solc-select install ${{ matrix.solc }}
solc-select use ${{ matrix.solc }}

- name: Compare versions to filter contracts to compile
uses: madhead/semver-utils@latest
id: comparison
with:
version: ${{ matrix.solc }}
compare-to: 0.8.12

- name: Compile Smart Contracts
run: |
if [[ ${{ matrix.solc }} < 0.8.12 ]]
if [[ "<" == "${{ steps.comparison.outputs.comparison-result }}" ]]
then
solc $(ls contracts/**/*.sol | grep -v "Compatible") --allow-paths $(pwd)/node_modules/ \
@erc725/smart-contracts/=node_modules/@erc725/smart-contracts/ \
@openzeppelin/=node_modules/@openzeppelin/ \
solc $(ls contracts/**/*.sol | grep -v "Compatible" | grep -v "Extension4337") --allow-paths $(pwd)/node_modules/ \
@=node_modules/@ \
solidity-bytes-utils/=node_modules/solidity-bytes-utils/
else
solc contracts/**/*.sol \
@erc725/smart-contracts/=node_modules/@erc725/smart-contracts/ \
@openzeppelin/=node_modules/@openzeppelin/ \
@=node_modules/@ \
solidity-bytes-utils/=node_modules/solidity-bytes-utils/
fi;
6 changes: 3 additions & 3 deletions contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ abstract contract LSP0ERC725AccountCore is
*/
function batchCalls(
bytes[] calldata data
) public virtual returns (bytes[] memory results) {
) public virtual override returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i; i < data.length; ) {
(bool success, bytes memory result) = address(this).delegatecall(
Expand Down Expand Up @@ -415,7 +415,7 @@ abstract contract LSP0ERC725AccountCore is
function universalReceiver(
bytes32 typeId,
bytes calldata receivedData
) public payable virtual returns (bytes memory returnedValues) {
) public payable virtual override returns (bytes memory returnedValues) {
if (msg.value != 0) {
emit ValueReceived(msg.sender, msg.value);
}
Expand Down Expand Up @@ -678,7 +678,7 @@ abstract contract LSP0ERC725AccountCore is
function isValidSignature(
bytes32 dataHash,
bytes memory signature
) public view virtual returns (bytes4 magicValue) {
) public view virtual override returns (bytes4 magicValue) {
address _owner = owner();

// If owner is a contract
Expand Down
56 changes: 43 additions & 13 deletions contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,42 +85,68 @@ abstract contract LSP11BasicSocialRecoveryCore is
/**
* @inheritdoc ILSP11BasicSocialRecovery
*/
function target() public view virtual returns (address) {
function target() public view virtual override returns (address) {
return _target;
}

/**
* @inheritdoc ILSP11BasicSocialRecovery
*/
function getRecoveryCounter() public view virtual returns (uint256) {
function getRecoveryCounter()
public
view
virtual
override
returns (uint256)
{
return _recoveryCounter;
}

/**
* @inheritdoc ILSP11BasicSocialRecovery
*/
function getGuardians() public view virtual returns (address[] memory) {
function getGuardians()
public
view
virtual
override
returns (address[] memory)
{
return _guardians.values();
}

/**
* @inheritdoc ILSP11BasicSocialRecovery
*/
function isGuardian(address _address) public view virtual returns (bool) {
function isGuardian(
address _address
) public view virtual override returns (bool) {
return _guardians.contains(_address);
}

/**
* @inheritdoc ILSP11BasicSocialRecovery
*/
function getGuardiansThreshold() public view virtual returns (uint256) {
function getGuardiansThreshold()
public
view
virtual
override
returns (uint256)
{
return _guardiansThreshold;
}

/**
* @inheritdoc ILSP11BasicSocialRecovery
*/
function getRecoverySecretHash() public view virtual returns (bytes32) {
function getRecoverySecretHash()
public
view
virtual
override
returns (bytes32)
{
return _recoverySecretHash;
}

Expand All @@ -129,14 +155,16 @@ abstract contract LSP11BasicSocialRecoveryCore is
*/
function getGuardianChoice(
address guardian
) public view virtual returns (address) {
) public view virtual override returns (address) {
return _guardiansChoice[_recoveryCounter][guardian];
}

/**
* @inheritdoc ILSP11BasicSocialRecovery
*/
function addGuardian(address newGuardian) public virtual onlyOwner {
function addGuardian(
address newGuardian
) public virtual override onlyOwner {
if (_guardians.contains(newGuardian))
revert GuardianAlreadyExist(newGuardian);

Expand All @@ -147,7 +175,9 @@ abstract contract LSP11BasicSocialRecoveryCore is
/**
* @inheritdoc ILSP11BasicSocialRecovery
*/
function removeGuardian(address existingGuardian) public virtual onlyOwner {
function removeGuardian(
address existingGuardian
) public virtual override onlyOwner {
if (!_guardians.contains(existingGuardian))
revert GuardianDoNotExist(existingGuardian);
if (_guardians.length() == _guardiansThreshold)
Expand All @@ -162,7 +192,7 @@ abstract contract LSP11BasicSocialRecoveryCore is
*/
function setGuardiansThreshold(
uint256 newThreshold
) public virtual onlyOwner {
) public virtual override onlyOwner {
if (newThreshold > _guardians.length())
revert ThresholdCannotBeHigherThanGuardiansNumber(
newThreshold,
Expand All @@ -179,7 +209,7 @@ abstract contract LSP11BasicSocialRecoveryCore is
*/
function setRecoverySecretHash(
bytes32 newRecoverSecretHash
) public virtual onlyOwner {
) public virtual override onlyOwner {
if (newRecoverSecretHash == bytes32(0)) revert SecretHashCannotBeZero();

_recoverySecretHash = newRecoverSecretHash;
Expand All @@ -191,7 +221,7 @@ abstract contract LSP11BasicSocialRecoveryCore is
*/
function selectNewController(
address addressSelected
) public virtual onlyGuardians {
) public virtual override onlyGuardians {
uint256 currentRecoveryCounter = _recoveryCounter;

_guardiansChoice[currentRecoveryCounter][msg.sender] = addressSelected;
Expand All @@ -209,7 +239,7 @@ abstract contract LSP11BasicSocialRecoveryCore is
address recoverer,
string memory plainSecret,
bytes32 newSecretHash
) public virtual {
) public virtual override {
// caching storage variables
uint256 currentRecoveryCounter = _recoveryCounter;
address[] memory guardians = _guardians.values();
Expand Down
4 changes: 2 additions & 2 deletions contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
*
* @custom:info If no ownership transfer is in progress, the pendingOwner will be `address(0).`.
*/
function pendingOwner() public view virtual returns (address) {
function pendingOwner() public view virtual override returns (address) {
return _pendingOwner;
}

Expand Down Expand Up @@ -110,7 +110,7 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
*
* @custom:requirements This function can only be called by the {pendingOwner()}.
*/
function acceptOwnership() public virtual NotInTransferOwnership {
function acceptOwnership() public virtual override NotInTransferOwnership {
address previousOwner = owner();

_acceptOwnership();
Expand Down
2 changes: 1 addition & 1 deletion contracts/LSP17Extensions/Extension4337.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.9;
pragma solidity ^0.8.12;

// interfaces
import {IAccount} from "@account-abstraction/contracts/interfaces/IAccount.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
function universalReceiver(
bytes32 typeId,
bytes memory /* data */
) public payable virtual returns (bytes memory) {
) public payable virtual override returns (bytes memory) {
// CHECK that we did not send any native tokens to the LSP1 Delegate, as it cannot transfer them back.
if (msg.value != 0) {
revert NativeTokensNotAccepted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
function universalReceiver(
bytes32 typeId,
bytes memory /* data */
) public payable virtual returns (bytes memory) {
) public payable virtual override returns (bytes memory) {
// CHECK that we did not send any native tokens to the LSP1 Delegate, as it cannot transfer them back.
if (msg.value != 0) {
revert NativeTokensNotAccepted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ contract LSP23LinkedContractsFactory is ILSP23LinkedContractsFactory {
)
public
payable
override
returns (
address primaryContractAddress,
address secondaryContractAddress
Expand Down Expand Up @@ -81,6 +82,7 @@ contract LSP23LinkedContractsFactory is ILSP23LinkedContractsFactory {
)
public
payable
override
returns (
address primaryContractAddress,
address secondaryContractAddress
Expand Down Expand Up @@ -140,6 +142,7 @@ contract LSP23LinkedContractsFactory is ILSP23LinkedContractsFactory {
)
public
view
override
returns (
address primaryContractAddress,
address secondaryContractAddress
Expand Down Expand Up @@ -187,6 +190,7 @@ contract LSP23LinkedContractsFactory is ILSP23LinkedContractsFactory {
)
public
view
override
returns (
address primaryContractAddress,
address secondaryContractAddress
Expand Down
18 changes: 9 additions & 9 deletions contracts/LSP6KeyManager/LSP6KeyManagerCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ abstract contract LSP6KeyManagerCore is
/**
* @inheritdoc ILSP6
*/
function target() public view returns (address) {
function target() public view override returns (address) {
return _target;
}

Expand Down Expand Up @@ -136,7 +136,7 @@ abstract contract LSP6KeyManagerCore is
function getNonce(
address from,
uint128 channelId
) public view virtual returns (uint256) {
) public view virtual override returns (uint256) {
return LSP25MultiChannelNonce._getNonce(from, channelId);
}

Expand All @@ -151,7 +151,7 @@ abstract contract LSP6KeyManagerCore is
function isValidSignature(
bytes32 dataHash,
bytes memory signature
) public view virtual returns (bytes4 magicValue) {
) public view virtual override returns (bytes4 magicValue) {
// if isValidSignature fail, the error is catched in returnedError
(address recoveredAddress, ECDSA.RecoverError returnedError) = ECDSA
.tryRecover(dataHash, signature);
Expand All @@ -177,7 +177,7 @@ abstract contract LSP6KeyManagerCore is
*/
function execute(
bytes calldata payload
) public payable virtual returns (bytes memory) {
) public payable virtual override returns (bytes memory) {
return _execute(msg.value, payload);
}

Expand All @@ -189,7 +189,7 @@ abstract contract LSP6KeyManagerCore is
function executeBatch(
uint256[] calldata values,
bytes[] calldata payloads
) public payable virtual returns (bytes[] memory) {
) public payable virtual override returns (bytes[] memory) {
if (values.length != payloads.length) {
revert BatchExecuteParamsLengthMismatch();
}
Expand Down Expand Up @@ -237,7 +237,7 @@ abstract contract LSP6KeyManagerCore is
uint256 nonce,
uint256 validityTimestamps,
bytes calldata payload
) public payable virtual returns (bytes memory) {
) public payable virtual override returns (bytes memory) {
return
_executeRelayCall(
signature,
Expand Down Expand Up @@ -267,7 +267,7 @@ abstract contract LSP6KeyManagerCore is
uint256[] calldata validityTimestamps,
uint256[] calldata values,
bytes[] calldata payloads
) public payable virtual returns (bytes[] memory) {
) public payable virtual override returns (bytes[] memory) {
if (
signatures.length != nonces.length ||
nonces.length != validityTimestamps.length ||
Expand Down Expand Up @@ -323,7 +323,7 @@ abstract contract LSP6KeyManagerCore is
address caller,
uint256 msgValue,
bytes calldata data
) external virtual returns (bytes4) {
) external virtual override returns (bytes4) {
bool isSetData = bytes4(data) == IERC725Y.setData.selector ||
bytes4(data) == IERC725Y.setDataBatch.selector;

Expand Down Expand Up @@ -373,7 +373,7 @@ abstract contract LSP6KeyManagerCore is
function lsp20VerifyCallResult(
bytes32 /*callHash*/,
bytes memory /*result*/
) external virtual returns (bytes4) {
) external virtual override returns (bytes4) {
// If it's the target calling, set back the reentrancy guard
// to false, if not return the magic value
if (msg.sender == _target) {
Expand Down
Loading
Loading