diff --git a/src/PalmeraModule.sol b/src/PalmeraModule.sol index 5bb6e1a..ac5035f 100644 --- a/src/PalmeraModule.sol +++ b/src/PalmeraModule.sol @@ -380,7 +380,7 @@ contract PalmeraModule is Auth, Helpers { !_authority.doesUserHaveRole( superSafeOrgSafe.safe, uint8(DataTypes.Role.SUPER_SAFE) ) - ) && (superSafeOrgSafe.child.length > 0) + ) && (superSafeOrgSafe.child.length != 0) ) { _authority.setUserRole( superSafeOrgSafe.safe, uint8(DataTypes.Role.SUPER_SAFE), true @@ -419,7 +419,7 @@ contract PalmeraModule is Auth, Helpers { // Check if the safe is Root Safe and has child if ( ((_safe.tier == DataTypes.Tier.ROOT) || (_safe.superSafe == 0)) - && (_safe.child.length > 0) + && (_safe.child.length != 0) ) { revert Errors.CannotRemoveSafeBeforeRemoveChild(_safe.child.length); } @@ -963,9 +963,10 @@ contract PalmeraModule is Auth, Helpers { revert Errors.OrgNotRegistered(org); } /// Check if the Safe address is into an Safe mapping - for (uint256 i; i < indexSafe[org].length;) { - if (safes[org][indexSafe[org][i]].safe == safe) { - return indexSafe[org][i]; + uint256[] memory indexSafeOrg = indexSafe[org]; + for (uint256 i; i < indexSafeOrg.length;) { + if (safes[org][indexSafeOrg[i]].safe == safe) { + return indexSafeOrg[i]; } unchecked { ++i; @@ -1114,10 +1115,11 @@ contract PalmeraModule is Auth, Helpers { /// @param org ID's of the organisation /// @param safeId uint256 of the safe function removeIndexSafe(bytes32 org, uint256 safeId) private { - for (uint256 i; i < indexSafe[org].length;) { - if (indexSafe[org][i] == safeId) { - indexSafe[org][i] = indexSafe[org][indexSafe[org].length - 1]; - indexSafe[org].pop(); + uint256[] storage indexSafeOrg = indexSafe[org]; + for (uint256 i; i < indexSafeOrg.length;) { + if (indexSafeOrg[i] == safeId) { + indexSafeOrg[i] = indexSafeOrg[indexSafeOrg.length - 1]; + indexSafeOrg.pop(); break; } unchecked { diff --git a/src/SigningUtils.sol b/src/SigningUtils.sol index abc4857..af4f8a3 100644 --- a/src/SigningUtils.sol +++ b/src/SigningUtils.sol @@ -1,7 +1,6 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity 0.8.23; -import {ECDSA} from "@openzeppelin/utils/cryptography/ECDSA.sol"; import {Enum} from "@safe-contracts/base/Executor.sol"; /// @title SigningUtils @@ -21,61 +20,4 @@ abstract contract SigningUtils { bytes signatures; } - // /** - // * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this - // * function returns the hash of the fully encoded EIP712 message for this domain. - // * - // * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: - // * - // * ```solidity - // * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( - // * keccak256("Mail(address to,string contents)"), - // * mailTo, - // * keccak256(bytes(mailContents)) - // * ))); - // * address signer = ECDSA.recover(digest, signature); - // * ``` - // */ - // function _hashTypedDataV4(bytes32 domainSeparator, bytes32 structHash) - // internal - // view - // virtual - // returns (bytes32) - // { - // return ECDSA.toTypedDataHash(domainSeparator, structHash); - // } - - // /** - // * @dev Given a transaction, it creates a hash of the transaction that can be signed - // * @param domainSeparatorSafe Hash of the Safe domain separator - // * @param safeTx Safe transaction - // * @return Hash of the transaction - // */ - // function createDigestExecTx( - // bytes32 domainSeparatorSafe, - // Transaction memory safeTx - // ) public view returns (bytes32) { - // bytes32 digest = _hashTypedDataV4( - // domainSeparatorSafe, - // keccak256( - // abi.encode( - // keccak256( - // "execTransaction(address to,uint256 value,bytes data,Enum.Operation operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,bytes signatures)" - // ), - // safeTx.to, - // safeTx.value, - // safeTx.data, - // safeTx.operation, - // safeTx.safeTxGas, - // safeTx.baseGas, - // safeTx.gasPrice, - // safeTx.gasToken, - // safeTx.refundReceiver, - // safeTx.signatures - // ) - // ) - // ); - - // return digest; - // } }