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

Document API Decisions for Module Registration #124

Open
nlordell opened this issue Oct 25, 2023 · 0 comments
Open

Document API Decisions for Module Registration #124

nlordell opened this issue Oct 25, 2023 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@nlordell
Copy link
Collaborator

nlordell commented Oct 25, 2023

Currently, module registration in the SafeProtocolRegistry and plugin permissions in the SafeProtocolManager use uint8 constants for specifying bitflags.

This issue captures some of the work to both document and re-evaluate the APIs to ensure that they are optimised for their uses:

  • The assumption is that module registration will mostly be initiated off-chain, which means that it might make sense to consider using Solidity enums as they have better integration with things like Ethers, TypeChain, etc.
  • The assumption is that check calls on modules would be called on-chain, where bitflags are more natural to use with constants instead of enums. In that case, the API should probably be implemented as it currently is in function of uint8 constants.

We should also consider whether it is worth having a higher API surface (i.e. support both enums and bitflags simultaneously) which increases cognitive load when trying to understand the interface.

On-Chain Usage of Enums vs Constants:

enum ModuleType {
  Plugin,
  Hook,
}

// usage:
ModuleType[] memory types = new ModuleType[](2);
types[0] = ModuleType.Plugin;
types[1] = ModuleType.Hook;
library ModuleTypes {
    uint8 constant PLUGIN = 1;
    uint8 constant HOOK = 2;
}

// usage:
uint8 types = ModuleTypes.PLUGIN | ModuleTypes.HOOK;
@nlordell nlordell added the documentation Improvements or additions to documentation label Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant