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

chore: cleanup function modifiers #239

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/handlers/ERC1271Handler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract contract ERC1271Handler is IERC1271Upgradeable, EIP712("Sso1271", "1.0.
function isValidSignature(
bytes32 signedHash,
bytes memory signatureAndValidator
) public view override returns (bytes4 magicValue) {
) external view override returns (bytes4 magicValue) {
(bytes memory signature, address validator) = SignatureDecoder.decodeSignatureNoHookData(signatureAndValidator);

bytes32 eip712Hash = _hashTypedDataV4(_ssoMessageHash(SsoMessage(signedHash)));
Expand Down Expand Up @@ -59,7 +59,7 @@ abstract contract ERC1271Handler is IERC1271Upgradeable, EIP712("Sso1271", "1.0.
return _SSO_MESSAGE_TYPEHASH;
}

function _ssoMessageHash(SsoMessage memory ssoMessage) internal pure returns (bytes32) {
function _ssoMessageHash(SsoMessage memory ssoMessage) private pure returns (bytes32) {
return keccak256(abi.encode(_SSO_MESSAGE_TYPEHASH, ssoMessage.signedHash));
}
}
8 changes: 4 additions & 4 deletions src/libraries/JsmnSolLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ library JsmnSolLib {
return (p, t);
}

function allocateToken(Parser memory parser, Token[] memory tokens) internal pure returns (bool, Token memory) {
function allocateToken(Parser memory parser, Token[] memory tokens) private pure returns (bool, Token memory) {
if (parser.toknext >= tokens.length) {
// no more space in tokens
return (false, tokens[tokens.length - 1]);
Expand All @@ -68,7 +68,7 @@ library JsmnSolLib {
return (true, token);
}

function fillToken(Token memory token, JsmnType jsmnType, uint256 start, uint256 end) internal pure {
function fillToken(Token memory token, JsmnType jsmnType, uint256 start, uint256 end) private pure {
token.jsmnType = jsmnType;
token.start = start;
token.startSet = true;
Expand All @@ -77,7 +77,7 @@ library JsmnSolLib {
token.size = 0;
}

function parseString(Parser memory parser, Token[] memory tokens, bytes memory s) internal pure returns (uint) {
function parseString(Parser memory parser, Token[] memory tokens, bytes memory s) private pure returns (uint) {
uint256 start = parser.pos;
bool success;
Token memory token;
Expand Down Expand Up @@ -122,7 +122,7 @@ library JsmnSolLib {
return RETURN_ERROR_PART;
}

function parsePrimitive(Parser memory parser, Token[] memory tokens, bytes memory s) internal pure returns (uint) {
function parsePrimitive(Parser memory parser, Token[] memory tokens, bytes memory s) private pure returns (uint) {
bool found = false;
uint256 start = parser.pos;
bool success;
Expand Down
6 changes: 3 additions & 3 deletions src/managers/HookManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ abstract contract HookManager is IHookManager, Auth {
}
}

function _addHook(bytes calldata hookAndData, bool isValidation) internal {
function _addHook(bytes calldata hookAndData, bool isValidation) private {
if (hookAndData.length < 20) {
revert Errors.EMPTY_HOOK_ADDRESS(hookAndData.length);
}
Expand Down Expand Up @@ -187,7 +187,7 @@ abstract contract HookManager is IHookManager, Auth {
emit AddHook(hookAddress);
}

function _removeHook(address hook, bool isValidation) internal {
function _removeHook(address hook, bool isValidation) private {
if (isValidation) {
_validationHooksLinkedList().remove(hook);
} else {
Expand Down Expand Up @@ -233,7 +233,7 @@ abstract contract HookManager is IHookManager, Auth {
hookDataStore = SsoStorage.layout().hookDataStore;
}

function _supportsHook(address hook, bool isValidation) internal view returns (bool) {
function _supportsHook(address hook, bool isValidation) private view returns (bool) {
return
isValidation
? hook.supportsInterface(type(IValidationHook).interfaceId)
Expand Down
2 changes: 1 addition & 1 deletion src/managers/OwnerManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract contract OwnerManager is IOwnerManager, Auth {
return _k1OwnersLinkedList().exists(addr);
}

function _k1OwnersLinkedList() internal view returns (mapping(address => address) storage k1Owners) {
function _k1OwnersLinkedList() private view returns (mapping(address => address) storage k1Owners) {
k1Owners = SsoStorage.layout().k1Owners;
}

Expand Down
4 changes: 2 additions & 2 deletions src/managers/ValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ abstract contract ValidatorManager is IValidatorManager, Auth {
emit AddModuleValidator(validator);
}

function _removeModuleValidator(address validator) internal {
function _removeModuleValidator(address validator) private {
_moduleValidatorsLinkedList().remove(validator);

validator.excessivelySafeCall(gasleft(), 0, abi.encodeWithSelector(IInitable.disable.selector));
Expand All @@ -68,7 +68,7 @@ abstract contract ValidatorManager is IValidatorManager, Auth {
return _moduleValidatorsLinkedList().exists(validator);
}

function _supportsModuleValidator(address validator) internal view returns (bool) {
function _supportsModuleValidator(address validator) private view returns (bool) {
return validator.supportsInterface(type(IModuleValidator).interfaceId);
}

Expand Down
2 changes: 1 addition & 1 deletion src/validators/SessionKeyValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contract SessionKeyValidator is IModuleValidator {
}

// This module should not be used to validate signatures
function validateSignature(bytes32 signedHash, bytes memory signature) external view returns (bool) {
function validateSignature(bytes32 signedHash, bytes memory signature) external pure returns (bool) {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/validators/WebAuthValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract WebAuthValidator is VerifierCaller, IModuleValidator {
// so there's no way to just delete all the keys
// We can only disconnect the module from the account,
// re-linking it will allow any previous keys
function disable() external {
function disable() external pure {
revert("Cannot disable module without removing it from account");
}

Expand Down Expand Up @@ -160,14 +160,14 @@ contract WebAuthValidator is VerifierCaller, IModuleValidator {
function _createMessage(
bytes memory authenticatorData,
bytes memory clientData
) internal pure returns (bytes32 message) {
) private pure returns (bytes32 message) {
bytes32 clientDataHash = sha256(clientData);
message = sha256(bytes.concat(authenticatorData, clientDataHash));
}

function _decodeFatSignature(
bytes memory fatSignature
) internal pure returns (bytes memory authenticatorData, string memory clientDataSuffix, bytes32[2] memory rs) {
) private pure returns (bytes memory authenticatorData, string memory clientDataSuffix, bytes32[2] memory rs) {
(authenticatorData, clientDataSuffix, rs) = abi.decode(fatSignature, (bytes, string, bytes32[2]));
}

Expand Down
Loading