Skip to content

Commit

Permalink
FIX: eliminate squad and switch to safe in all contracts, comments an…
Browse files Browse the repository at this point in the history
…d test
  • Loading branch information
alfredolopez80 committed May 22, 2024
1 parent e3dc3b9 commit f0efa12
Show file tree
Hide file tree
Showing 29 changed files with 2,678 additions and 2,766 deletions.
318 changes: 159 additions & 159 deletions .gas-snapshot

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PalmeraModule - Safe module for Palmera

This contract is a registry of palmera organization/squads setup on a Safe that can be used by specific accounts. For this the contract needs to be enabled as a module on the Safe that holds the assets that should be transferred.
This contract is a registry of palmera organisation/safes setup on a Safe that can be used by specific accounts. For this the contract needs to be enabled as a module on the Safe that holds the assets that should be transferred.

## Tech requirements

Expand Down Expand Up @@ -48,7 +48,7 @@ Execute the command `deploy-module` located in the Makefile

Execute the command `deploy-new-safe` located in the Makefile

## Setting up a DAO
## Setting up a On-chain Organisation

All the following calls have to be executed from a safe using safe execTransation function. Check documentation https://safe-docs.dev.gnosisdev.com/safe/docs/contracts_tx_execution/

Expand All @@ -58,31 +58,31 @@ All the following calls have to be executed from a safe using safe execTransatio

The address of the calling safe is going to be registered with the input name

# Add Subsquads to main organisation
# Add Subsafes to main organisation

`function addSquad(address org, address superSafe, string memory name)`
`function addSafe(address org, address superSafe, string memory name)`

Need to specify to which organisation the new squad will belong
Need to specify to which organisation the new safe will belong

## Requirements (not finalized)

Organization=Safe Root has multiple squads
Squads/Safe relationship
Organisation=Safe Root has multiple safes
Safes/Safe relationship

- Each squad is associated to a safe
- Each squad has a superSafe (superSafe has ownership over the squad)
- Each squad has set of child
- Each safe is associated to a safe
- Each safe has a superSafe (superSafe has ownership over the safe)
- Each safe has set of child

Validate transfer rules - execTransactionFromModule:

- Safe signers can execute transactions if threshold met (normal safe verification)
- Safe squad signers can execute transactions in behalf of any child safe
- Squad threshold kept
- Safe safe signers can execute transactions in behalf of any child safe
- Safe threshold kept

Setup squads rules:
Setup safes rules:

