Skip to content

Commit

Permalink
Merge pull request #1 from buildorz/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
avaxrox authored Nov 24, 2023
2 parents b8e8cdd + 5b6068b commit 5a56eb7
Show file tree
Hide file tree
Showing 13 changed files with 3,142 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist/
types/

# Ignores development broadcast logs
/broadcast/*
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/
Expand Down
18 changes: 10 additions & 8 deletions scripts/DeployECDSAValidator.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ import "src/validator/ECDSAValidator.sol";
import "forge-std/Script.sol";
import "forge-std/console.sol";
contract DeployKernel is Script {
address constant DEPLOYER = 0x9775137314fE595c943712B0b336327dfa80aE8A;
address constant DEPLOYER = 0x9fD431b7703f94289Ba02034631dcC302717805B;
address constant ENTRYPOINT_0_6 = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789;
address constant EXPECTED_VALIDATOR_ADDRESS = 0xd9AB5096a832b9ce79914329DAEE236f8Eea0390;
address constant EXPECTED_VALIDATOR_ADDRESS = 0x93513fB6ea522d47ed8595f1B5037bd88578A914; //0x02c79162232843C3a1AAe42143087a848a525292;
function run() public {
uint256 key = vm.envUint("DEPLOYER_PRIVATE_KEY");
vm.startBroadcast(key);
if(EXPECTED_VALIDATOR_ADDRESS.code.length == 0) {
ECDSAValidator validator = new ECDSAValidator{salt:0}();
console.log("validator address: %s", address(validator));
} else {
console.log("validator address: %s", EXPECTED_VALIDATOR_ADDRESS);
}
ECDSAValidator validator = new ECDSAValidator{salt:"0x31"}();
console.log("validator address: %s", address(validator));
// if(EXPECTED_VALIDATOR_ADDRESS.code.length == 0) {
// ECDSAValidator validator = new ECDSAValidator{salt:0}();
// console.log("validator address: %s", address(validator));
// } else {
// console.log("validator address: %s", EXPECTED_VALIDATOR_ADDRESS);
// }
vm.stopBroadcast();
}
}
Expand Down
16 changes: 8 additions & 8 deletions scripts/DeployKernel.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import "account-abstraction/interfaces/IStakeManager.sol";
import "forge-std/Script.sol";
import "forge-std/console.sol";
contract DeployKernel is Script {
address constant DEPLOYER = 0x9775137314fE595c943712B0b336327dfa80aE8A;
address constant DEPLOYER = 0x9fD431b7703f94289Ba02034631dcC302717805B;
address constant ENTRYPOINT_0_6 = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789;
address payable constant EXPECTED_KERNEL_ADDRESS = payable(0xf048AD83CB2dfd6037A43902a2A5Be04e53cd2Eb);
address payable constant EXPECTED_KERNEL_FACTORY_ADDRESS = payable(0x5de4839a76cf55d0c90e2061ef4386d962E15ae3);
address payable constant EXPECTED_KERNEL_ADDRESS = payable(0x29C69905F09908C70da2D67a2B3d52B22E71F241); //0xf048AD83CB2dfd6037A43902a2A5Be04e53cd2Eb
address payable constant EXPECTED_KERNEL_FACTORY_ADDRESS = payable(0xc9683DFF173B60aCeF306525645AE6381726cC45);
function run() public {
uint256 key = vm.envUint("DEPLOYER_PRIVATE_KEY");
vm.startBroadcast(key);
Expand All @@ -30,11 +30,11 @@ contract DeployKernel is Script {
console.log("Registering kernel implementation");
factory.setImplementation(address(kernel), true);
}
IEntryPoint entryPoint = IEntryPoint(ENTRYPOINT_0_6);
IStakeManager.DepositInfo memory info = entryPoint.getDepositInfo(address(factory));
if(info.stake == 0) {
console.log("Need to stake to factory");
}
// IEntryPoint entryPoint = IEntryPoint(ENTRYPOINT_0_6);
// IStakeManager.DepositInfo memory info = entryPoint.getDepositInfo(address(factory));
// if(info.stake == 0) {
// console.log("Need to stake to factory");
// }
vm.stopBroadcast();
}
}
Expand Down
24 changes: 24 additions & 0 deletions scripts/createAcount.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
pragma solidity ^0.8.0;

import "src/factory/KernelFactory.sol";
import "forge-std/Script.sol";
import "forge-std/console.sol";
import "src/validator/ECDSAValidator.sol";


contract CreateAccount is Script {
function run() public {
uint256 key = vm.envUint("DEPLOYER_PRIVATE_KEY");
vm.startBroadcast(key);
KernelFactory kernelFactory = KernelFactory(0xc9683DFF173B60aCeF306525645AE6381726cC45);
IKernelValidator defaultValidator = new ECDSAValidator();
address accountProxy = kernelFactory.createAccount(
0x29C69905F09908C70da2D67a2B3d52B22E71F241, //0xf048AD83CB2dfd6037A43902a2A5Be04e53cd2Eb,
abi.encodeWithSelector(KernelStorage.initialize.selector, defaultValidator, abi.encodePacked(0x9fD431b7703f94289Ba02034631dcC302717805B)),
0
);
console.log("smart account created at: %s", accountProxy);
vm.stopBroadcast();
}
}

26 changes: 26 additions & 0 deletions src/Kernel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "account-abstraction/interfaces/IEntryPoint.sol";
import "./abstract/Compatibility.sol";
import "./abstract/KernelStorage.sol";
import "./utils/KernelHelper.sol";
import "./utils/Exec.sol";

import "src/common/Constants.sol";
import "src/common/Enum.sol";
Expand Down Expand Up @@ -78,6 +79,31 @@ contract Kernel is EIP712, Compatibility, KernelStorage {
}
}

function executeBatch(address[] memory dest, uint256[] memory values, bytes[] memory func, Operation operation)
external
{
if (msg.sender != address(entryPoint) && !_checkCaller()) {
revert NotAuthorizedCaller();
}
for (uint256 i = 0; i < dest.length; i++) {
if (operation == Operation.Call) {
(bool success, bytes memory ret) = Exec.call(dest[i], values[i], func[i]);
if (!success) {
assembly {
revert(add(ret, 32), mload(ret))
}
}
} else {
(bool success, bytes memory ret) = Exec.delegateCall(dest[i], func[i]);
if (!success) {
assembly {
revert(add(ret, 32), mload(ret))
}
}
}
}
}

/// @notice Validates a user operation based on its mode
/// @dev This function will validate user operation and be called by EntryPoint
/// @param userOp The user operation to be validated
Expand Down
Loading

0 comments on commit 5a56eb7

Please sign in to comment.