-
Notifications
You must be signed in to change notification settings - Fork 16
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 changes to support modular accounts #26
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,9 @@ abstract contract EmailAccountRecovery { | |
address public dkimAddr; | ||
address public emailAuthImplementationAddr; | ||
|
||
mapping(address account => string[][]) public acceptanceSubjectTemplates; | ||
mapping(address account => string[][]) public recoverySubjectTemplates; | ||
|
||
/// @notice Returns the address of the verifier contract. | ||
/// @dev This function is virtual and can be overridden by inheriting contracts. | ||
/// @return address The address of the verifier contract. | ||
|
@@ -40,7 +43,7 @@ abstract contract EmailAccountRecovery { | |
/// @notice Returns a two-dimensional array of strings representing the subject templates for an acceptance by a new guardian's. | ||
/// @dev This function is virtual and should be implemented by inheriting contracts to define specific acceptance subject templates. | ||
/// @return string[][] A two-dimensional array of strings, where each inner array represents a set of fixed strings and matchers for a subject template. | ||
function acceptanceSubjectTemplates() | ||
function getAcceptanceSubjectTemplates(address account) | ||
public | ||
view | ||
virtual | ||
|
@@ -49,20 +52,22 @@ abstract contract EmailAccountRecovery { | |
/// @notice Returns a two-dimensional array of strings representing the subject templates for email recovery. | ||
/// @dev This function is virtual and should be implemented by inheriting contracts to define specific recovery subject templates. | ||
/// @return string[][] A two-dimensional array of strings, where each inner array represents a set of fixed strings and matchers for a subject template. | ||
function recoverySubjectTemplates() | ||
function getRecoverySubjectTemplates(address account) | ||
public | ||
view | ||
virtual | ||
returns (string[][] memory); | ||
|
||
function acceptGuardian( | ||
address account, | ||
address guardian, | ||
uint templateIdx, | ||
bytes[] memory subjectParams, | ||
bytes32 emailNullifier | ||
) internal virtual; | ||
|
||
function processRecovery( | ||
address account, | ||
address guardian, | ||
uint templateIdx, | ||
bytes[] memory subjectParams, | ||
|
@@ -71,8 +76,7 @@ abstract contract EmailAccountRecovery { | |
|
||
/// @notice Completes the recovery process. | ||
/// @dev This function must be implemented by inheriting contracts to finalize the recovery process. | ||
function completeRecovery() external virtual; | ||
|
||
function completeRecovery(address account, bytes memory recoveryCalldata) external virtual; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haven't got the calldata construction in solidity working yet. Will aim to remove the |
||
/// @notice Computes the address for email auth contract using the CREATE2 opcode. | ||
/// @dev This function utilizes the `Create2` library to compute the address. The computation uses a provided account salt | ||
/// and the hash of the encoded ERC1967Proxy creation code concatenated with the encoded email auth contract implementation | ||
|
@@ -164,6 +168,7 @@ abstract contract EmailAccountRecovery { | |
/// @param emailAuthMsg The email auth message for the email send from the guardian. | ||
/// @param templateIdx The index of the subject template for acceptance, which should match with the subject in the given email auth message. | ||
function handleAcceptance( | ||
address account, | ||
EmailAuthMsg memory emailAuthMsg, | ||
uint templateIdx | ||
) external { | ||
|
@@ -193,16 +198,16 @@ abstract contract EmailAccountRecovery { | |
EmailAuth guardianEmailAuth = EmailAuth(address(proxy)); | ||
guardianEmailAuth.updateDKIMRegistry(dkim()); | ||
guardianEmailAuth.updateVerifier(verifier()); | ||
for (uint idx = 0; idx < acceptanceSubjectTemplates().length; idx++) { | ||
for (uint idx = 0; idx < acceptanceSubjectTemplates[account].length; idx++) { | ||
guardianEmailAuth.insertSubjectTemplate( | ||
computeAcceptanceTemplateId(idx), | ||
acceptanceSubjectTemplates()[idx] | ||
acceptanceSubjectTemplates[account][idx] | ||
); | ||
} | ||
for (uint idx = 0; idx < recoverySubjectTemplates().length; idx++) { | ||
for (uint idx = 0; idx < recoverySubjectTemplates[account].length; idx++) { | ||
guardianEmailAuth.insertSubjectTemplate( | ||
computeRecoveryTemplateId(idx), | ||
recoverySubjectTemplates()[idx] | ||
recoverySubjectTemplates[account][idx] | ||
); | ||
} | ||
|
||
|
@@ -211,6 +216,7 @@ abstract contract EmailAccountRecovery { | |
guardianEmailAuth.authEmail(emailAuthMsg); | ||
|
||
acceptGuardian( | ||
account, | ||
guardian, | ||
templateIdx, | ||
emailAuthMsg.subjectParams, | ||
|
@@ -224,6 +230,7 @@ abstract contract EmailAccountRecovery { | |
/// @param emailAuthMsg The email auth message for recovery. | ||
/// @param templateIdx The index of the subject template for recovery, which should match with the subject in the given email auth message. | ||
function handleRecovery( | ||
address account, | ||
EmailAuthMsg memory emailAuthMsg, | ||
uint templateIdx | ||
) external { | ||
|
@@ -250,6 +257,7 @@ abstract contract EmailAccountRecovery { | |
guardianEmailAuth.authEmail(emailAuthMsg); | ||
|
||
processRecovery( | ||
account, | ||
guardian, | ||
templateIdx, | ||
emailAuthMsg.subjectParams, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could also be stored in a registry. See zkemail/email-recovery#3
Need to think about how these are stored a bit more.