Skip to content

Commit

Permalink
rename loupe function
Browse files Browse the repository at this point in the history
  • Loading branch information
adamegyed committed May 31, 2024
1 parent c8d2b45 commit 6d48a68
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
14 changes: 10 additions & 4 deletions src/account/AccountLoupe.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract contract AccountLoupe is IAccountLoupe {
using EnumerableSet for EnumerableSet.AddressSet;

/// @inheritdoc IAccountLoupe
function getExecutionFunctionHandler(bytes4 selector) external view returns (address plugin) {
function getExecutionFunctionHandler(bytes4 selector) external view override returns (address plugin) {
AccountStorage storage _storage = getAccountStorage();

if (
Expand All @@ -36,12 +36,17 @@ abstract contract AccountLoupe is IAccountLoupe {
}

/// @inheritdoc IAccountLoupe
function getValidationFunctions(bytes4 selector) external view returns (FunctionReference[] memory) {
function getValidations(bytes4 selector) external view override returns (FunctionReference[] memory) {
return toFunctionReferenceArray(getAccountStorage().selectorData[selector].validations);
}

/// @inheritdoc IAccountLoupe
function getExecutionHooks(bytes4 selector) external view returns (ExecutionHook[] memory execHooks) {
function getExecutionHooks(bytes4 selector)
external
view
override
returns (ExecutionHook[] memory execHooks)
{
SelectorData storage selectorData = getAccountStorage().selectorData[selector];
uint256 executionHooksLength = selectorData.executionHooks.length();

Expand All @@ -58,14 +63,15 @@ abstract contract AccountLoupe is IAccountLoupe {
function getPreValidationHooks(bytes4 selector)
external
view
override
returns (FunctionReference[] memory preValidationHooks)
{
preValidationHooks =
toFunctionReferenceArray(getAccountStorage().selectorData[selector].preValidationHooks);
}

/// @inheritdoc IAccountLoupe
function getInstalledPlugins() external view returns (address[] memory pluginAddresses) {
function getInstalledPlugins() external view override returns (address[] memory pluginAddresses) {
pluginAddresses = getAccountStorage().plugins.values();
}
}
2 changes: 1 addition & 1 deletion src/interfaces/IAccountLoupe.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface IAccountLoupe {
/// @notice Get the validation functions for a selector.
/// @param selector The selector to get the validation functions for.
/// @return The validation functions for this selector.
function getValidationFunctions(bytes4 selector) external view returns (FunctionReference[] memory);
function getValidations(bytes4 selector) external view returns (FunctionReference[] memory);

/// @notice Get the pre and post execution hooks for a selector.
/// @param selector The selector to get the hooks for.
Expand Down
4 changes: 2 additions & 2 deletions test/account/AccountLoupe.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ contract AccountLoupeTest is AccountTestBase {
}

function test_pluginLoupe_getValidationFunctions() public {
FunctionReference[] memory validations = account1.getValidationFunctions(comprehensivePlugin.foo.selector);
FunctionReference[] memory validations = account1.getValidations(comprehensivePlugin.foo.selector);

assertEq(validations.length, 1);
assertEq(
Expand All @@ -89,7 +89,7 @@ contract AccountLoupeTest is AccountTestBase {
)
);

validations = account1.getValidationFunctions(account1.execute.selector);
validations = account1.getValidations(account1.execute.selector);

assertEq(validations.length, 1);
assertEq(FunctionReference.unwrap(validations[0]), FunctionReference.unwrap(ownerValidation));
Expand Down
3 changes: 1 addition & 2 deletions test/account/MultiValidation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ contract MultiValidationTest is AccountTestBase {
);
validations[1] =
FunctionReferenceLib.pack(address(validator2), uint8(ISingleOwnerPlugin.FunctionId.VALIDATION_OWNER));
FunctionReference[] memory validations2 =
account1.getValidationFunctions(IStandardExecutor.execute.selector);
FunctionReference[] memory validations2 = account1.getValidations(IStandardExecutor.execute.selector);
assertEq(validations2.length, 2);
assertEq(FunctionReference.unwrap(validations2[0]), FunctionReference.unwrap(validations[0]));
assertEq(FunctionReference.unwrap(validations2[1]), FunctionReference.unwrap(validations[1]));
Expand Down

0 comments on commit 6d48a68

Please sign in to comment.