From 3074076dd6738e392c5a8a13a2dedbcec413de8d Mon Sep 17 00:00:00 2001 From: Flydexo Date: Sat, 13 May 2023 21:45:39 +0200 Subject: [PATCH] new events --- .env.example | 2 +- readme.md | 6 +++--- scripts/Deploy.s.sol | 4 ++-- scripts/deploy_all.sh | 8 ++++---- scripts/deploy_safe.sh | 4 ++-- src/core/FeeManager.sol | 5 ++++- src/core/PermissiveAccount.sol | 9 +++++++++ src/core/PermissiveFactory.sol | 7 +++++++ src/integrations/safe/ISafeModule.sol | 2 ++ src/integrations/safe/SafeFactory.sol | 6 ++++++ src/integrations/safe/SafeModule.sol | 1 + src/interfaces/IPermissiveAccount.sol | 10 ++++++++++ 12 files changed, 51 insertions(+), 13 deletions(-) diff --git a/.env.example b/.env.example index ccbb47e..b71b422 100644 --- a/.env.example +++ b/.env.example @@ -20,7 +20,7 @@ ETHERSCAN_KEY_5="" RPC_59140="https://rpc.goerli.linea.build" ETHERSCAN_URL_59140="" ETHERSCAN_KEY_59140="" -FEE_MANAGER="0x904Ecc27AA051050FC3Dd867Ead58aEb43a98188" +FEE_MANAGER="0x2ad29cc25d9fb3647b304353a0a609f27afe380b" ALLOWANCE_CALLDATA="0xEf86319d72267e538e963f724cdC813d8CCC6C50" SALT="Permissive-v0.0.3" BYTES_LIB="0xaEFF1a8e8Fc46A37151b4be60F3430742d9ccBF7" diff --git a/readme.md b/readme.md index 8ccf275..259b270 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ # Deployments -| factory | account implementation | fee manager | -| ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | -| 0xA0f2BC600ABce58558590674A41EF52eC335A90A | 0x23E4f1cD1F842effCd260daCcD6fFf7a24E0f7c6 | 0xd3bfe05a94e8ffe5f087aaa7b9665d484deb2ced | +| factory | account implementation | fee manager | safe factory | +| ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | +| 0x499dcb87582897b050fa0579eb0d5fe71ce491b3 | 0x031d104686cde4d7ac2a31831efe36eee888af2c | 0x2ad29cc25d9fb3647b304353a0a609f27afe380b | 0x0c850e3c696871e6b72a410bea7b1c96870e0715 | diff --git a/scripts/Deploy.s.sol b/scripts/Deploy.s.sol index b42205a..0ac2198 100644 --- a/scripts/Deploy.s.sol +++ b/scripts/Deploy.s.sol @@ -17,8 +17,8 @@ contract DeployScript is Script { FeeManager feeManager = new FeeManager{salt: versionSalt}(); feeManager.initialize(vm.envAddress("OWNER")); PermissiveFactory factory = new PermissiveFactory{salt: versionSalt}( - IEntryPoint(entrypoint), - feeManager + entrypoint, + payable(address(feeManager)) ); vm.stopBroadcast(); } diff --git a/scripts/deploy_all.sh b/scripts/deploy_all.sh index 22cef60..31cf7c9 100755 --- a/scripts/deploy_all.sh +++ b/scripts/deploy_all.sh @@ -1,9 +1,9 @@ # deploy mumbai forge script --rpc-url $RPC_80001 --broadcast --sender $OWNER ./scripts/Deploy.s.sol -# base goerli -forge script --rpc-url $RPC_84531 --broadcast --sender $OWNER ./scripts/Deploy.s.sol -# linea goerli -forge script --rpc-url $RPC_59140 --broadcast --sender $OWNER ./scripts/Deploy.s.sol +# # base goerli +# forge script --rpc-url $RPC_84531 --broadcast --sender $OWNER ./scripts/Deploy.s.sol +# # linea goerli +# forge script --rpc-url $RPC_59140 --broadcast --sender $OWNER ./scripts/Deploy.s.sol # optimism goerli forge script --rpc-url $RPC_420 --broadcast --sender $OWNER ./scripts/Deploy.s.sol # arbitrum goerli diff --git a/scripts/deploy_safe.sh b/scripts/deploy_safe.sh index c4c19a1..2c256a9 100755 --- a/scripts/deploy_safe.sh +++ b/scripts/deploy_safe.sh @@ -1,7 +1,7 @@ # # deploy mumbai # forge script --rpc-url $RPC_80001 --broadcast --sender $OWNER ./scripts/Deploy.s.sol -# base goerli -forge script --rpc-url $RPC_84531 --broadcast --sender $OWNER ./scripts/DeploySafe.s.sol +# # base goerli +# forge script --rpc-url $RPC_84531 --broadcast --sender $OWNER ./scripts/DeploySafe.s.sol # # linea goerli # forge script --rpc-url $RPC_59140 --broadcast --sender $OWNER ./scripts/Deploy.s.sol # # optimism goerli diff --git a/src/core/FeeManager.sol b/src/core/FeeManager.sol index 1acea75..e203326 100644 --- a/src/core/FeeManager.sol +++ b/src/core/FeeManager.sol @@ -7,6 +7,7 @@ import "@openzeppelin/contracts/access/Ownable.sol"; contract FeeManager is Ownable { uint256 public fee = 2000; bool initialized; + event FeePaid(address indexed from, uint amount); function initialize(address owner) external { require(!initialized); @@ -22,5 +23,7 @@ contract FeeManager is Ownable { payable(msg.sender).transfer(address(this).balance); } - receive() external payable {} + receive() external payable { + emit FeePaid(msg.sender, msg.value); + } } diff --git a/src/core/PermissiveAccount.sol b/src/core/PermissiveAccount.sol index a6efed0..665eefb 100644 --- a/src/core/PermissiveAccount.sol +++ b/src/core/PermissiveAccount.sol @@ -120,6 +120,7 @@ contract PermissiveAccount is BaseAccount, IPermissiveAccount, Ownable, EIP712 { remainingFeeForOperator[permission.operator] -= gasFee; } _payPrefund(missingAccountFunds); + emit UserOpValidated(userOpHash, userOp); } function execute( @@ -156,6 +157,14 @@ contract PermissiveAccount is BaseAccount, IPermissiveAccount, Ownable, EIP712 { AllowanceCalldata.RLPtoABI(func.slice(4, func.length - 4)) ) ); + emit PermissionUsed( + hashPerm(permission), + dest, + value, + func, + permission, + gasFee + ); if (!success) { assembly { revert(add(result, 32), mload(result)) diff --git a/src/core/PermissiveFactory.sol b/src/core/PermissiveFactory.sol index 73d73da..b807935 100644 --- a/src/core/PermissiveFactory.sol +++ b/src/core/PermissiveFactory.sol @@ -11,6 +11,12 @@ import "account-abstraction/interfaces/IEntryPoint.sol"; contract PermissiveFactory { PermissiveAccount public immutable accountImplementation; + event AccountCreated( + address indexed owner, + uint256 indexed salt, + address indexed account + ); + constructor(address entrypoint, address payable feeManager) { accountImplementation = new PermissiveAccount(entrypoint, feeManager); } @@ -32,6 +38,7 @@ contract PermissiveFactory { ) ) ); + emit AccountCreated(owner, salt, address(ret)); } function getAddress( diff --git a/src/integrations/safe/ISafeModule.sol b/src/integrations/safe/ISafeModule.sol index db94e93..09ff74f 100644 --- a/src/integrations/safe/ISafeModule.sol +++ b/src/integrations/safe/ISafeModule.sol @@ -24,4 +24,6 @@ interface ISafeModule { uint256 maxValue, uint256 maxFee ); + + event NewSafe(address safe); } diff --git a/src/integrations/safe/SafeFactory.sol b/src/integrations/safe/SafeFactory.sol index cdc7d06..9d90cef 100644 --- a/src/integrations/safe/SafeFactory.sol +++ b/src/integrations/safe/SafeFactory.sol @@ -8,6 +8,11 @@ import "./SafeModule.sol"; contract SafeFactory { SafeModule public immutable moduleImplementation; + event AccountCreated( + address indexed safe, + uint256 indexed salt, + address indexed account + ); constructor(address entrypoint, address payable feeManager) { moduleImplementation = new SafeModule(entrypoint, feeManager); @@ -30,6 +35,7 @@ contract SafeFactory { ) ) ); + emit AccountCreated(safe, salt, address(ret)); } function getAddress( diff --git a/src/integrations/safe/SafeModule.sol b/src/integrations/safe/SafeModule.sol index bdf448d..848f6e6 100644 --- a/src/integrations/safe/SafeModule.sol +++ b/src/integrations/safe/SafeModule.sol @@ -42,6 +42,7 @@ contract SafeModule is ISafeModule { function setSafe(address _safe) external { _onlySafe(); safe = ISafe(_safe); + emit NewSafe(_safe); } // EXTERNAL FUNCTIONS diff --git a/src/interfaces/IPermissiveAccount.sol b/src/interfaces/IPermissiveAccount.sol index 8db2a07..be712d9 100644 --- a/src/interfaces/IPermissiveAccount.sol +++ b/src/interfaces/IPermissiveAccount.sol @@ -25,6 +25,16 @@ interface IPermissiveAccount is IAccount { uint256 maxFee ); + event UserOpValidated(bytes32 indexed userOpHash, UserOperation userOp); + event PermissionUsed( + bytes32 indexed permHash, + address dest, + uint256 value, + bytes func, + Permission permission, + uint256 gasFee + ); + function initialize(address owner) external; function setOperatorPermissions(