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

[DRAFT] refactor/SMA: Inheritable Account Refactor #133

Merged

Conversation

Zer0dot
Copy link
Contributor

@Zer0dot Zer0dot commented Aug 7, 2024

Motivation

This PR introduces a refactor that adds overridable functions to validation calls to make SMAs easier to develop, review, and audit, as well as to isolate the core contract from SMAs.

This way, creating an SMA with custom validation logic is as simple as inheriting from the parent modular account.

Solution

Add internal virtual functions wrapping validation module calls. These can then be overriden in an inheriting contract to implement custom validation logic, as is done with an SMA here.

This also involved a test refactor to leverage the same test suite for both the inheriting and original accounts. This uses a new environment boolean variable "SMA_TEST," which is true if the test suite should be run for the SMA.

This variable is then read in certain places where logic that is different between SMAs and the parent modular account is needed. Mainly, initializing with a validation, creating an account, or affecting the single signer validation (which is built-in for the SMA).

TODO

  • Lint everything
  • Evaluate if there's a better way to handle testing both implementations (other than making a script to run the test suite twice for each contract, but we could do that too!)
  • Add comments and documentation where tests branch between SMA/RI
  • Revisit factory, potentially split it into a separate factory for each implementation
  • Handle upstream PR

@Zer0dot Zer0dot changed the title Zer0dot/inheritable account [DRAFT] refactor/SMA: Inheritable Account Refactor Aug 7, 2024
@Zer0dot Zer0dot force-pushed the zer0dot/sma-fallback-bytecode-signer branch from 5d739e9 to 11c90e5 Compare August 7, 2024 18:14
@Zer0dot Zer0dot force-pushed the zer0dot/inheritable-account branch 3 times, most recently from 45cce9b to fdd8baf Compare August 7, 2024 18:30
@Zer0dot Zer0dot force-pushed the zer0dot/inheritable-account branch from fdd8baf to d5290d6 Compare August 7, 2024 19:51
@Zer0dot Zer0dot marked this pull request as ready for review August 12, 2024 17:34
@Zer0dot Zer0dot merged commit e5f881a into zer0dot/sma-fallback-bytecode-signer Aug 12, 2024
3 checks passed
@Zer0dot Zer0dot deleted the zer0dot/inheritable-account branch August 12, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant