Skip to content

Commit

Permalink
Add selector getter function to module
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnGuilding committed Jun 18, 2024
1 parent 5fbedbf commit c9aaa0d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/interfaces/IRecoveryModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ interface IRecoveryModule {
function recover(address account, bytes memory recoveryCalldata) external;
function getTrustedRecoveryManager() external returns (address);
function getAllowedValidators(address account) external view returns (address[] memory);
function getAllowedSelectors(address account) external view returns (bytes4[] memory);
}
19 changes: 16 additions & 3 deletions src/modules/EmailRecoveryModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,27 @@ contract EmailRecoveryModule is ERC7579ExecutorBase, IRecoveryModule {
return emailRecoveryManager;
}

function getAllowedValidators(address account) external view returns (address[] memory) {
function getAllowedValidators(address account) public view returns (address[] memory) {
ValidatorList storage validatorList = validators[account];

// getEntriesPaginated pageCount cannot be zero
uint256 pageCount = validatorList.count == 0 ? 1 : validatorList.count;
(address[] memory array,) =
(address[] memory allowedValidators,) =
validatorList.validators.getEntriesPaginated(SENTINEL, pageCount);
return array;

return allowedValidators;
}

function getAllowedSelectors(address account) external view returns (bytes4[] memory) {
address[] memory allowedValidators = getAllowedValidators(account);
uint256 allowedValidatorsLength = allowedValidators.length;

bytes4[] memory selectors = new bytes4[](allowedValidatorsLength);
for (uint256 i; i < allowedValidatorsLength; i++) {
selectors[i] = allowedSelectors[allowedValidators[i]][account];
}

return selectors;
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit c9aaa0d

Please sign in to comment.