- Root lead has full control over all squads (or over all squads that he is a designed lead?)
=> Remove/Add squads.
- Root lead has full control over all safes (or over all safes that he is a designed lead?)
=> Remove/Add safes.
=> Remove/Add signers of any child safe
- Each squad has a designed lead (full ownership of the safe)
- Each safe has a designed lead (full ownership of the safe)
- Can an lead be something different than a Safe contract?
52 changes: 26 additions & 26 deletions lcov.info
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,16 @@ DA:353,125
DA:354,125
DA:356,125
DA:358,125
FN:365,PalmeraModule.createRootSafeSquad
FNDA:22,PalmeraModule.createRootSafeSquad
FN:365,PalmeraModule.createRootSafe
FNDA:22,PalmeraModule.createRootSafe
DA:372,22
DA:373,22
DA:374,22
DA:375,22
DA:377,22
DA:379,22
FN:388,PalmeraModule.addSquad
FNDA:297,PalmeraModule.addSquad
FN:388,PalmeraModule.addSafe
FNDA:297,PalmeraModule.addSafe
DA:395,295
BRDA:395,12,0,-
BRDA:395,12,1,295
Expand Down Expand Up @@ -367,8 +367,8 @@ BRDA:424,16,0,-
BRDA:424,16,1,139
DA:431,139
DA:436,290
FN:444,PalmeraModule.removeSquad
FNDA:20,PalmeraModule.removeSquad
FN:444,PalmeraModule.removeSafe
FNDA:20,PalmeraModule.removeSafe
DA:449,27
DA:450,27
DA:451,27
Expand Down Expand Up @@ -568,8 +568,8 @@ FNDA:1,PalmeraModule.disableDenyHelper
DA:782,1
DA:783,1
DA:784,1
FN:793,PalmeraModule.getSquadInfo
FNDA:43,PalmeraModule.getSquadInfo
FN:793,PalmeraModule.getSafeInfo
FNDA:43,PalmeraModule.getSafeInfo
DA:806,41
DA:807,41
FN:821,PalmeraModule.hasNotPermissionOverTarget
Expand Down Expand Up @@ -656,8 +656,8 @@ DA:951,73
BRDA:951,54,0,15
BRDA:951,54,1,58
DA:952,58
FN:959,PalmeraModule.getSquadSafeAddress
FNDA:242,PalmeraModule.getSquadSafeAddress
FN:959,PalmeraModule.getSafeAddress
FNDA:242,PalmeraModule.getSafeAddress
DA:965,242
DA:966,242
FN:972,PalmeraModule.getOrgHashBySafe
Expand All @@ -668,8 +668,8 @@ BRDA:974,55,0,-
BRDA:974,55,1,1864
DA:975,1864
DA:978,473
FN:985,PalmeraModule.getSquadIdBySafe
FNDA:385,PalmeraModule.getSquadIdBySafe
FN:985,PalmeraModule.getSafeIdBySafe
FNDA:385,PalmeraModule.getSafeIdBySafe
DA:990,4139
BRDA:990,56,0,1
BRDA:990,56,1,4138
Expand All @@ -680,8 +680,8 @@ BRDA:995,57,0,-
BRDA:995,57,1,3341
DA:996,3341
DA:999,797
FN:1006,PalmeraModule.getOrgBySquad
FNDA:72,PalmeraModule.getOrgBySquad
FN:1006,PalmeraModule.getOrgBySafe
FNDA:72,PalmeraModule.getOrgBySafe
DA:1011,2639
BRDA:1011,58,0,2
BRDA:1011,58,1,2637
Expand Down Expand Up @@ -761,8 +761,8 @@ DA:1131,30
BRDA:1130,69,0,-
BRDA:1130,69,1,-
DA:1135,0
FN:1144,PalmeraModule.removeIndexSquad
FNDA:23,PalmeraModule.removeIndexSquad
FN:1144,PalmeraModule.removeIndexSafe
FNDA:23,PalmeraModule.removeIndexSafe
DA:1145,23
DA:1146,50
BRDA:1146,70,0,-
Expand Down Expand Up @@ -1039,8 +1039,8 @@ FN:14,PalmeraSafeBuilder.setUpParams
FNDA:0,PalmeraSafeBuilder.setUpParams
DA:18,0
DA:19,0
FN:26,PalmeraSafeBuilder.setupRootOrgAndOneSquad
FNDA:46,PalmeraSafeBuilder.setupRootOrgAndOneSquad
FN:26,PalmeraSafeBuilder.setupRootOrgAndOneSafe
FNDA:46,PalmeraSafeBuilder.setupRootOrgAndOneSafe
DA:31,121
DA:32,121
DA:34,121
Expand All @@ -1051,8 +1051,8 @@ DA:40,121
DA:42,121
DA:43,121
DA:45,121
FN:52,PalmeraSafeBuilder.setupRootWithTwoSquads
FNDA:1,PalmeraSafeBuilder.setupRootWithTwoSquads
FN:52,PalmeraSafeBuilder.setupRootWithTwoSafes
FNDA:1,PalmeraSafeBuilder.setupRootWithTwoSafes
DA:57,1
DA:59,1
DA:62,1
Expand All @@ -1061,8 +1061,8 @@ DA:66,1
DA:67,1
DA:68,1
DA:70,1
FN:77,PalmeraSafeBuilder.setupTwoRootOrgWithOneSquadEach
FNDA:12,PalmeraSafeBuilder.setupTwoRootOrgWithOneSquadEach
FN:77,PalmeraSafeBuilder.setupTwoRootOrgWithOneSafeEach
FNDA:12,PalmeraSafeBuilder.setupTwoRootOrgWithOneSafeEach
DA:91,22
DA:93,22
DA:96,22
Expand All @@ -1076,8 +1076,8 @@ DA:109,22
DA:110,22
DA:111,22
DA:113,22
FN:122,PalmeraSafeBuilder.setupTwoRootOrgWithOneSquadAndOneChildEach
FNDA:10,PalmeraSafeBuilder.setupTwoRootOrgWithOneSquadAndOneChildEach
FN:122,PalmeraSafeBuilder.setupTwoRootOrgWithOneSafeAndOneChildEach
FNDA:10,PalmeraSafeBuilder.setupTwoRootOrgWithOneSafeAndOneChildEach
DA:140,10
DA:144,10
DA:145,10
Expand All @@ -1090,8 +1090,8 @@ DA:154,10
DA:155,10
DA:156,10
DA:158,10
FN:174,PalmeraSafeBuilder.setupTwoOrgWithOneRootOneSquadAndOneChildEach
FNDA:5,PalmeraSafeBuilder.setupTwoOrgWithOneRootOneSquadAndOneChildEach
FN:174,PalmeraSafeBuilder.setupTwoOrgWithOneRootOneSafeAndOneChildEach
FNDA:5,PalmeraSafeBuilder.setupTwoOrgWithOneRootOneSafeAndOneChildEach
DA:192,5
DA:194,5
DA:196,5
Expand Down
6 changes: 3 additions & 3 deletions libraries/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ library Constants {
bytes4(keccak256(bytes("setRole(uint8,address,uint256,bool)")));

bytes4 internal constant CREATE_ROOT_SAFE =
bytes4(keccak256(bytes("createRootSafeSquad(address,string)")));
bytes4(keccak256(bytes("createRootSafe(address,string)")));

bytes4 internal constant ENABLE_ALLOWLIST =
bytes4(keccak256(bytes("enableAllowlist()")));
Expand Down Expand Up @@ -73,8 +73,8 @@ library Constants {
)
);

