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: resolve solc warnings #156

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/deployment/RegistryDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
)
public
{
require(isContract(mockAttester), "MockAttester is not deployed on this network");

Check warning on line 115 in src/deployment/RegistryDeployer.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Error message for require is too long: 44 counted / 32 allowed

Check warning on line 115 in src/deployment/RegistryDeployer.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

GC: Use Custom Errors instead of require statements

SchemaUID _schemaUID = findSchema();
AttestationRequest memory request = AttestationRequest({
Expand All @@ -130,7 +130,7 @@
)
);

require(success, "Mock attestation failed");

Check warning on line 133 in src/deployment/RegistryDeployer.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

GC: Use Custom Errors instead of require statements
}

function isModuleAttestedMock(address module) public view returns (bool) {
Expand Down Expand Up @@ -188,9 +188,9 @@
}

// <---- OTHER ---->
function isContract(address _addr) internal returns (bool isContract) {
function isContract(address _addr) internal view returns (bool _isContract) {
uint32 size;
assembly {

Check warning on line 193 in src/deployment/RegistryDeployer.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Avoid to use inline assembly. It is acceptable only in rare cases
size := extcodesize(_addr)
}
return (size > 0);
Expand Down
71 changes: 21 additions & 50 deletions src/test/ModuleKitHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,8 @@ library ModuleKitHelpers {
{
bytes memory erc7579ExecCall =
HelperBase(instance.accountHelper).encode(target, value, callData);
(userOpData.userOp, userOpData.userOpHash) = HelperBase(instance.accountHelper).execUserOp({
instance: instance,
callData: erc7579ExecCall,
txValidator: txValidator
});
(userOpData.userOp, userOpData.userOpHash) =
HelperBase(instance.accountHelper).execUserOp(instance, erc7579ExecCall, txValidator);
userOpData.entrypoint = instance.aux.entrypoint;
}

Expand All @@ -113,11 +110,8 @@ library ModuleKitHelpers {
returns (UserOpData memory userOpData)
{
bytes memory erc7579ExecCall = HelperBase(instance.accountHelper).encode(executions);
(userOpData.userOp, userOpData.userOpHash) = HelperBase(instance.accountHelper).execUserOp({
instance: instance,
callData: erc7579ExecCall,
txValidator: txValidator
});
(userOpData.userOp, userOpData.userOpHash) =
HelperBase(instance.accountHelper).execUserOp(instance, erc7579ExecCall, txValidator);
userOpData.entrypoint = instance.aux.entrypoint;
}

Expand Down Expand Up @@ -286,14 +280,7 @@ library ModuleKitHelpers {
{
// get userOp with correct nonce for selected txValidator
(userOpData.userOp, userOpData.userOpHash) = HelperBase(instance.accountHelper)
.configModuleUserOp({
instance: instance,
moduleType: moduleType,
module: module,
initData: initData,
isInstall: true,
txValidator: txValidator
});
.configModuleUserOp(instance, moduleType, module, initData, true, txValidator);
userOpData.entrypoint = instance.aux.entrypoint;
}

Expand All @@ -309,14 +296,7 @@ library ModuleKitHelpers {
{
// get userOp with correct nonce for selected txValidator
(userOpData.userOp, userOpData.userOpHash) = HelperBase(instance.accountHelper)
.configModuleUserOp({
instance: instance,
moduleType: moduleType,
module: module,
initData: initData,
isInstall: false,
txValidator: txValidator
});
.configModuleUserOp(instance, moduleType, module, initData, false, txValidator);
userOpData.entrypoint = instance.aux.entrypoint;
}

Expand Down Expand Up @@ -654,12 +634,9 @@ library ModuleKitHelpers {
internal
returns (bool)
{
return HelperBase(instance.accountHelper).isValidSignature({
instance: instance,
validator: validator,
hash: hash,
signature: signature
});
return HelperBase(instance.accountHelper).isValidSignature(
instance, validator, hash, signature
);
}

function formatERC1271Hash(
Expand All @@ -670,11 +647,7 @@ library ModuleKitHelpers {
internal
returns (bytes32)
{
return HelperBase(instance.accountHelper).formatERC1271Hash({
instance: instance,
validator: validator,
hash: hash
});
return HelperBase(instance.accountHelper).formatERC1271Hash(instance, validator, hash);
}

function formatERC1271Signature(
Expand All @@ -685,11 +658,9 @@ library ModuleKitHelpers {
internal
returns (bytes memory)
{
return HelperBase(instance.accountHelper).formatERC1271Signature({
instance: instance,
validator: validator,
signature: signature
});
return HelperBase(instance.accountHelper).formatERC1271Signature(
instance, validator, signature
);
}

function signDefault(UserOpData memory userOpData) internal pure returns (UserOpData memory) {
Expand Down Expand Up @@ -753,14 +724,14 @@ library ModuleKitHelpers {
instance.installModule(1, address(instance.smartSession), "");
}
// Setup session data
Session memory session = Session({
sessionValidator: ISessionValidator(address(instance.defaultSessionValidator)),
salt: salt,
sessionValidatorInitData: "mockInitData",
userOpPolicies: userOpPolicies,
erc7739Policies: erc7739Policy,
actions: actionDatas
});
Session memory session = Session(
ISessionValidator(address(instance.defaultSessionValidator)),
"mockInitData",
salt,
userOpPolicies,
erc7739Policy,
actionDatas
);
// Enable session
return instance.addSession(session);
}
Expand Down
10 changes: 5 additions & 5 deletions src/test/helpers/ERC7579Helpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ contract ERC7579Helpers is HelperBase {
* get callData to install fallback on ERC7579 Account
*/
function getInstallFallbackData(
AccountInstance memory instance,
address module,
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
Expand All @@ -100,8 +100,8 @@ contract ERC7579Helpers is HelperBase {
* get callData to uninstall fallback on ERC7579 Account
*/
function getUninstallFallbackData(
AccountInstance memory instance,
address module,
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
Expand Down Expand Up @@ -136,7 +136,7 @@ contract ERC7579Helpers is HelperBase {
}

function formatERC1271Signature(
AccountInstance memory instance,
AccountInstance memory, // instance
address validator,
bytes memory signature
)
Expand Down
99 changes: 35 additions & 64 deletions src/test/helpers/HelperBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,11 @@ abstract contract HelperBase {
}
bytes memory callData;
if (isInstall) {
initData = getInstallModuleData({
instance: instance,
moduleType: moduleType,
module: module,
initData: initData
});
callData = getInstallModuleCallData({
instance: instance,
moduleType: moduleType,
module: module,
initData: initData
});
initData = getInstallModuleData(instance, moduleType, module, initData);
callData = getInstallModuleCallData(instance, moduleType, module, initData);
} else {
initData = getUninstallModuleData({
instance: instance,
moduleType: moduleType,
module: module,
initData: initData
});
callData = getUninstallModuleCallData({
instance: instance,
moduleType: moduleType,
module: module,
initData: initData
});
initData = getUninstallModuleData(instance, moduleType, module, initData);
callData = getUninstallModuleCallData(instance, moduleType, module, initData);
}

userOp = PackedUserOperation({
Expand All @@ -109,7 +89,7 @@ abstract contract HelperBase {
}

function getInstallModuleCallData(
AccountInstance memory instance,
AccountInstance memory, // instance
uint256 moduleType,
address module,
bytes memory initData
Expand All @@ -123,7 +103,7 @@ abstract contract HelperBase {
}

function getUninstallModuleCallData(
AccountInstance memory instance,
AccountInstance memory, // instance
uint256 moduleType,
address module,
bytes memory initData
Expand All @@ -140,8 +120,8 @@ abstract contract HelperBase {
* get callData to install validator on ERC7579 Account
*/
function getInstallValidatorData(
AccountInstance memory instance,
address module,
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
Expand All @@ -156,8 +136,8 @@ abstract contract HelperBase {
* get callData to uninstall validator on ERC7579 Account
*/
function getUninstallValidatorData(
AccountInstance memory instance,
address module,
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
Expand All @@ -172,8 +152,8 @@ abstract contract HelperBase {
* get callData to install executor on ERC7579 Account
*/
function getInstallExecutorData(
AccountInstance memory instance,
address module,
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
Expand All @@ -188,8 +168,8 @@ abstract contract HelperBase {
* get callData to uninstall executor on ERC7579 Account
*/
function getUninstallExecutorData(
AccountInstance memory instance,
address module,
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
Expand All @@ -204,8 +184,8 @@ abstract contract HelperBase {
* get callData to install hook on ERC7579 Account
*/
function getInstallHookData(
AccountInstance memory instance,
address module,
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
Expand All @@ -220,8 +200,8 @@ abstract contract HelperBase {
* get callData to uninstall hook on ERC7579 Account
*/
function getUninstallHookData(
AccountInstance memory instance,
address module,
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
Expand All @@ -236,8 +216,8 @@ abstract contract HelperBase {
* get callData to install fallback on ERC7579 Account
*/
function getInstallFallbackData(
AccountInstance memory instance,
address module,
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
Expand All @@ -252,8 +232,8 @@ abstract contract HelperBase {
* get callData to uninstall fallback on ERC7579 Account
*/
function getUninstallFallbackData(
AccountInstance memory instance,
address module,
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
Expand Down Expand Up @@ -305,16 +285,13 @@ abstract contract HelperBase {
returns (bytes memory)
{
if (moduleType == MODULE_TYPE_VALIDATOR) {
return
getInstallValidatorData({ instance: instance, module: module, initData: initData });
return getInstallValidatorData(instance, module, initData);
} else if (moduleType == MODULE_TYPE_EXECUTOR) {
return
getInstallExecutorData({ instance: instance, module: module, initData: initData });
return getInstallExecutorData(instance, module, initData);
} else if (moduleType == MODULE_TYPE_HOOK) {
return getInstallHookData({ instance: instance, module: module, initData: initData });
return getInstallHookData(instance, module, initData);
} else if (moduleType == MODULE_TYPE_FALLBACK) {
return
getInstallFallbackData({ instance: instance, module: module, initData: initData });
return getInstallFallbackData(instance, module, initData);
} else {
revert("Invalid module type");
}
Expand All @@ -332,19 +309,13 @@ abstract contract HelperBase {
returns (bytes memory)
{
if (moduleType == MODULE_TYPE_VALIDATOR) {
return getUninstallValidatorData({
instance: instance,
module: module,
initData: initData
});
return getUninstallValidatorData(instance, module, initData);
} else if (moduleType == MODULE_TYPE_EXECUTOR) {
return
getUninstallExecutorData({ instance: instance, module: module, initData: initData });
return getUninstallExecutorData(instance, module, initData);
} else if (moduleType == MODULE_TYPE_HOOK) {
return getUninstallHookData({ instance: instance, module: module, initData: initData });
return getUninstallHookData(instance, module, initData);
} else if (moduleType == MODULE_TYPE_FALLBACK) {
return
getUninstallFallbackData({ instance: instance, module: module, initData: initData });
return getUninstallFallbackData(instance, module, initData);
} else {
revert("Invalid module type");
}
Expand All @@ -356,7 +327,7 @@ abstract contract HelperBase {

function isValidSignature(
AccountInstance memory instance,
address validator,
address, // validator
bytes32 hash,
bytes memory signature
)
Expand All @@ -370,8 +341,8 @@ abstract contract HelperBase {
}

function formatERC1271Hash(
AccountInstance memory instance,
address validator,
AccountInstance memory, // instance
address, //validator
bytes32 hash
)
public
Expand All @@ -382,8 +353,8 @@ abstract contract HelperBase {
}

function formatERC1271Signature(
AccountInstance memory instance,
address validator,
AccountInstance memory, // instance
address, // validator
bytes memory signature
)
public
Expand Down
Loading
Loading