Skip to content

Commit

Permalink
Merge pull request #4 from permissivelabs/safe
Browse files Browse the repository at this point in the history
new events
  • Loading branch information
Flydexo authored May 13, 2023
2 parents 930cbdd + 3074076 commit 90a6e96
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Deployments

| factory | account implementation | fee manager |
| ------------------------------------------ | ------------------------------------------ | ------------------------------------------ |
| 0xA0f2BC600ABce58558590674A41EF52eC335A90A | 0x23E4f1cD1F842effCd260daCcD6fFf7a24E0f7c6 | 0xd3bfe05a94e8ffe5f087aaa7b9665d484deb2ced |
| factory | account implementation | fee manager | safe factory |
| ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ |
| 0x499dcb87582897b050fa0579eb0d5fe71ce491b3 | 0x031d104686cde4d7ac2a31831efe36eee888af2c | 0x2ad29cc25d9fb3647b304353a0a609f27afe380b | 0x0c850e3c696871e6b72a410bea7b1c96870e0715 |
4 changes: 2 additions & 2 deletions scripts/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
8 changes: 4 additions & 4 deletions scripts/deploy_all.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/deploy_safe.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/core/FeeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
9 changes: 9 additions & 0 deletions src/core/PermissiveAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ contract PermissiveAccount is BaseAccount, IPermissiveAccount, Ownable, EIP712 {
remainingFeeForOperator[permission.operator] -= gasFee;
}
_payPrefund(missingAccountFunds);
emit UserOpValidated(userOpHash, userOp);
}

function execute(
Expand Down Expand Up @@ -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))
Expand Down
7 changes: 7 additions & 0 deletions src/core/PermissiveFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -32,6 +38,7 @@ contract PermissiveFactory {
)
)
);
emit AccountCreated(owner, salt, address(ret));
}

function getAddress(
Expand Down
2 changes: 2 additions & 0 deletions src/integrations/safe/ISafeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ interface ISafeModule {
uint256 maxValue,
uint256 maxFee
);

event NewSafe(address safe);
}
6 changes: 6 additions & 0 deletions src/integrations/safe/SafeFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -30,6 +35,7 @@ contract SafeFactory {
)
)
);
emit AccountCreated(safe, salt, address(ret));
}

function getAddress(
Expand Down
1 change: 1 addition & 0 deletions src/integrations/safe/SafeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ contract SafeModule is ISafeModule {
function setSafe(address _safe) external {
_onlySafe();
safe = ISafe(_safe);
emit NewSafe(_safe);
}

// EXTERNAL FUNCTIONS
Expand Down
10 changes: 10 additions & 0 deletions src/interfaces/IPermissiveAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 90a6e96

Please sign in to comment.