bytes4 internal constant REMOVE_SQUAD =
bytes4(keccak256(bytes("removeSquad(uint256)")));
bytes4 internal constant REMOVE_SAFE =
bytes4(keccak256(bytes("removeSafe(uint256)")));

bytes4 internal constant REMOVE_WHOLE_TREE =
bytes4(keccak256(bytes("removeWholeTree()")));
Expand Down
20 changes: 10 additions & 10 deletions libraries/DataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ library DataTypes {
SUPER_SAFE,
ROOT_SAFE
}
/// @dev typos of squads into Palmera Modules
/// @dev typos of safes into Palmera Modules
enum Tier {
SQUAD, // 0
safe, // 0
ROOT, // 1
REMOVED // 2
}
/// @devStruct for Squad
/// @param tier Kind of the squad (at the momento only squad or ROOT)
/// @param name String name of the squad (any tier of squad)
/// @param lead Address of Safe Lead of the squad (Safe Lead Role)
/// @param safe Address of Safe of the squad (Safe Role)
/// @param child Array of ID's members of the squad
/// @param superSafe ID of Superior Squad (superSafe Role)
struct Squad {
/// @devStruct for Safe
/// @param tier Kind of the safe (at the momento only safe or ROOT)
/// @param name String name of the safe (any tier of safe)
/// @param lead Address of Safe Lead of the safe (Safe Lead Role)
/// @param safe Address of Safe Wallet (Safe Role)
/// @param child Array of ID's members of the safe
/// @param superSafe ID of Superior Safe (superSafe Role)
struct Safe {
Tier tier;
string name;
address lead;
Expand Down
40 changes: 19 additions & 21 deletions libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,39 @@ import {DataTypes} from "./DataTypes.sol";
library Errors {
/// @notice Error codes for the Palmera module
/// @dev Errors Palmera Modules
/// @dev Error messages when the Org Hash (Dao's name) is not Registered
/// @dev Error messages when the Org Hash (On-chain Organisation) is not Registered
error OrgNotRegistered(bytes32 org);
/// @dev Error messages when the Squad(`squad`) is not Registered
error SquadNotRegistered(uint256 squad);
/// @dev Error messages when the Super safe Squad(`superSafe`) is not Registered
/// @dev Error messages when the Safe(`safe`) is not Registered
error SafeIdNotRegistered(uint256 safe);
/// @dev Error messages when the Super Safe(`superSafe`) is not Registered
error SuperSafeNotRegistered(uint256 superSafe);
/// @dev Error messages when the Safe(`safe`) is not Registered
error SafeNotRegistered(address safe);
/// @dev Error messages when the Safe is not Autorized to Add Owner like Lead/Super/Root Safe
error NotAuthorizedAddOwnerWithThreshold();
/// @dev Error messages when the Safe is not Autorized to Remove Owner like Lead/Safe/Root Safe
error NotAuthorizedRemoveSquadFromOtherTree();
error NotAuthorizedRemoveSquadFromOtherOrg();
/// @dev Error messages when the Safe is not Autorized to Remove Owner like Lead/Root Safe or Safe itself
error NotAuthorizedRemoveSafeFromOtherTree();
error NotAuthorizedRemoveSafeFromOtherOrg();
error NotAuthorizedRemoveOwner();
error NotAuthorizedExecOnBehalf();
error NotAuthorizedUpdateSquadToOtherOrg();
/// @dev Error messages when try to disconnect Safe before remove it, and show the Safe's children Squad Id's
error NotAuthorizedUpdateSafeToOtherOrg();
/// @dev Error messages when try to disconnect Safe before remove it, and show the Safe's children Safe Id's
error CannotDisconnectedSafeBeforeRemoveChild(uint256 children);
/// @dev Error messages when try to remove Squad before remove it's children, and show the Squad's children Squad Id's
error CannotRemoveSquadBeforeRemoveChild(uint256 children);
/// @dev Error messages when try to remove Safe before remove it's children, and show the Safe's children Safe Id's
error CannotRemoveSafeBeforeRemoveChild(uint256 children);
error CannotDisablePalmeraModule(address module);
error CannotDisablePalmeraGuard(address guard);
error SquadAlreadyRemoved();
error SafeAlreadyRemoved();
/// @dev Error messages when the Caller is not Autorized to execute any action like Lead Safe
error NotAuthorizedAsNotSafeLead();
/// @dev Error messages when the Caller is not Autorized to execute any action like Super Safe
error NotAuthorizedAsNotRootOrSuperSafe();
/// @dev Error messages when the Root Safe is not Autorized Update Super Safe for a Squad in Another Tree
error NotAuthorizedUpdateNonChildrenSquad();
/// @dev Error messages when the Root Safe is not Autorized Update Super Safe for a Safe in Another Tree
error NotAuthorizedUpdateNonChildrenSafe();
error NotAuthorizedUpdateNonSuperSafe();
/// @dev Error messages when the Root Safe is not Autorized to Disconnect an Safe in Another Tree
error NotAuthorizedDisconnectChildrenSquad();
/// @dev Error messages when the Root Safe is not Autorized to Update a Role in a Squad in Another Tree
error NotAuthorizedDisconnectChildrenSafe();
/// @dev Error messages when the Root Safe is not Autorized to Update a Role in a Safe in Another Tree
error NotAuthorizedSetRoleAnotherTree();
/// @dev Error messages the Owner is not Found into the Safe Owners
error OwnerNotFound();
Expand All @@ -52,21 +52,19 @@ library Errors {
error InvalidThreshold();
/// @dev Error messages when Try to Execute a Transaction On Behalf and Fail
error TxExecutionModuleFailed();
error PreviewModuleNotFound(address squad);
error PreviewModuleNotFound(address safe);
/// @dev Error messages when Try to Execute a Transaction On Behalf and Fail
error TxOnBehalfExecutedFailed();
/// @dev Error messages when the caller is an Invalid Safe
error InvalidSafe(address safe);
/// @dev Error messages when the caller is an Invalid Root Safe
error InvalidRootSafe(address safe);
/// @dev Error messages when the Squad is an Invalid ID's
error InvalidSquadId();
/// @dev Error messages when the Safe is an Invalid ID's
error InvalidSafeId();
/// @dev Error messages when the Try to Modify a Role Not Permitted
error SetRoleForbidden(DataTypes.Role role);
/// @dev Error messages when Org Already Registered
error OrgAlreadyRegistered(bytes32 safe);
/// @dev Error messages when Squad Already Registered
error SquadAlreadyRegistered();
/// @dev Error messages when Safe Already Registered
error SafeAlreadyRegistered(address safe);
/// @dev Error messages when the String Name is Empty
Expand Down
Loading

0 comments on commit f0efa12

Please sign in to comment.