-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from keyper-labs/feature/reduce-bytesize-code
Reduce byteSize Code and Fix override of deepTreeLimit when Create a New rootSafe (issue 49)
- Loading branch information
Showing
5 changed files
with
15 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,15 +11,13 @@ import { | |
DataTypes, | ||
Events, | ||
Address, | ||
GnosisSafeMath, | ||
Enum, | ||
ISafe | ||
} from "./Helpers.sol"; | ||
|
||
/// @title Palmera Module | ||
/// @custom:security-contact [email protected] | ||
contract PalmeraModule is Auth, Helpers { | ||
using GnosisSafeMath for uint256; | ||
using Address for address; | ||
|
||
/// @dev Definition of Safe Palmera Module | ||
|
@@ -334,8 +332,6 @@ contract PalmeraModule is Auth, Helpers { | |
bytes32 org = getOrgHashBySafe(caller); | ||
uint256 newIndex = indexId; | ||
safeId = _createOrgOrRoot(name, caller, newRootSafe); | ||
// Setting level by default | ||
depthTreeLimit[org] = 8; | ||
|
||
emit Events.RootSafeCreated(org, newIndex, caller, newRootSafe, name); | ||
} | ||
|
@@ -384,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 | ||
|
@@ -423,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); | ||
} | ||
|
@@ -727,7 +723,7 @@ contract PalmeraModule is Auth, Helpers { | |
address prevUser = getPrevUser(org, user); | ||
listed[org][prevUser] = listed[org][user]; | ||
listed[org][user] = address(0); | ||
listCount[org] = listCount[org] > 1 ? listCount[org].sub(1) : 0; | ||
listCount[org] = listCount[org] > 1 ? (listCount[org] - 1) : 0; | ||
emit Events.DroppedFromList(user); | ||
} | ||
|
||
|
@@ -967,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; | ||
|
@@ -1118,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 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters