From b8d0ab6f44c8593a586ddc0b31f759ba0deb08bb Mon Sep 17 00:00:00 2001 From: zeroknots Date: Fri, 23 Feb 2024 11:03:50 +0700 Subject: [PATCH] updating CI clean up fix CI test test of fmt --- .github/workflows/ci.yaml | 31 ++- packages/SessionKeyManager/bytecode.sh | 3 +- .../src/ISessionValidationModule.sol | 2 + .../src/SessionKeyManager.sol | 7 +- .../src/SessionKeyManagerBytecode.sol | 3 +- .../src/modules/ERC7579HookDestruct.sol | 2 - .../src/modules/ERC7579HookDestruct.sol.bak | 181 ------------------ 7 files changed, 21 insertions(+), 208 deletions(-) delete mode 100644 packages/modulekit/src/modules/ERC7579HookDestruct.sol.bak diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4a7387b5..12842800 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,53 +3,48 @@ on: - pull_request jobs: - lint: - uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-lint.yaml@main" - - build: - uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-build.yaml@main" + lint-modulekit: + uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-lint-workspaces.yaml@main" + with: + match-workspace: "@rhinestone/modulekit" - test-unit: - needs: ["build"] - uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test.yaml@main" + build-modulekit: + uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test-workspaces.yaml@main" with: - foundry-fuzz-runs: 5000 - foundry-profile: "test" - match-path: "test/**/*.sol" - name: "Unit tests" + match-workspace: "@rhinestone/modulekit" lint-safe7579: - needs: ["lint", "test-unit"] + needs: ["lint-modulekit"] uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-lint-workspaces.yaml@main" with: match-workspace: "@rhinestone/safe7579" test-safe7579: - needs: ["build", "test-unit"] + needs: ["build-modulekit"] uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test-workspaces.yaml@main" with: match-workspace: "@rhinestone/safe7579" lint-sessionkeymanager: - needs: ["lint", "test-unit"] + needs: ["lint-modulekit"] uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-lint-workspaces.yaml@main" with: match-workspace: "@rhinestone/sessionkeymanager" test-sessionkeymanager: - needs: ["build", "test-unit"] + needs: ["build-modulekit"] uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test-workspaces.yaml@main" with: match-workspace: "@rhinestone/sessionkeymanager" lint-modulekit-examples: - needs: ["lint", "test-unit"] + needs: ["lint-modulekit"] uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-lint-workspaces.yaml@main" with: match-workspace: "@rhinestone/modulekit-examples" test-modulekit-examples: - needs: ["build", "test-unit"] + needs: ["build-modulekit"] uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test-workspaces.yaml@main" with: match-workspace: "@rhinestone/modulekit-examples" diff --git a/packages/SessionKeyManager/bytecode.sh b/packages/SessionKeyManager/bytecode.sh index 67714640..b9abe489 100755 --- a/packages/SessionKeyManager/bytecode.sh +++ b/packages/SessionKeyManager/bytecode.sh @@ -3,5 +3,6 @@ bytecode=$(jq ".bytecode" out/SessionKeyManager.sol/SessionKeyManager.json | jq echo "// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; -/* solhint-disable-nextline max-line-length */ + +/* solhint-disable max-line-length */ bytes constant SESSIONKEYMANAGER_BYTECODE = $bytecode;" > src/SessionKeyManagerBytecode.sol diff --git a/packages/SessionKeyManager/src/ISessionValidationModule.sol b/packages/SessionKeyManager/src/ISessionValidationModule.sol index f9b29a4a..9ce05833 100644 --- a/packages/SessionKeyManager/src/ISessionValidationModule.sol +++ b/packages/SessionKeyManager/src/ISessionValidationModule.sol @@ -2,6 +2,8 @@ pragma solidity ^0.8.23; interface ISessionValidationModule { + + /** * @dev validates that the call (destinationContract, callValue, funcCallData) * complies with the Session Key permissions represented by sessionKeyData diff --git a/packages/SessionKeyManager/src/SessionKeyManager.sol b/packages/SessionKeyManager/src/SessionKeyManager.sol index 85324d85..84d17fbe 100644 --- a/packages/SessionKeyManager/src/SessionKeyManager.sol +++ b/packages/SessionKeyManager/src/SessionKeyManager.sol @@ -4,13 +4,10 @@ pragma solidity ^0.8.23; /* solhint-disable function-max-lines*/ /* solhint-disable ordering*/ -import { IERC7579Account, Execution } from "@rhinestone/modulekit/src/Accounts.sol"; -import { EncodedModuleTypes, ModuleTypeLib, ModuleType } from "erc7579/lib/ModuleTypeLib.sol"; import { ACCOUNT_EXEC_TYPE, ERC7579ValidatorLib } from "@rhinestone/modulekit/src/modules/utils/ERC7579ValidatorLib.sol"; -import { IERC1271 } from "@rhinestone/modulekit/src/interfaces/IERC1271.sol"; import { ERC7579ValidatorBase } from "@rhinestone/modulekit/src/modules/ERC7579ValidatorBase.sol"; import { PackedUserOperation, UserOperationLib @@ -85,7 +82,7 @@ contract SessionKeyManager is ERC7579ValidatorBase { function _validateSingleExec( PackedUserOperation calldata userOp, - bytes32 userOpHash + bytes32 /*userOpHash*/ // TODO: userOpHash is currently not evaluated. DONT USE THIS IN PROD ) internal returns (ValidationData vd) @@ -112,7 +109,7 @@ contract SessionKeyManager is ERC7579ValidatorBase { function _validateBatchedExec( PackedUserOperation calldata userOp, - bytes32 userOpHash + bytes32 /*userOpHash*/ ) internal returns (ValidationData vd) diff --git a/packages/SessionKeyManager/src/SessionKeyManagerBytecode.sol b/packages/SessionKeyManager/src/SessionKeyManagerBytecode.sol index 8447f255..168d1725 100644 --- a/packages/SessionKeyManager/src/SessionKeyManagerBytecode.sol +++ b/packages/SessionKeyManager/src/SessionKeyManagerBytecode.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; -/* solhint-disable-nextline max-line-length */ + +/* solhint-disable max-line-length */ bytes constant SESSIONKEYMANAGER_BYTECODE = hex"6080806040523461001657610cfe908161001c8239f35b600080fdfe60806040908082526004918236101561001757600080fd5b600091823560e01c90816306fdde03146106025750806354fd4d50146105be5780636d61fe70146105b95780638a91b0e3146105b95780639700320314610563578063cb9b272c14610308578063d4511ee9146102e7578063d60b347f146102c2578063d6cc1aa4146102a8578063df73e60e146101cb578063ecd05961146101a6578063f42c859d146100ff5763f551e2ee146100b457600080fd5b346100fb5760603660031901126100fb576100cd610727565b5060443567ffffffffffffffff81116100f7576020936100ef9136910161068f565b505051908152f35b8280fd5b5080fd5b508183346100fb5760203660031901126100fb576001903592838352826020528083203384526020528220828155016101388154610807565b80610169575b505050337f10103b778a5e09e8bcc680439d97711489525190a1fe679251002e893f9ea5638380a380f35b82601f8211600114610181575050555b81838061013e565b909180825261019f601f60208420940160051c840160018501610841565b5555610179565b509190346101c85760203660031901126101c857506001602092519135148152f35b80fd5b50346100fb57806003193601126100fb576102a460016101e9610727565b838051956101f68761073d565b808752606080602098838a820152838582015201526024358152808752818120848060a01b038094168252875220948451946102318661073d565b86549165ffffffffffff9788918285168952610271818a0192848760301c168452858b019660601c875261026a8651809a81930161088c565b038861078b565b606089019687528351998a99828b52511690890152511690860152511660608401525160808084015260a083019061064f565b0390f35b50346100fb57816003193601126100fb5751908152602090f35b50346100fb5760203660031901126100fb57906020916102e0610727565b5051908152f35b50346100fb576020906103016102fc366106f5565b610c34565b9051908152f35b5082346100f757610318366106f5565b9061032282610c34565b92838552602092858452818620338752845281862065ffffffffffff9283610349846107e0565b1690868401946bffffffffffff000000000000610365876107e0565b60301b16828601936bffffffffffffffffffffffff19610384866107f3565b60601b169117178455600180940160608601946103a186886107ad565b919067ffffffffffffffff9a8b841161055057509082918e8d6103c48754610807565b90601f8211610517575b90508193601f86116001146104ad575050926104a2575b50508160011b916000199060031b1c19161790555b6104178251968988528261040d88610858565b168a890152610858565b1690850152356001600160a01b0381169081900361049e57606084015235601e198236030181121561049a57018035930191831161049657823603821361049657806104907f57aa9b35aca9ac2ac77db1278fe563afa57004616360740e680d89bc674ebd1e93608080840152339560a084019161086b565b0390a380f35b8480fd5b8680fd5b8780fd5b013590508d806103e5565b8783528183209550929392601f19871692915b8383106104ff575050509084600195949392106104e5575b505050811b0190556103fa565b0135600019600384901b60f8161c191690558d80806104d8565b8185978293949688013581550196019301908f6104c0565b87835280832061053f92601f880160051c8201928810610546575b601f0160051c0190610841565b388e6103ce565b9091508190610532565b634e487b7160e01b8f526041905260248efd5b5090346101c8576003199282843601126100fb57803567ffffffffffffffff81116100f7576101208183019582360301126100f75760646105a59101856107ad565b919050116101c85750610301602092610922565b6106c2565b50346100fb57816003193601126100fb5780516102a4916105de8261076f565b6005825264302e302e3160d81b60208301525191829160208352602083019061064f565b919050346100f757826003193601126100f7576102a492506106238261076f565b601182527029b2b9b9b4b7b725b2bca6b0b730b3b2b960791b6020830152519182916020835260208301905b919082519283825260005b84811061067b575050826000602080949584010152601f8019910116010190565b60208183018101518483018201520161065a565b9181601f840112156106bd5782359167ffffffffffffffff83116106bd57602083818601950101116106bd57565b600080fd5b346106bd5760203660031901126106bd5760043567ffffffffffffffff81116106bd576106f390369060040161068f565b005b600319906020818301126106bd576004359167ffffffffffffffff83116106bd57826080920301126106bd5760040190565b600435906001600160a01b03821682036106bd57565b6080810190811067ffffffffffffffff82111761075957604052565b634e487b7160e01b600052604160045260246000fd5b6040810190811067ffffffffffffffff82111761075957604052565b90601f8019910116810190811067ffffffffffffffff82111761075957604052565b903590601e19813603018212156106bd570180359067ffffffffffffffff82116106bd576020019181360383136106bd57565b3565ffffffffffff811681036106bd5790565b356001600160a01b03811681036106bd5790565b90600182811c92168015610837575b602083101461082157565b634e487b7160e01b600052602260045260246000fd5b91607f1691610816565b81811061084c575050565b60008155600101610841565b359065ffffffffffff821682036106bd57565b908060209392818452848401376000828201840152601f01601f1916010190565b80546000939261089b82610807565b9182825260209360019160018116908160001461090357506001146108c2575b5050505050565b90939495506000929192528360002092846000945b8386106108ef575050505001019038808080806108bb565b8054858701830152940193859082016108d7565b60ff19168685015250505090151560051b0101915038808080806108bb565b6109306101008201826107ad565b5060018101356000526000602052604060002060018060a01b0383351660005260205261096660406000209260608101906107ad565b9290836004116106bd576003198401806020116106bd57806040116106bd57601f198501858111610c1e57806080116106bd57116106bd576109f7602091610a0c956000855460601c92610a2c604051998a968795869463c20bccb960e01b8652601081013560601c60048701526024810135602487015260a06044870152608460a4870192609f1901910161086b565b83810360031901606485015260018a0161088c565b82810360031901608484015260218a8101358b016001810135910161086b565b03925af1928315610c1257600093610bce575b5054916000916001600160a01b038216610a80575b505015610a7a5760a01b65ffffffffffff60d01b81169065ffffffffffff60a01b161790565b50600190565b9091506040519160018201356000526040600160218401358401013514610b6f575b6041600160218401358401013514610b25575b60006060526040838152630b135d3f60e11b8085526001848101356004870152602486019283526021808601358601808301356044890181905294979396602096899690959460649490930184860137602181013501013501916001600160a01b03165afa915114163880610a54565b6021828101358301606181013560001a6020526040910181376020600160806000825afa516001600160a01b038216183d1517610ab5575050600060605260405260013880610a54565b6021828101358301604181013560ff81901c601b01602090815291909201356040526001600160ff1b03909116606052600160806000825afa516001600160a01b038216183d1517610aa2575050600060605260405260013880610a54565b9092506020813d602011610c0a575b81610bea6020938361078b565b810103126106bd57516001600160a01b03811681036106bd579138610a3f565b3d9150610bdd565b6040513d6000823e3d90fd5b634e487b7160e01b600052601160045260246000fd5b610c3d816107e0565b90610cc26040610c4f602084016107e0565b93610c69610c5e8386016107f3565b9460608101906107ad565b80918451968794602086019965ffffffffffff60d01b809260d01b168b5260d01b1660268601526bffffffffffffffffffffffff199060601b16602c85015284840137810160008382015203602081018452018261078b565b5190209056fea264697066735822122026a81cd670005fcd561638caf42a14771310b8b3023b89447085b3f5739e2d3364736f6c63430008180033"; diff --git a/packages/modulekit/src/modules/ERC7579HookDestruct.sol b/packages/modulekit/src/modules/ERC7579HookDestruct.sol index 108a4377..1b89c33a 100644 --- a/packages/modulekit/src/modules/ERC7579HookDestruct.sol +++ b/packages/modulekit/src/modules/ERC7579HookDestruct.sol @@ -13,7 +13,6 @@ import { CALLTYPE_DELEGATECALL } from "erc7579/lib/ModeLib.sol"; - uint256 constant EXEC_OFFSET = 100; uint256 constant INSTALL_OFFSET = 132; @@ -70,7 +69,6 @@ abstract contract ERC7579HookDestruct is ERC7579HookBase { ModeCode mode = ModeCode.wrap(bytes32(msgData[4:36])); CallType calltype = ModeLib.getCallType(mode); - if (calltype == CALLTYPE_SINGLE) { (address to, uint256 value, bytes calldata callData) = ExecutionLib.decodeSingle(encodedExecutions); diff --git a/packages/modulekit/src/modules/ERC7579HookDestruct.sol.bak b/packages/modulekit/src/modules/ERC7579HookDestruct.sol.bak deleted file mode 100644 index 330363e7..00000000 --- a/packages/modulekit/src/modules/ERC7579HookDestruct.sol.bak +++ /dev/null @@ -1,181 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.23; - -import { ERC7579HookBase } from "./ERC7579HookBase.sol"; -import { IERC7579Account } from "../Accounts.sol"; -import { ExecutionLib, Execution } from "erc7579/lib/ExecutionLib.sol"; -import { - ModeLib, - CallType, - ModeCode, - CALLTYPE_SINGLE, - CALLTYPE_BATCH, - CALLTYPE_DELEGATECALL -} from "erc7579/lib/ModeLib.sol"; - -import "forge-std/console2.sol"; - -abstract contract ERC7579HookDestruct is ERC7579HookBase { - error HookInvalidSelector(); - - /*////////////////////////////////////////////////////////////////////////// - CALLDATA DECODING - //////////////////////////////////////////////////////////////////////////*/ - - // import "../interfaces/IERC7579Account.sol"; - // - // library HookOffsetLib { - // function offset() internal pure returns (uint256 offset) { - // bytes4 functionSig = bytes4(msg.data[:4]); - // if ( - // functionSig == IERC7579Account.execute.selector - // || functionSig == IERC7579Account.executeFromExecutor.selector - // ) { - // return 100 + uint256(bytes32(msg.data[68:100])); - // } - // - // if ( - // functionSig == IERC7579Account.installModule.selector - // || functionSig == IERC7579Account.uninstallModule.selector - // ) { - // return 132 + uint256(bytes32(msg.data[100:132])); - // } else { - // return msg.data.length; - // } - // } - // } - - function preCheck( - address msgSender, - bytes calldata msgData - ) - external - override - returns (bytes memory hookData) - { - bytes4 selector = bytes4(msgData[0:4]); - - if (selector == IERC7579Account.execute.selector) { - ModeCode mode = ModeCode.wrap(bytes32(msgData[4:36])); - CallType calltype = ModeLib.getCallType(mode); - uint256 offset = 100 + uint256(bytes32(msgData[68:100])); - if (calltype == CALLTYPE_SINGLE) { - (address to, uint256 value, bytes calldata callData) = - ExecutionLib.decodeSingle(msgData[36:offset]); - return onExecute(msgSender, to, value, callData); - } else if (calltype == CALLTYPE_BATCH) { - Execution[] calldata execs = ExecutionLib.decodeBatch(msgData[36:]); - return onExecuteBatch(msgSender, execs); - } else { - revert HookInvalidSelector(); - } - } else if (selector == IERC7579Account.executeFromExecutor.selector) { - console2.logBytes(msgData); - - uint256 offset = 100 + uint256(bytes32(msgData[68:100])); - console2.log("offset: ", offset); - console2.logBytes(msgData[:offset]); - ModeCode mode = ModeCode.wrap(bytes32(msgData[4:36])); - CallType calltype = ModeLib.getCallType(mode); - if (calltype == CALLTYPE_SINGLE) { - (address to, uint256 value, bytes calldata callData) = - ExecutionLib.decodeSingle(msgData[36:offset]); - return onExecuteFromExecutor(msgSender, to, value, callData); - } else if (calltype == CALLTYPE_BATCH) { - Execution[] calldata execs = ExecutionLib.decodeBatch(msgData[36:offset]); - return onExecuteBatchFromExecutor(msgSender, execs); - } else { - revert HookInvalidSelector(); - } - } else if (selector == IERC7579Account.installModule.selector) { - uint256 offset = 132 + uint256(bytes32(msgData[100:132])); - uint256 moduleType = uint256(bytes32(msgData[4:24])); - address module = address(bytes20(msgData[24:36])); - bytes calldata initData = msgData[36:offset]; - onInstallModule(msgSender, moduleType, module, initData); - } else if (selector == IERC7579Account.uninstallModule.selector) { - uint256 offset = 132 + uint256(bytes32(msgData[100:132])); - uint256 moduleType = uint256(bytes32(msgData[4:24])); - address module = address(bytes20(msgData[24:36])); - bytes calldata initData = msgData[36:offset]; - onUninstallModule(msgSender, moduleType, module, initData); - } else { - revert HookInvalidSelector(); - } - } - - function postCheck(bytes calldata hookData) external override returns (bool success) { - if (hookData.length == 0) return true; - return onPostCheck(hookData); - } - - /*////////////////////////////////////////////////////////////////////////// - EXECUTION - //////////////////////////////////////////////////////////////////////////*/ - - function onExecute( - address msgSender, - address target, - uint256 value, - bytes calldata callData - ) - internal - virtual - returns (bytes memory hookData); - - function onExecuteBatch( - address msgSender, - Execution[] calldata - ) - internal - virtual - returns (bytes memory hookData); - - function onExecuteFromExecutor( - address msgSender, - address target, - uint256 value, - bytes calldata callData - ) - internal - virtual - returns (bytes memory hookData); - - function onExecuteBatchFromExecutor( - address msgSender, - Execution[] calldata - ) - internal - virtual - returns (bytes memory hookData); - - /*////////////////////////////////////////////////////////////////////////// - CONFIG - //////////////////////////////////////////////////////////////////////////*/ - - function onInstallModule( - address msgSender, - uint256 moduleType, - address module, - bytes calldata initData - ) - internal - virtual - returns (bytes memory hookData); - - function onUninstallModule( - address msgSender, - uint256 moduleType, - address module, - bytes calldata deInitData - ) - internal - virtual - returns (bytes memory hookData); - - /*////////////////////////////////////////////////////////////////////////// - POSTCHECK - //////////////////////////////////////////////////////////////////////////*/ - - function onPostCheck(bytes calldata hookData) internal virtual returns (bool success); -}