diff --git a/certora/conf/KintoID_Generic.conf b/certora/conf/KintoID_Generic.conf index f2e855f49..7b1d41740 100644 --- a/certora/conf/KintoID_Generic.conf +++ b/certora/conf/KintoID_Generic.conf @@ -7,7 +7,7 @@ "verify": "KintoIDHarness:certora/spec/Generic.spec", "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/certora/conf/KintoID_Monitor1.conf b/certora/conf/KintoID_Monitor1.conf index 343ccec7c..aca39aa7f 100644 --- a/certora/conf/KintoID_Monitor1.conf +++ b/certora/conf/KintoID_Monitor1.conf @@ -7,7 +7,7 @@ "verify": "KintoIDHarness:certora/spec/KintoID/Monitor.spec", "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/certora/conf/KintoID_Monitor2.conf b/certora/conf/KintoID_Monitor2.conf index 0e9f31ab9..b6c6ecaf3 100644 --- a/certora/conf/KintoID_Monitor2.conf +++ b/certora/conf/KintoID_Monitor2.conf @@ -7,7 +7,7 @@ "verify": "KintoIDHarness:certora/spec/KintoID/Monitor.spec", "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/certora/conf/KintoID_SanctionsTraits.conf b/certora/conf/KintoID_SanctionsTraits.conf index be11505ca..8dba72e24 100644 --- a/certora/conf/KintoID_SanctionsTraits.conf +++ b/certora/conf/KintoID_SanctionsTraits.conf @@ -7,7 +7,7 @@ "verify": "KintoIDHarness:certora/spec/KintoID/SanctionsTraits.spec", "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/certora/conf/KintoID_Viewer.conf b/certora/conf/KintoID_Viewer.conf index 995030f3d..f7ab79ad4 100644 --- a/certora/conf/KintoID_Viewer.conf +++ b/certora/conf/KintoID_Viewer.conf @@ -7,7 +7,7 @@ "verify":"KintoIDHarness:certora/spec/KintoID/Viewer.spec", "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/certora/conf/KintoWallet.conf b/certora/conf/KintoWallet.conf index 3118e6bfa..32b37514b 100644 --- a/certora/conf/KintoWallet.conf +++ b/certora/conf/KintoWallet.conf @@ -13,7 +13,7 @@ ], "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts', + '@aa/=node_modules/account-abstraction-0.7.0/contracts', 'ds-test/=node_modules/forge-std/lib/ds-test/src', 'forge-std/=node_modules/forge-std/src', diff --git a/certora/conf/KintoWalletFactory.conf b/certora/conf/KintoWalletFactory.conf index 5ddcf5c6a..c607987f7 100644 --- a/certora/conf/KintoWalletFactory.conf +++ b/certora/conf/KintoWalletFactory.conf @@ -6,7 +6,7 @@ "verify":"KintoWalletFactory:certora/spec/KintoWalletFactory/Factory.spec", "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/certora/conf/SponsorPaymaster.conf b/certora/conf/SponsorPaymaster.conf index 08b7ecbcb..9942d769e 100644 --- a/certora/conf/SponsorPaymaster.conf +++ b/certora/conf/SponsorPaymaster.conf @@ -16,7 +16,7 @@ ], "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/certora/conf/SponsorPaymaster_additional.conf b/certora/conf/SponsorPaymaster_additional.conf index 5d8c8141f..892174b6c 100644 --- a/certora/conf/SponsorPaymaster_additional.conf +++ b/certora/conf/SponsorPaymaster_additional.conf @@ -16,7 +16,7 @@ ], "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/foundry.toml b/foundry.toml index 31a29d117..874389bb0 100644 --- a/foundry.toml +++ b/foundry.toml @@ -11,7 +11,7 @@ ffi = true solc_version = "0.8.24" remappings = [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', @@ -28,7 +28,6 @@ remappings = [ '@openzeppelin/contracts-upgradeable/=node_modules/openzeppelin-contracts-upgradeable/', 'node_modules/account-abstraction:@openzeppelin/contracts/=node_modules/openzeppelin-contracts', - '@aa/=node_modules/account-abstraction/contracts/', '@solady/=node_modules/solady/src/', 'solady/=node_modules/solady/src/', diff --git a/remappings.txt b/remappings.txt deleted file mode 100644 index 66aa4d7f8..000000000 --- a/remappings.txt +++ /dev/null @@ -1,26 +0,0 @@ -ds-test/=lib/forge-std/lib/ds-test/src/ -forge-std/=lib/forge-std/src/ - -@kinto-core-script/=script/ -@kinto-core-test/=test/ -@kinto-core/=src/ - -lib/openzeppelin-contracts-upgradeable-5.0.1:@openzeppelin/=lib/openzeppelin-contracts-5.0.1 -lib/account-abstraction:@openzeppelin/=lib/openzeppelin-contracts -lib/account-abstraction-0.7.0:@openzeppelin/=lib/openzeppelin-contracts-5.0.1 - -@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ -@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/ - -@aa/=lib/account-abstraction-0.7.0/contracts - - -@openzeppelin-5.0.1/contracts/=lib/openzeppelin-contracts-5.0.1/contracts/ -@openzeppelin-5.0.1/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable-5.0.1/contracts/ - -@solady/=lib/solady/src/ - -@token-bridge-contracts/=lib/token-bridge-contracts/ -@nitro-contracts/=lib/nitro-contracts/ - -@alto/=lib/alto/contracts/ diff --git a/script/actions/deploy.s.sol b/script/actions/deploy.s.sol index 54b256f8f..8b23a6b7b 100644 --- a/script/actions/deploy.s.sol +++ b/script/actions/deploy.s.sol @@ -303,11 +303,6 @@ contract DeployerScript is Create2Helper, DeployerHelper { privateKey > 0 ? vm.broadcast(privateKey) : vm.broadcast(); _walletFactory.initialize(); - - // set wallet factory in EntryPoint - if (log) console.log("Setting wallet factory in entry point to: ", address(_walletFactory)); - privateKey > 0 ? vm.broadcast(privateKey) : vm.broadcast(); - entryPoint.setWalletFactory(address(_walletFactory)); } function deployKintoWallet() public returns (KintoWallet _kintoWallet) { diff --git a/script/actions/send-user-operation.s.sol b/script/actions/send-user-operation.s.sol index 825e5b6eb..40f477fff 100644 --- a/script/actions/send-user-operation.s.sol +++ b/script/actions/send-user-operation.s.sol @@ -1,7 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import {IEntryPoint, UserOperation} from "@aa/core/BaseAccount.sol"; +import {IEntryPoint} from "@aa/core/BaseAccount.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; @@ -21,25 +22,21 @@ contract SendUserOperationScript is MigrationHelper { uint256 nonce = json.readUint(".inflatedOp.nonce"); bytes memory callData = json.readBytes(".inflatedOp.callData"); bytes memory initCode = json.readBytes(".inflatedOp.initCode "); - uint256 callGasLimit = json.readUint(".inflatedOp.callGasLimit"); - uint256 verificationGasLimit = json.readUint(".inflatedOp.verificationGasLimit"); + bytes32 accountGasLimits = json.readBytes32(".inflatedOp.accountGasLimits"); + bytes32 gasFees = json.readBytes32(".inflatedOp.gasFees"); uint256 preVerificationGas = json.readUint(".inflatedOp.preVerificationGas"); - uint256 maxFeePerGas = json.readUint(".inflatedOp.maxFeePerGas"); - uint256 maxPriorityFeePerGas = json.readUint(".inflatedOp.maxPriorityFeePerGas"); bytes memory paymasterAndData = json.readBytes(".inflatedOp.paymasterAndData"); bytes memory signature = json.readBytes(".inflatedOp.signature"); - UserOperation[] memory userOps = new UserOperation[](1); - userOps[0] = UserOperation({ + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); + userOps[0] = PackedUserOperation({ sender: sender, nonce: nonce, initCode: initCode, callData: callData, - callGasLimit: callGasLimit, - verificationGasLimit: verificationGasLimit, preVerificationGas: preVerificationGas, - maxFeePerGas: maxFeePerGas, - maxPriorityFeePerGas: maxPriorityFeePerGas, + accountGasLimits: accountGasLimits, + gasFees: gasFees, paymasterAndData: paymasterAndData, signature: signature }); diff --git a/script/migrations/08-deploy_kinto_app.s.sol b/script/migrations/08-deploy_kinto_app.s.sol deleted file mode 100644 index 915ca3f87..000000000 --- a/script/migrations/08-deploy_kinto_app.s.sol +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "../../src/apps/KintoAppRegistry.sol"; -import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; -import "../../src/interfaces/IKintoWalletFactory.sol"; -import "../../test/helpers/Create2Helper.sol"; -import "../../test/helpers/ArtifactsReader.sol"; - -import "forge-std/Script.sol"; -import "forge-std/console.sol"; - -contract KintoMigration8DeployScript is Create2Helper, ArtifactsReader { - KintoAppRegistry _kintoApp; - KintoAppRegistry _kintoAppImpl; - - function setUp() public {} - - function run() public { - console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid)); - // Execute this script with the hot wallet - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - console.log("Executing with address", msg.sender); - address ledgerAdmin = vm.envAddress("LEDGER_ADMIN"); - console.log("Executing with ledger admin as", ledgerAdmin); - - address appAddr = _getChainDeployment("KintoAppRegistry"); - if (appAddr != address(0)) { - console.log("KintoAppRegistry already deployed", appAddr); - return; - } - address walletFactoryAddr = _getChainDeployment("KintoWalletFactory"); - IKintoWalletFactory _walletFactory = IKintoWalletFactory(walletFactoryAddr); - - bytes memory bytecode = - abi.encodePacked(type(KintoAppRegistry).creationCode, abi.encode(address(_walletFactory))); - _kintoAppImpl = - KintoAppRegistry(_walletFactory.deployContract{value: 0}(ledgerAdmin, 0, bytecode, bytes32("1"))); - vm.stopBroadcast(); - - // Writes the addresses to a file - console.log("Add these new addresses to the artifacts file"); - console.log(string.concat('"KintoAppRegistry-impl": "', vm.toString(address(_kintoAppImpl)), '"')); - } -} diff --git a/script/migrations/09-deploy_registry_proxy.s.sol b/script/migrations/09-deploy_registry_proxy.s.sol deleted file mode 100644 index 4d3aa1313..000000000 --- a/script/migrations/09-deploy_registry_proxy.s.sol +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "forge-std/Script.sol"; -import "../../src/apps/KintoAppRegistry.sol"; -import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; -import "../../src/wallet/KintoWalletFactory.sol"; -import {Create2Helper} from "../../test/helpers/Create2Helper.sol"; -import {ArtifactsReader} from "../../test/helpers/ArtifactsReader.sol"; -import {UUPSProxy} from "../../test/helpers/UUPSProxy.sol"; -import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol"; -import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; -import "forge-std/console.sol"; - -contract KintoMigration9DeployScript is Create2Helper, ArtifactsReader { - KintoAppRegistry _kintoApp; - KintoAppRegistry _kintoAppImpl; - - function setUp() public {} - - // solhint-disable code-complexity - function run() public { - console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid)); - // Execute this script with the hot wallet - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - console.log("Executing with address", msg.sender); - address ledgerAdmin = vm.envAddress("LEDGER_ADMIN"); - console.log("Executing with ledger admin as", ledgerAdmin); - - address appAddr = _getChainDeployment("KintoAppRegistry"); - if (appAddr != address(0)) { - console.log("KintoAppRegistry already deployed", appAddr); - return; - } - address walletFactoryAddr = _getChainDeployment("KintoWalletFactory"); - KintoWalletFactory _walletFactory = KintoWalletFactory(walletFactoryAddr); - address kintoAppRegistryImpl = _getChainDeployment("KintoAppRegistry-impl"); - - if (kintoAppRegistryImpl == address(0)) { - console.log("kintoAppRegistryImpl not deployed", appAddr); - return; - } - console.log("kintoAppRegistryImpl", kintoAppRegistryImpl); - bytes memory bytecode = - abi.encodePacked(type(UUPSProxy).creationCode, abi.encode(address(kintoAppRegistryImpl), bytes(""))); - // deploy _proxy contract and point it to _implementation - _kintoApp = KintoAppRegistry(_walletFactory.deployContract{value: 0}(ledgerAdmin, 0, bytecode, bytes32("10"))); - vm.stopBroadcast(); - - // Writes the addresses to a file - console.log("Add these new addresses to the artifacts file"); - console.log(string.concat('"KintoAppRegistry": "', vm.toString(address(_kintoApp)), '"')); - } -} diff --git a/script/migrations/10-upgrade_wallet_v3.s.sol b/script/migrations/10-upgrade_wallet_v3.s.sol deleted file mode 100644 index 1b3d7a443..000000000 --- a/script/migrations/10-upgrade_wallet_v3.s.sol +++ /dev/null @@ -1,70 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "../../src/wallet/KintoWalletFactory.sol"; -import "../../src/wallet/KintoWallet.sol"; -import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; - -import "../../test/helpers/Create2Helper.sol"; -import "../../test/helpers/ArtifactsReader.sol"; -import "../../test/helpers/UUPSProxy.sol"; - -import "forge-std/Script.sol"; -import "forge-std/console.sol"; - -contract KintoMigration10DeployScript is Create2Helper, ArtifactsReader { - KintoWalletFactory _walletFactory; - KintoWalletV3 _kintoWalletImpl; - UUPSProxy _proxy; - - function setUp() public {} - - function run() public { - console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid)); - // Execute this script with the hot wallet - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - console.log("Executing with address", msg.sender); - address walletFactoryAddr = _getChainDeployment("KintoWalletFactory"); - if (walletFactoryAddr == address(0)) { - console.log("Need to execute main deploy script first", walletFactoryAddr); - return; - } - address kintoAppAddr = _getChainDeployment("KintoAppRegistry"); - if (kintoAppAddr == address(0)) { - console.log("Need to deploy kinto app registry first", kintoAppAddr); - return; - } - _walletFactory = KintoWalletFactory(payable(walletFactoryAddr)); - - bytes memory bytecode = abi.encodePacked( - type(KintoWalletV3).creationCode, - abi.encode( - _getChainDeployment("EntryPoint"), - IKintoID(_getChainDeployment("KintoID")), - IKintoAppRegistry(_getChainDeployment("KintoAppRegistry")) - ) // Encoded constructor arguments - ); - - // Deploy new wallet implementation - _kintoWalletImpl = KintoWalletV3(payable(_walletFactory.deployContract(msg.sender, 0, bytecode, bytes32(0)))); - vm.stopBroadcast(); - vm.startBroadcast(); - // Upgrade all implementations - _walletFactory.upgradeAllWalletImplementations(_kintoWalletImpl); - address credits = _getChainDeployment("EngenCredits"); - // Fund in the paymaster - SponsorPaymaster _paymaster = SponsorPaymaster(payable(_getChainDeployment("SponsorPaymaster"))); - _paymaster.addDepositFor{value: 1e17}(credits); - vm.stopBroadcast(); - // Writes the addresses to a file - console.log("Add these new addresses to the artifacts file"); - console.log(string.concat('"KintoWalletV3-impl": "', vm.toString(address(_kintoWalletImpl)), '"')); - } -} - -contract KintoWalletV3 is KintoWallet { - constructor(IEntryPoint _entryPoint, IKintoID _kintoID, IKintoAppRegistry _appRegistry) - KintoWallet(_entryPoint, _kintoID, _appRegistry) - {} -} diff --git a/script/migrations/11-upgrade_paymasterv2.s.sol b/script/migrations/11-upgrade_paymasterv2.s.sol deleted file mode 100644 index 99085ce76..000000000 --- a/script/migrations/11-upgrade_paymasterv2.s.sol +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "../../src/wallet/KintoWalletFactory.sol"; -import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; - -import "../../test/helpers/Create2Helper.sol"; -import "../../test/helpers/ArtifactsReader.sol"; -import "../../test/helpers/UUPSProxy.sol"; -import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; - -import "forge-std/Script.sol"; -import "forge-std/console.sol"; - -contract KintoMigration11DeployScript is Create2Helper, ArtifactsReader { - SponsorPaymaster _paymaster; - KintoWalletFactory _walletFactory; - SponsorPaymasterV2 _paymasterImpl; - UUPSProxy _proxy; - - function setUp() public {} - - function run() public { - console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid)); - // Execute this script with the hot wallet and ledger - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - address sponsorAddr = _getChainDeployment("SponsorPaymaster"); - if (sponsorAddr == address(0)) { - console.log("Need to execute main deploy script first", sponsorAddr); - return; - } - _paymaster = SponsorPaymaster(payable(sponsorAddr)); - - _walletFactory = KintoWalletFactory(payable(_getChainDeployment("KintoWalletFactory"))); - bytes memory bytecode = abi.encodePacked( - type(SponsorPaymasterV2).creationCode, - abi.encode(_getChainDeployment("EntryPoint")) // Encoded constructor arguments - ); - - // Deploy new paymaster implementation - _paymasterImpl = SponsorPaymasterV2(payable(_walletFactory.deployContract(msg.sender, 0, bytecode, bytes32(0)))); - // Switch to admin to upgrade - vm.stopBroadcast(); - vm.startBroadcast(); - _paymaster.upgradeTo(address(_paymasterImpl)); - // Set the app registry - _paymaster.setAppRegistry(_getChainDeployment("KintoAppRegistry")); - vm.stopBroadcast(); - // Writes the addresses to a file - console.log("Add these new addresses to the artifacts file"); - console.log(string.concat('"SponsorPaymasterV2-impl": "', vm.toString(address(_paymasterImpl)), '"')); - } -} - -contract SponsorPaymasterV2 is SponsorPaymaster { - constructor(IEntryPoint __entryPoint) SponsorPaymaster(__entryPoint) {} -} diff --git a/script/migrations/12-create_engen_app.s.sol b/script/migrations/12-create_engen_app.s.sol index 37b855d36..b64ca557e 100644 --- a/script/migrations/12-create_engen_app.s.sol +++ b/script/migrations/12-create_engen_app.s.sol @@ -64,7 +64,7 @@ contract KintoMigration12DeployScript is ArtifactsReader, UserOp { privateKeys[0] = deployerPrivateKey; uint256 nonce = _kintoWallet.getNonce(); - UserOperation[] memory userOps = new UserOperation[](3); + PackedUserOperation[] memory userOps = new PackedUserOperation[](3); // whitelist Engen Credits & Registry address[] memory apps = new address[](2); diff --git a/script/migrations/121-upgrade_access_protocol.s.sol b/script/migrations/121-upgrade_access_protocol.s.sol index 29822d8a0..b4eb7eec5 100644 --- a/script/migrations/121-upgrade_access_protocol.s.sol +++ b/script/migrations/121-upgrade_access_protocol.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {IBridger} from "@kinto-core/interfaces/bridger/IBridger.sol"; import {UpgradeableBeacon} from "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; diff --git a/script/migrations/126-deploy-cross-chain-swap.s.sol b/script/migrations/126-deploy-cross-chain-swap.s.sol index 3898ff310..258879a35 100644 --- a/script/migrations/126-deploy-cross-chain-swap.s.sol +++ b/script/migrations/126-deploy-cross-chain-swap.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {IBridger} from "@kinto-core/interfaces/bridger/IBridger.sol"; import {UpgradeableBeacon} from "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; diff --git a/script/migrations/13-upgrade_id_paymasterv3.s.sol b/script/migrations/13-upgrade_id_paymasterv3.s.sol deleted file mode 100644 index 984147810..000000000 --- a/script/migrations/13-upgrade_id_paymasterv3.s.sol +++ /dev/null @@ -1,97 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "../../src/wallet/KintoWalletFactory.sol"; -import "../../src/wallet/KintoWallet.sol"; -import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; -import "../../src/KintoID.sol"; - -import "../../test/helpers/Create2Helper.sol"; -import "../../test/helpers/ArtifactsReader.sol"; -import "../../test/helpers/UUPSProxy.sol"; -import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; - -import "forge-std/Script.sol"; -import "forge-std/console.sol"; - -contract KintoIDV3 is KintoID { - constructor(address _walletFactory) KintoID(_walletFactory) {} -} - -contract KintoMigration13DeployScript is Create2Helper, ArtifactsReader { - KintoWalletFactory _walletFactory; - SponsorPaymaster _paymaster; - SponsorPaymasterV3 _paymasterImpl; - KintoID _kintoID; - KintoIDV3 _kintoIDImpl; - UUPSProxy _proxy; - - function setUp() public {} - - // NOTE: this migration must be run from the ledger admin - function run() public { - console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid)); - - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - - // execute this script with the with the ledger - console.log("Executing from address", msg.sender); - - // get wallet factory - _walletFactory = KintoWalletFactory(payable(_getChainDeployment("KintoWalletFactory"))); - - // (1). deploy new paymaster implementation via wallet factory - address sponsorAddr = _getChainDeployment("SponsorPaymaster"); - if (sponsorAddr == address(0)) { - console.log("Need to execute main deploy script first", sponsorAddr); - return; - } - _paymaster = SponsorPaymaster(payable(sponsorAddr)); - bytes memory bytecode = - abi.encodePacked(type(SponsorPaymasterV3).creationCode, abi.encode(_getChainDeployment("EntryPoint"))); - console.log("factory", address(_walletFactory)); - _paymasterImpl = SponsorPaymasterV3(payable(_walletFactory.deployContract(msg.sender, 0, bytecode, bytes32(0)))); - - // (2). deploy new kinto ID implementation via wallet factory - address kintoIDAddr = _getChainDeployment("KintoID"); - if (kintoIDAddr == address(0)) { - console.log("Need to execute main deploy script first", kintoIDAddr); - return; - } - _kintoID = KintoID(payable(kintoIDAddr)); - bytecode = abi.encodePacked(type(KintoIDV3).creationCode, abi.encode(_getChainDeployment("KintoWalletFactory"))); - _kintoIDImpl = KintoIDV3(payable(_walletFactory.deployContract(msg.sender, 0, bytecode, bytes32(0)))); - - vm.stopBroadcast(); - vm.startBroadcast(); - // (3). upgrade paymaster to new implementation - _paymaster.upgradeTo(address(_paymasterImpl)); - - // sanity check: paymaster's cost of op should be 200_000 - require(_paymaster.COST_OF_POST() == 200_000, "COST_OF_POST should be 200_000"); - - // (4). upgrade kinto id to new implementation - // vm.prank(_paymaster.owner()); - _kintoID.upgradeTo(address(_kintoIDImpl)); - - // sanity check: paymaster's cost of op should be 200_000 - try _kintoID.burn(10) { - revert("should have reverted"); - } catch Error(string memory reason) { - require( - keccak256(abi.encodePacked(reason)) == keccak256(abi.encodePacked("Use burnKYC instead")), - "Incorrect error reason" - ); - } - vm.stopBroadcast(); - // writes the addresses to a file - console.log("Add these new addresses to the artifacts file"); - console.log(string.concat('"SponsorPaymasterV3-impl": "', vm.toString(address(_paymasterImpl)), '"')); - console.log(string.concat('"KintoIDV3-impl": "', vm.toString(address(_kintoIDImpl)), '"')); - } -} - -contract SponsorPaymasterV3 is SponsorPaymaster { - constructor(IEntryPoint __entryPoint) SponsorPaymaster(__entryPoint) {} -} diff --git a/script/migrations/137-upgrade_wallet_factory.s.sol b/script/migrations/137-upgrade_wallet_factory.s.sol index bf5657685..c1ceb63b1 100644 --- a/script/migrations/137-upgrade_wallet_factory.s.sol +++ b/script/migrations/137-upgrade_wallet_factory.s.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.18; import "../../src/wallet/KintoWallet.sol"; import {KintoWalletFactory} from "../../src/wallet/KintoWalletFactory.sol"; +import {RewardsDistributor} from "@kinto-core/liquidity-mining/RewardsDistributor.sol"; import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; diff --git a/script/migrations/14-factory_v3.s.sol b/script/migrations/14-factory_v3.s.sol deleted file mode 100644 index b4302e5ca..000000000 --- a/script/migrations/14-factory_v3.s.sol +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "../../src/wallet/KintoWalletFactory.sol"; -import "../../src/wallet/KintoWallet.sol"; -import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; -import "../../src/KintoID.sol"; - -import "../../test/helpers/Create2Helper.sol"; -import "../../test/helpers/ArtifactsReader.sol"; -import "../../test/helpers/UUPSProxy.sol"; -import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; - -import "forge-std/Script.sol"; -import "forge-std/console.sol"; - -contract KintoWalletFactoryV3 is KintoWalletFactory { - constructor(IKintoWallet _implementation) KintoWalletFactory(_implementation) {} -} - -contract KintoIDV4 is KintoID { - constructor(address _walletFactory) KintoID(_walletFactory) {} -} - -contract KintoMigration14DeployScript is Create2Helper, ArtifactsReader { - KintoWalletFactoryV3 _factoryImpl; - KintoID _kintoID; - KintoIDV4 _kintoIDImpl; - - function setUp() public {} - - // NOTE: this migration must be run from the ledger admin - function run() public { - console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid)); - // Execute this script with the ledger admin but first we use the hot wallet - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - console.log("Executing with address", msg.sender, vm.envAddress("LEDGER_ADMIN")); - address factoryAddr = _getChainDeployment("KintoWalletFactory"); - if (factoryAddr == address(0)) { - console.log("Need to execute main deploy script first", factoryAddr); - return; - } - address v3factory = _getChainDeployment("KintoWalletFactoryV3-impl"); - if (v3factory != address(0)) { - console.log("V3 already deployed", v3factory); - return; - } - - address kintoIDAddr = _getChainDeployment("KintoID"); - if (kintoIDAddr == address(0)) { - console.log("Need to execute main deploy script first", kintoIDAddr); - return; - } - - IKintoWalletFactory _walletFactory = IKintoWalletFactory(payable(_getChainDeployment("KintoWalletFactory"))); - - address newImpl = _getChainDeployment("KintoWalletV3-impl"); - if (newImpl == address(0)) { - console.log("Need to deploy the new wallet first", newImpl); - return; - } - - bytes memory bytecode = abi.encodePacked( - type(KintoWalletFactoryV3).creationCode, - abi.encode(newImpl) // Encoded constructor arguments - ); - - // 1) Deploy new wallet factory - _factoryImpl = KintoWalletFactoryV3( - payable(_walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0))) - ); - - // (2). deploy new kinto ID implementation via wallet factory - - _kintoID = KintoID(payable(kintoIDAddr)); - bytecode = abi.encodePacked(type(KintoIDV4).creationCode, abi.encode(_getChainDeployment("KintoWalletFactory"))); - _kintoIDImpl = - KintoIDV4(payable(_walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0)))); - - vm.stopBroadcast(); - // Start admin - vm.startBroadcast(); - // 3) Upgrade wallet factory - KintoWalletFactory(address(_walletFactory)).upgradeTo(address(_factoryImpl)); - // (4). upgrade kinto id to new implementation - _kintoID.upgradeTo(address(_kintoIDImpl)); - vm.stopBroadcast(); - // writes the addresses to a file - console.log("Add these new addresses to the artifacts file"); - console.log(string.concat('"KintoWalletFactoryV3-impl": "', vm.toString(address(_factoryImpl)), '"')); - console.log(string.concat('"KintoIDV4-impl": "', vm.toString(address(_kintoIDImpl)), '"')); - } -} diff --git a/script/migrations/145-upgrade_access_protocol.s.sol b/script/migrations/145-upgrade_access_protocol.s.sol index 2d556ecff..2420da8b4 100644 --- a/script/migrations/145-upgrade_access_protocol.s.sol +++ b/script/migrations/145-upgrade_access_protocol.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {IBridger} from "@kinto-core/interfaces/bridger/IBridger.sol"; import {UpgradeableBeacon} from "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; diff --git a/script/migrations/148-transfer-access-registry-ownership.s.sol b/script/migrations/148-transfer-access-registry-ownership.s.sol index c3d67f50b..11d007873 100644 --- a/script/migrations/148-transfer-access-registry-ownership.s.sol +++ b/script/migrations/148-transfer-access-registry-ownership.s.sol @@ -8,7 +8,7 @@ import {AccessManager} from "@openzeppelin-5.0.1/contracts/access/manager/Access import {Ownable} from "@openzeppelin-5.0.1/contracts/access/Ownable.sol"; import {UUPSUpgradeable} from "@openzeppelin-5.0.1/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {IAccessPoint} from "@kinto-core/interfaces/IAccessPoint.sol"; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; diff --git a/script/migrations/16-factory_v4.s.sol b/script/migrations/16-factory_v4.s.sol deleted file mode 100644 index 35c533012..000000000 --- a/script/migrations/16-factory_v4.s.sol +++ /dev/null @@ -1,72 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "../../src/wallet/KintoWalletFactory.sol"; -import "../../src/wallet/KintoWallet.sol"; -import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; -import "../../src/KintoID.sol"; - -import "../../test/helpers/Create2Helper.sol"; -import "../../test/helpers/ArtifactsReader.sol"; -import "../../test/helpers/UUPSProxy.sol"; -import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; - -import "forge-std/Script.sol"; -import "forge-std/console.sol"; - -contract KintoWalletFactoryV4 is KintoWalletFactory { - constructor(IKintoWallet newWalletImpl) KintoWalletFactory(newWalletImpl) {} -} - -contract KintoMigration16DeployScript is Create2Helper, ArtifactsReader { - KintoWalletFactoryV4 _factoryImpl; - - function setUp() public {} - - // NOTE: this migration must be run from the ledger admin - function run() public { - console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid)); - // Execute this script with the ledger admin but first we use the hot wallet - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - console.log("Executing with address", msg.sender, vm.envAddress("LEDGER_ADMIN")); - address factoryAddr = _getChainDeployment("KintoWalletFactory"); - if (factoryAddr == address(0)) { - console.log("Need to execute main deploy script first", factoryAddr); - return; - } - address v3factory = _getChainDeployment("KintoWalletFactoryV4-impl"); - if (v3factory != address(0)) { - console.log("V4 already deployed", v3factory); - return; - } - - IKintoWalletFactory _walletFactory = IKintoWalletFactory(payable(_getChainDeployment("KintoWalletFactory"))); - - address newImpl = _getChainDeployment("KintoWalletV3-impl"); - if (newImpl == address(0)) { - console.log("Need to deploy the new wallet first", newImpl); - return; - } - - bytes memory bytecode = abi.encodePacked( - type(KintoWalletFactoryV4).creationCode, - abi.encode(newImpl) // Encoded constructor arguments - ); - - // 1) Deploy new wallet factory - _factoryImpl = KintoWalletFactoryV4( - payable(_walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0))) - ); - - vm.stopBroadcast(); - // Start admin - vm.startBroadcast(); - // 2) Upgrade wallet factory - KintoWalletFactory(address(_walletFactory)).upgradeTo(address(_factoryImpl)); - vm.stopBroadcast(); - // writes the addresses to a file - console.log("Add these new addresses to the artifacts file"); - console.log(string.concat('"KintoWalletFactoryV4-impl": "', vm.toString(address(_factoryImpl)), '"')); - } -} diff --git a/script/migrations/17-faucet_v3.s.sol b/script/migrations/17-faucet_v3.s.sol deleted file mode 100644 index 872bb27b4..000000000 --- a/script/migrations/17-faucet_v3.s.sol +++ /dev/null @@ -1,83 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; - -import "../../src/interfaces/IKintoWalletFactory.sol"; -import "../../src/interfaces/IKintoWallet.sol"; -import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; - -import "../../src/Faucet.sol"; - -import "../../test/helpers/Create2Helper.sol"; -import "../../test/helpers/ArtifactsReader.sol"; -import "../../test/helpers/UUPSProxy.sol"; -import "../../test/helpers/UserOp.sol"; -import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; - -import "forge-std/Script.sol"; -import "forge-std/console.sol"; - -contract FaucetV3 is Faucet { - constructor(address _kintoWalletFactory) Faucet(_kintoWalletFactory) {} -} - -contract KintoMigration15DeployScript is Create2Helper, ArtifactsReader, UserOp { - FaucetV3 _implementation; - UUPSProxy _proxy; - - function setUp() public {} - - function run() public { - console.log("Chain ID", vm.toString(block.chainid)); - - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - console.log("Deployer address: ", vm.addr(deployerPrivateKey)); - - vm.startBroadcast(deployerPrivateKey); - - address faucetProxy = payable(_getChainDeployment("Faucet")); - require(faucetProxy != address(0), "Faucet proxy is already deployed"); - - // make sure wallet faucet v3 is not deployed - require(_getChainDeployment("FaucetV3-impl") == address(0), "Faucet v3 is already deployed"); - - // use wallet factory to deploy new Faucet implementation - address factory = _getChainDeployment("KintoWalletFactory"); - IKintoWalletFactory walletFactory = IKintoWalletFactory(payable(factory)); - - // deploy Faucet implementation - bytes memory bytecode = abi.encodePacked(type(FaucetV3).creationCode, abi.encode(factory)); - _implementation = FaucetV3(payable(walletFactory.deployContract(msg.sender, 0, bytecode, bytes32(0)))); - - _upgradeTo(address(_implementation), deployerPrivateKey); - - vm.stopBroadcast(); - - console.log(string.concat("Faucet-impl: ", vm.toString(address(_implementation)))); - } - - function _upgradeTo(address _newFaucetImpl, uint256 _signerPk) internal { - address payable adminWallet = payable(_getChainDeployment("KintoWallet-admin")); - address payable faucetProxy = payable(_getChainDeployment("Faucet")); - - // prep upgradeTo user op - uint256 nonce = IKintoWallet(adminWallet).getNonce(); - uint256[] memory privateKeys = new uint256[](1); - privateKeys[0] = _signerPk; - UserOperation[] memory userOps = new UserOperation[](1); - userOps[0] = _createUserOperation( - block.chainid, - adminWallet, - faucetProxy, - 0, - nonce, - privateKeys, - abi.encodeWithSelector(UUPSUpgradeable.upgradeTo.selector, address(_newFaucetImpl)), - _getChainDeployment("SponsorPaymaster") - ); - - // execute transaction via entry point - IEntryPoint(_getChainDeployment("EntryPoint")).handleOps(userOps, payable(vm.addr(_signerPk))); - } -} diff --git a/script/migrations/19-fund2.s.sol b/script/migrations/19-fund2.s.sol deleted file mode 100644 index 933a2b31e..000000000 --- a/script/migrations/19-fund2.s.sol +++ /dev/null @@ -1,77 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "../../src/wallet/KintoWalletFactory.sol"; -import "../../src/wallet/KintoWallet.sol"; -import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; -import "../../src/KintoID.sol"; - -import "../../test/helpers/Create2Helper.sol"; -import "../../test/helpers/ArtifactsReader.sol"; -import "../../test/helpers/UUPSProxy.sol"; -import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; - -import "forge-std/Script.sol"; -import "forge-std/console.sol"; - -contract KintoWalletFactoryV5 is KintoWalletFactory { - constructor(IKintoWallet _implAddressP) KintoWalletFactory(_implAddressP) {} -} - -contract KintoMigration16DeployScript is Create2Helper, ArtifactsReader { - KintoWalletFactoryV5 _factoryImpl; - - function setUp() public {} - - // NOTE: this migration must be run from the ledger admin - function run() public { - console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid)); - // Execute this script with the ledger admin but first we use the hot wallet - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - console.log("Executing with address", msg.sender, vm.envAddress("LEDGER_ADMIN")); - address factoryAddr = _getChainDeployment("KintoWalletFactory"); - if (factoryAddr == address(0)) { - console.log("Need to execute main deploy script first", factoryAddr); - return; - } - address v5factory = _getChainDeployment("KintoWalletFactoryV5-impl"); - if (v5factory != address(0)) { - console.log("V5 already deployed", v5factory); - return; - } - - IKintoWalletFactory _walletFactory = IKintoWalletFactory(payable(_getChainDeployment("KintoWalletFactory"))); - - address newImpl = _getChainDeployment("KintoWalletV3-impl"); - if (newImpl == address(0)) { - console.log("Need to deploy the new wallet first", newImpl); - return; - } - - bytes memory bytecode = abi.encodePacked( - type(KintoWalletFactoryV5).creationCode, - abi.encode(newImpl) // Encoded constructor arguments - ); - - // 1) Deploy new wallet factory - _factoryImpl = KintoWalletFactoryV5( - payable(_walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0))) - ); - - vm.stopBroadcast(); - // Start admin - vm.startBroadcast(); - // 2) Upgrade wallet factory - KintoWalletFactory(address(_walletFactory)).upgradeTo(address(_factoryImpl)); - // 3) Send ETH to test signer - KintoWalletFactory(address(_walletFactory)).sendMoneyToAccount{value: 0.05 ether}( - 0x0C1df30B4576A1A94D9528854516D4d425Cf9323 - ); - require(address(0x0C1df30B4576A1A94D9528854516D4d425Cf9323).balance > 0.05 ether, "amount was not sent"); - vm.stopBroadcast(); - // writes the addresses to a file - console.log("Add these new addresses to the artifacts file"); - console.log(string.concat('"KintoWalletFactoryV5-impl": "', vm.toString(address(_factoryImpl)), '"')); - } -} diff --git a/script/migrations/20-faucet_fund_fix.s.sol b/script/migrations/20-faucet_fund_fix.s.sol deleted file mode 100644 index e26e616cd..000000000 --- a/script/migrations/20-faucet_fund_fix.s.sol +++ /dev/null @@ -1,81 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "../../src/wallet/KintoWalletFactory.sol"; -import "../../src/wallet/KintoWallet.sol"; -import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; -import "../../src/KintoID.sol"; - -import "../../test/helpers/Create2Helper.sol"; -import "../../test/helpers/ArtifactsReader.sol"; -import "../../test/helpers/UUPSProxy.sol"; -import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; - -import "forge-std/Script.sol"; -import "forge-std/console.sol"; - -contract KintoMigration20DeployScript is Create2Helper, ArtifactsReader { - KintoWalletFactoryV6 _factoryImpl; - - function setUp() public {} - - // NOTE: this migration must be run from the ledger admin - function run() public { - console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid)); - // Execute this script with the ledger admin but first we use the hot wallet - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - console.log("Executing with address", msg.sender, vm.envAddress("LEDGER_ADMIN")); - address factoryAddr = _getChainDeployment("KintoWalletFactory"); - if (factoryAddr == address(0)) { - console.log("Need to execute main deploy script first", factoryAddr); - return; - } - address v5factory = _getChainDeployment("KintoWalletFactoryV5-impl"); - if (v5factory != address(0)) { - console.log("V5 already deployed", v5factory); - return; - } - - IKintoWalletFactory _walletFactory = IKintoWalletFactory(payable(_getChainDeployment("KintoWalletFactory"))); - - address newImpl = _getChainDeployment("KintoWalletV3-impl"); - if (newImpl == address(0)) { - console.log("Need to deploy the new wallet first", newImpl); - return; - } - - bytes memory bytecode = abi.encodePacked( - type(KintoWalletFactoryV6).creationCode, - abi.encode(newImpl) // Encoded constructor arguments - ); - - // 1) Deploy new wallet factory - _factoryImpl = KintoWalletFactoryV6( - payable(_walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0))) - ); - - // 2) Send ETH to faucet - address _faucet = _getChainDeployment("Faucet"); - KintoWalletFactory(address(_walletFactory)).sendMoneyToAccount{value: 0.7 ether}(_faucet); - require(address(_faucet).balance >= 0.7 ether, "amount was not sent"); - vm.stopBroadcast(); - // Start admin - vm.startBroadcast(); - // 3) Upgrade wallet factory - KintoWalletFactory(address(_walletFactory)).upgradeTo(address(_factoryImpl)); - // writes the addresses to a file - console.log("Add these new addresses to the artifacts file"); - console.log(string.concat('"KintoWalletFactoryV6-impl": "', vm.toString(address(_factoryImpl)), '"')); - } -} - -contract KintoWalletFactoryV6 is KintoWalletFactory { - constructor(IKintoWallet _implAddressP) KintoWalletFactory(_implAddressP) {} -} - -contract KintoWalletV3 is KintoWallet { - constructor(IEntryPoint _entryPoint, IKintoID _kintoID, IKintoAppRegistry _appRegistry) - KintoWallet(_entryPoint, _kintoID, _appRegistry) - {} -} diff --git a/script/migrations/21-multiple_upgrade.s.sol b/script/migrations/21-multiple_upgrade.s.sol deleted file mode 100644 index ffcd4d1d8..000000000 --- a/script/migrations/21-multiple_upgrade.s.sol +++ /dev/null @@ -1,248 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "../../src/wallet/KintoWalletFactory.sol"; -import "../../src/wallet/KintoWallet.sol"; -import "../../src/apps/KintoAppRegistry.sol"; -import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; -import "../../src/viewers/KYCViewer.sol"; -import "../../src/KintoID.sol"; - -import "../../test/helpers/Create2Helper.sol"; -import "../../test/helpers/ArtifactsReader.sol"; -import "../../test/helpers/UUPSProxy.sol"; -import "../../test/helpers/UserOp.sol"; -import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; - -import "forge-std/Script.sol"; -import "forge-std/console.sol"; - -contract KYCViewerV2 is KYCViewer { - constructor(address _kintoWalletFactory, address _faucet, address _engenCredits) - KYCViewer(_kintoWalletFactory, address(0), address(0)) - {} -} - -contract KintoWalletFactoryV7 is KintoWalletFactory { - constructor(IKintoWallet _implAddressP) KintoWalletFactory(_implAddressP) {} -} - -contract SponsorPaymasterV4 is SponsorPaymaster { - constructor(IEntryPoint __entryPoint) SponsorPaymaster(__entryPoint) {} -} - -contract KintoWalletV4 is KintoWallet { - constructor(IEntryPoint _entryPoint, IKintoID _kintoID, IKintoAppRegistry _appRegistry) - KintoWallet(_entryPoint, _kintoID, _appRegistry) - {} -} - -contract KintoAppRegistryV3 is KintoAppRegistry { - constructor(IKintoWalletFactory _walletFactory) KintoAppRegistry(_walletFactory) {} -} - -contract KintoMigration21DeployScript is Create2Helper, ArtifactsReader, UserOp { - KintoWalletFactory _walletFactory; - uint256 deployerPrivateKey; - - // NOTE: this migration must be run from the ledger admin - function run() public { - console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid)); - - deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - - // execute this script with the with the ledger - console.log("Executing from address", msg.sender); - - // set wallet factory - _walletFactory = KintoWalletFactory(payable(_getChainDeployment("KintoWalletFactory"))); - - // deploy contracts - address _paymasterImpl = upgradePaymaster(); - address _registryImpl = upgradeRegistry(); - address _walletImpl = upgradeWallet(); - address _factoryImpl = upgradeFactory(); - (address _kycViewerImpl, address _kycViewerProxy) = upgradeKYCViewer(); - - // writes the addresses to a file - console.log("TODO: Manually add these new addresses to the artifacts file"); - console.log(string.concat("SponsorPaymasterV4-impl: ", vm.toString(address(_paymasterImpl)))); - console.log(string.concat("KintoAppRegistryV3-impl: ", vm.toString(address(_registryImpl)))); - console.log(string.concat("KintoWalletV4-impl: ", vm.toString(address(_walletImpl)))); - console.log(string.concat("KintoWalletFactoryV7-impl: ", vm.toString(address(_factoryImpl)))); - console.log(string.concat("KYCViewerV2-impl: ", vm.toString(address(_kycViewerImpl)))); - console.log(string.concat("KYCViewerV2: ", vm.toString(address(_kycViewerProxy)))); - } - - function upgradePaymaster() public returns (address _paymasterImpl) { - // (1). deploy new paymaster implementation via wallet factory - address paymasterProxy = _getChainDeployment("SponsorPaymaster"); - require(paymasterProxy != address(0), "Need to execute main deploy script first"); - - bytes memory bytecode = - abi.encodePacked(type(SponsorPaymasterV4).creationCode, abi.encode(_getChainDeployment("EntryPoint"))); - - vm.broadcast(deployerPrivateKey); - _paymasterImpl = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0)); - - // (3). upgrade paymaster to new implementation - vm.broadcast(); // requires LEDGER_ADMIN - // vm.prank(vm.envAddress("LEDGER_ADMIN")); - SponsorPaymaster(payable(paymasterProxy)).upgradeTo(address(_paymasterImpl)); - } - - function upgradeRegistry() public returns (address _registryImpl) { - // (1). deploy new kinto registry implementation via wallet factory - address registryProxy = _getChainDeployment("KintoAppRegistry"); - require(registryProxy != address(0), "Need to execute main deploy script first"); - - bytes memory bytecode = - abi.encodePacked(type(KintoAppRegistryV3).creationCode, abi.encode(address(_walletFactory))); - - vm.broadcast(deployerPrivateKey); - _registryImpl = - _walletFactory.deployContract{value: 0}(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32("1")); - - // (2). upgrade registry to new implementation - _upgradeTo(payable(registryProxy), _registryImpl, deployerPrivateKey); - _transferOwnership(registryProxy, deployerPrivateKey, vm.envAddress("LEDGER_ADMIN")); - } - - function upgradeWallet() public returns (address _walletImpl) { - // (1). deploy new kinto wallet implementation via wallet factory - bytes memory bytecode = abi.encodePacked( - type(KintoWalletV4).creationCode, - abi.encode( - _getChainDeployment("EntryPoint"), - IKintoID(_getChainDeployment("KintoID")), - IKintoAppRegistry(_getChainDeployment("KintoAppRegistry")) - ) - ); - - vm.broadcast(deployerPrivateKey); - _walletImpl = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0)); - - // (2). upgrade all implementations - vm.broadcast(); // requires LEDGER_ADMIN - // vm.prank(vm.envAddress("LEDGER_ADMIN")); - _walletFactory.upgradeAllWalletImplementations(IKintoWallet(_walletImpl)); - } - - function upgradeFactory() public returns (address _factoryImpl) { - // (1). deploy new kinto factory - address factoryProxy = _getChainDeployment("KintoWalletFactory"); - require(factoryProxy != address(0), "Need to execute main deploy script first"); - - address _walletImpl = _getChainDeployment("KintoWalletV3-impl"); - require(_walletImpl != address(0), "Need to deploy the new wallet first"); - - bytes memory bytecode = abi.encodePacked( - type(KintoWalletFactoryV7).creationCode, - abi.encode(_walletImpl) // Encoded constructor arguments - ); - - vm.broadcast(deployerPrivateKey); - _factoryImpl = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0)); - - // (2). upgrade factory to new implementation - vm.broadcast(); // requires LEDGER_ADMIN - // vm.prank(vm.envAddress("LEDGER_ADMIN")); - KintoWalletFactory(payable(factoryProxy)).upgradeTo(address(_factoryImpl)); - } - - function upgradeKYCViewer() public returns (address _kycViewerImpl, address _proxy) { - // make sure kyc viewer proxy is not already deployed - address viewerProxy = payable(_getChainDeployment("KYCViewer")); - require(viewerProxy == address(0), "KYCViewer proxy is already deployed"); - - // (1). deploy KYCViewerV2 implementation - bytes memory bytecode = abi.encodePacked(type(KYCViewerV2).creationCode, abi.encode(_walletFactory)); - - vm.broadcast(deployerPrivateKey); - _kycViewerImpl = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0)); - - // (2). deploy KYCViewerV2 proxy - bytecode = abi.encodePacked(type(UUPSProxy).creationCode, abi.encode(address(_kycViewerImpl), "")); - - vm.broadcast(deployerPrivateKey); - _proxy = _walletFactory.deployContract(vm.envAddress("LEDGER_ADMIN"), 0, bytecode, bytes32(0)); - - _initialize(_proxy, deployerPrivateKey); - _transferOwnership(_proxy, deployerPrivateKey, vm.envAddress("LEDGER_ADMIN")); - } - - function _upgradeTo(address _proxy, address _newImpl, uint256 _signerPk) internal { - address payable _from = payable(_getChainDeployment("KintoWallet-admin")); - - // prep upgradeTo user op - uint256 nonce = IKintoWallet(_from).getNonce(); - uint256[] memory privateKeys = new uint256[](1); - privateKeys[0] = _signerPk; - UserOperation[] memory userOps = new UserOperation[](1); - userOps[0] = _createUserOperation( - block.chainid, - _from, - _proxy, - 0, - nonce, - privateKeys, - abi.encodeWithSelector(UUPSUpgradeable.upgradeTo.selector, address(_newImpl)), - _getChainDeployment("SponsorPaymaster") - ); - - vm.broadcast(deployerPrivateKey); - IEntryPoint(_getChainDeployment("EntryPoint")).handleOps(userOps, payable(vm.addr(_signerPk))); - } - - function _initialize(address _proxy, uint256 _signerPk) internal { - address payable _from = payable(_getChainDeployment("KintoWallet-admin")); - - // fund _proxy in the paymaster - ISponsorPaymaster _paymaster = ISponsorPaymaster(_getChainDeployment("SponsorPaymaster")); - vm.broadcast(deployerPrivateKey); - _paymaster.addDepositFor{value: 0.00000001 ether}(_proxy); - assertEq(_paymaster.balances(_proxy), 0.00000001 ether); - - // prep upgradeTo user op - uint256 nonce = IKintoWallet(_from).getNonce(); - uint256[] memory privateKeys = new uint256[](1); - privateKeys[0] = _signerPk; - UserOperation[] memory userOps = new UserOperation[](1); - userOps[0] = _createUserOperation( - block.chainid, - _from, - _proxy, - 0, - nonce, - privateKeys, - abi.encodeWithSelector(KYCViewer.initialize.selector), - _getChainDeployment("SponsorPaymaster") - ); - - vm.broadcast(deployerPrivateKey); - IEntryPoint(_getChainDeployment("EntryPoint")).handleOps(userOps, payable(vm.addr(_signerPk))); - } - - function _transferOwnership(address _proxy, uint256 _signerPk, address _newOwner) internal { - address payable _from = payable(_getChainDeployment("KintoWallet-admin")); - - // prep upgradeTo user op - uint256 nonce = IKintoWallet(_from).getNonce(); - uint256[] memory privateKeys = new uint256[](1); - privateKeys[0] = _signerPk; - UserOperation[] memory userOps = new UserOperation[](1); - userOps[0] = _createUserOperation( - block.chainid, - _from, - _proxy, - 0, - nonce, - privateKeys, - abi.encodeWithSelector(Ownable.transferOwnership.selector, _newOwner), - _getChainDeployment("SponsorPaymaster") - ); - - vm.broadcast(deployerPrivateKey); - IEntryPoint(_getChainDeployment("EntryPoint")).handleOps(userOps, payable(vm.addr(_signerPk))); - } -} diff --git a/script/migrations/27-deploy_registry-v4.s.sol b/script/migrations/27-deploy_registry-v4.s.sol index 61b6ec541..554083a00 100644 --- a/script/migrations/27-deploy_registry-v4.s.sol +++ b/script/migrations/27-deploy_registry-v4.s.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; +import {IKintoAppRegistry} from "@kinto-core/interfaces/IKintoAppRegistry.sol"; import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; import {KintoAppRegistry} from "@kinto-core/apps/KintoAppRegistry.sol"; diff --git a/script/samples/counter.s.sol b/script/samples/counter.s.sol index a96047747..c4c8ee3b6 100644 --- a/script/samples/counter.s.sol +++ b/script/samples/counter.s.sol @@ -72,7 +72,7 @@ contract KintoCounterScript is MigrationHelper { uint256[] memory privateKeys = new uint256[](1); privateKeys[0] = deployerPrivateKey; - UserOperation[] memory userOps = new UserOperation[](2); + PackedUserOperation[] memory userOps = new PackedUserOperation[](2); // whitelist counter contract in the wallet address[] memory targets = new address[](1); diff --git a/script/samples/guesser.s.sol b/script/samples/guesser.s.sol index 5ed298433..1f52c7c26 100644 --- a/script/samples/guesser.s.sol +++ b/script/samples/guesser.s.sol @@ -74,7 +74,7 @@ contract KintoGuesserScript is MigrationHelper { uint256 nonce = _newWallet.getNonce(); uint256[] memory privateKeys = new uint256[](1); privateKeys[0] = deployerPrivateKey; - UserOperation[] memory userOps = new UserOperation[](2); + PackedUserOperation[] memory userOps = new PackedUserOperation[](2); // whitelist ETHPriceIsRight contract in the wallet address[] memory targets = new address[](1); diff --git a/script/utils/MigrationHelper.sol b/script/utils/MigrationHelper.sol index 1a3404cd5..d46554cd0 100644 --- a/script/utils/MigrationHelper.sol +++ b/script/utils/MigrationHelper.sol @@ -349,9 +349,9 @@ contract MigrationHelper is Script, DeployerHelper, SignatureHelper, UserOp, Sal uint256[] memory privateKeys = new uint256[](1); privateKeys[0] = signerPk; - PackedUserOperation[] memory userOps = new PackedUserOperation[](_selectorAndParams.length); - uint256 nonce = IKintoWallet(_from).getNonce(); - for (uint256 i = 0; i < _selectorAndParams.length; i++) { + PackedUserOperation[] memory userOps = new PackedUserOperation[](selectorAndParams.length); + uint256 nonce = IKintoWallet(from).getNonce(); + for (uint256 i = 0; i < selectorAndParams.length; i++) { userOps[i] = _createUserOperation( block.chainid, from, tos[i], 0, nonce, privateKeys, selectorAndParams[i], sponsorPaymaster ); @@ -370,7 +370,7 @@ contract MigrationHelper is Script, DeployerHelper, SignatureHelper, UserOp, Sal require(selectorAndParams.length == tos.length, "selectorAndParams and tos mismatch"); address payable from = payable(kintoAdminWallet); - UserOperation[] memory userOps = new UserOperation[](selectorAndParams.length); + PackedUserOperation[] memory userOps = new PackedUserOperation[](selectorAndParams.length); uint256 nonce = IKintoWallet(from).getNonce(); for (uint256 i = 0; i < selectorAndParams.length; i++) { userOps[i] = _createUserOperation( diff --git a/src/inflators/BundleBulker.sol b/src/inflators/BundleBulker.sol index a5b2c6499..bdd7ec1a1 100644 --- a/src/inflators/BundleBulker.sol +++ b/src/inflators/BundleBulker.sol @@ -2,6 +2,7 @@ pragma solidity >=0.8; import "../interfaces/IInflator.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; /** diff --git a/src/inflators/KintoInflator.sol b/src/inflators/KintoInflator.sol index d78eedbed..158df4b6e 100644 --- a/src/inflators/KintoInflator.sol +++ b/src/inflators/KintoInflator.sol @@ -30,7 +30,7 @@ import "@solady/utils/LibZip.sol"; /// 0x04 .. 0x80: number of operations in the batch /// The rest of the flags are not used. -/// All other UserOperation fields are encoded as is. +/// All other PackedUserOperation fields are encoded as is. contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { /// @notice Mapping of Kinto contract names to addresses mapping(string => address) public kintoContracts; @@ -66,9 +66,9 @@ contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { /* ============ Inflate & Compress ============ */ /** - * @notice Inflates a compressed UserOperation - * @param compressed The compressed UserOperation as bytes - * @return op The inflated UserOperation + * @notice Inflates a compressed PackedUserOperation + * @param compressed The compressed PackedUserOperation as bytes + * @return op The inflated PackedUserOperation */ function inflate(bytes calldata compressed) external view returns (PackedUserOperation memory op) { // decompress the data @@ -108,21 +108,15 @@ contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { op.callData = callData; // extract gas parameters and other values using direct conversions - op.callGasLimit = uint256(bytes32(decompressed[cursor:cursor + 32])); + op.accountGasLimits = bytes32(decompressed[cursor:cursor + 32]); cursor += 32; - op.verificationGasLimit = uint256(bytes32(decompressed[cursor:cursor + 32])); + op.gasFees = bytes32(decompressed[cursor:cursor + 32]); cursor += 32; op.preVerificationGas = uint32(bytes4(decompressed[cursor:cursor + 4])); cursor += 4; - op.maxFeePerGas = uint48(bytes6(decompressed[cursor:cursor + 6])); - cursor += 6; - - op.maxPriorityFeePerGas = uint48(bytes6(decompressed[cursor:cursor + 6])); - cursor += 6; - // Extract paymasterAndData if the flag is set if (flags & 0x02 == 0x02) { op.paymasterAndData = abi.encodePacked(kintoContracts["SP"]); @@ -138,9 +132,9 @@ contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { } /** - * @notice Compresses a UserOperation for efficient storage and transmission - * @param op The UserOperation to compress - * @return compressed The compressed UserOperation as bytes + * @notice Compresses a PackedUserOperation for efficient storage and transmission + * @param op The PackedUserOperation to compress + * @return compressed The compressed PackedUserOperation as bytes */ function compress(PackedUserOperation memory op) external view returns (bytes memory compressed) { // initialize a dynamic bytes array for the pre-compressed data @@ -170,14 +164,7 @@ contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { } // encode gas params - buffer = abi.encodePacked( - buffer, - op.callGasLimit, - op.verificationGasLimit, - uint32(op.preVerificationGas), - uint48(op.maxFeePerGas), - uint48(op.maxPriorityFeePerGas) - ); + buffer = abi.encodePacked(buffer, op.accountGasLimits, op.gasFees, uint32(op.preVerificationGas)); // encode `signature` content buffer = abi.encodePacked(buffer, uint32(op.signature.length), op.signature); @@ -188,20 +175,20 @@ contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { /* ============ Simple compress/inflate ============ */ /** - * @notice Inflates a UserOperation compressed with the simple algorithm - * @param compressed The compressed UserOperation as bytes - * @return op The inflated UserOperation + * @notice Inflates a PackedUserOperation compressed with the simple algorithm + * @param compressed The compressed PackedUserOperation as bytes + * @return op The inflated PackedUserOperation */ function inflateSimple(bytes calldata compressed) external pure returns (PackedUserOperation memory op) { op = abi.decode(LibZip.flzDecompress(compressed), (PackedUserOperation)); } /** - * @notice Compresses a UserOperation using a simple compression algorithm - * @param op The UserOperation to compress - * @return compressed The compressed UserOperation as bytes + * @notice Compresses a PackedUserOperation using a simple compression algorithm + * @param op The PackedUserOperation to compress + * @return compressed The compressed PackedUserOperation as bytes */ - function compressSimple(UserOperation memory op) external pure returns (bytes memory compressed) { + function compressSimple(PackedUserOperation memory op) external pure returns (bytes memory compressed) { compressed = LibZip.flzCompress(abi.encode(op)); } @@ -305,9 +292,9 @@ contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { /* ============ Compress Helpers ============ */ /** - * @notice Determines the flags for a UserOperation + * @notice Determines the flags for a PackedUserOperation * @param selector The function selector - * @param op The UserOperation + * @param op The PackedUserOperation * @param callData The calldata * @return flags The determined flags */ @@ -335,7 +322,7 @@ contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { /** * @notice Encodes the calldata for an execute operation - * @param op The UserOperation + * @param op The PackedUserOperation * @param target The target address * @param value The value to send * @param bytesOp The operation bytes diff --git a/src/interfaces/IInflator.sol b/src/interfaces/IInflator.sol index d7d96718d..b52d00c84 100644 --- a/src/interfaces/IInflator.sol +++ b/src/interfaces/IInflator.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8; -import "./IKintoEntryPoint.sol"; +import {EntryPoint} from "@aa/core/EntryPoint.sol"; import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; interface IInflator { diff --git a/src/interfaces/IKintoEntryPoint.sol b/src/interfaces/IKintoEntryPoint.sol deleted file mode 100644 index 17227450e..000000000 --- a/src/interfaces/IKintoEntryPoint.sol +++ /dev/null @@ -1,11 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "@aa/interfaces/IEntryPoint.sol"; - -interface IKintoEntryPoint is IEntryPoint { - function walletFactory() external view returns (address); - - // Admin - function setWalletFactory(address _walletFactory) external; -} diff --git a/src/paymasters/SponsorPaymaster.sol b/src/paymasters/SponsorPaymaster.sol index c5c267ca3..bcc120030 100644 --- a/src/paymasters/SponsorPaymaster.sol +++ b/src/paymasters/SponsorPaymaster.sol @@ -4,10 +4,10 @@ pragma solidity ^0.8.18; import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; import {IEntryPoint} from "@aa/core/BaseAccount.sol"; import {IPaymaster} from "@aa/interfaces/IPaymaster.sol"; -import {BasePaymaster} from "@aa/core/BasePaymaster.sol"; import {UserOperationLib} from "@aa/core/UserOperationLib.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; @@ -28,12 +28,26 @@ import {IKintoWalletFactory} from "@kinto-core/interfaces/IKintoWalletFactory.so abstract contract BasePaymaster is IPaymaster, Ownable { IEntryPoint public immutable entryPoint; - constructor(IEntryPoint _entryPoint) { + uint256 internal constant PAYMASTER_VALIDATION_GAS_OFFSET = UserOperationLib.PAYMASTER_VALIDATION_GAS_OFFSET; + uint256 internal constant PAYMASTER_POSTOP_GAS_OFFSET = UserOperationLib.PAYMASTER_POSTOP_GAS_OFFSET; + uint256 internal constant PAYMASTER_DATA_OFFSET = UserOperationLib.PAYMASTER_DATA_OFFSET; + + constructor(IEntryPoint _entryPoint) Ownable() { + _validateEntryPointInterface(_entryPoint); entryPoint = _entryPoint; } + //sanity check: make sure this EntryPoint was compiled against the same + // IEntryPoint of this paymaster + function _validateEntryPointInterface(IEntryPoint _entryPoint) internal virtual { + require( + IERC165(address(_entryPoint)).supportsInterface(type(IEntryPoint).interfaceId), + "IEntryPoint interface mismatch" + ); + } + /// @inheritdoc IPaymaster - function validatePaymasterUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost) + function validatePaymasterUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost) external override returns (bytes memory context, uint256 validationData) @@ -48,15 +62,18 @@ abstract contract BasePaymaster is IPaymaster, Ownable { * @param userOpHash - The hash of the user operation. * @param maxCost - The maximum cost of the user operation. */ - function _validatePaymasterUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost) + function _validatePaymasterUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost) internal virtual returns (bytes memory context, uint256 validationData); /// @inheritdoc IPaymaster - function postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost) external override { + function postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost, uint256 actualUserOpFeePerGas) + external + override + { _requireFromEntryPoint(); - _postOp(mode, context, actualGasCost); + _postOp(mode, context, actualGasCost, actualUserOpFeePerGas); } /** @@ -66,14 +83,19 @@ abstract contract BasePaymaster is IPaymaster, Ownable { * it must also implement this method. * @param mode - Enum with the following options: * opSucceeded - User operation succeeded. - * opReverted - User op reverted. still has to pay for gas. - * postOpReverted - User op succeeded, but caused postOp (in mode=opSucceeded) to revert. - * Now this is the 2nd call, after user's op was deliberately reverted. + * opReverted - User op reverted. The paymaster still has to pay for gas. + * postOpReverted - never passed in a call to postOp(). * @param context - The context value returned by validatePaymasterUserOp * @param actualGasCost - Actual gas used so far (without this postOp call). + * @param actualUserOpFeePerGas - the gas price this UserOp pays. This value is based on the UserOp's maxFeePerGas + * and maxPriorityFee (and basefee) + * It is not the same as tx.gasprice, which is what the bundler pays. */ - function _postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost) internal virtual { - (mode, context, actualGasCost); // unused params + function _postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost, uint256 actualUserOpFeePerGas) + internal + virtual + { + (mode, context, actualGasCost, actualUserOpFeePerGas); // unused params // subclass must override this method if validatePaymasterUserOp returns a context revert("must override"); } @@ -336,16 +358,18 @@ contract SponsorPaymaster is Initializable, BasePaymaster, UUPSUpgradeable, Reen { (userOpHash); + uint256 postOpGasLimit = userOp.unpackPostOpGasLimit(); + uint256 verificationGasLimit = userOp.unpackVerificationGasLimit(); + uint256 maxFeePerGas = userOp.unpackMaxFeePerGas(); // verificationGasLimit is dual-purposed, as gas limit for postOp. make sure it is high enough - if (userOp.verificationGasLimit < COST_OF_POST || userOp.verificationGasLimit > MAX_COST_OF_VERIFICATION) { + if (postOpGasLimit < COST_OF_POST || verificationGasLimit > MAX_COST_OF_VERIFICATION) { revert GasOutsideRangeForPostOp(); } if (userOp.preVerificationGas > MAX_COST_OF_PREVERIFICATION) revert GasTooHighForVerification(); if (userOp.paymasterAndData.length != 20) revert PaymasterAndDataLengthInvalid(); // use maxFeePerGas for conservative estimation of gas cost - uint256 gasPriceUserOp = userOp.maxFeePerGas; - uint256 ethMaxCost = (maxCost + COST_OF_POST * gasPriceUserOp); + uint256 ethMaxCost = (maxCost + COST_OF_POST * maxFeePerGas); if (ethMaxCost > userOpMaxCost) revert GasTooHighForUserOp(); address sponsor = appRegistry.getApp(_decodeCallData(userOp.callData)); @@ -358,13 +382,18 @@ contract SponsorPaymaster is Initializable, BasePaymaster, UUPSUpgradeable, Reen // Wallets get auto funded by kinto core app sponsor = appRegistry.getApp(address(walletFactory)); } - return (abi.encode(sponsor, userOp.sender, userOp.maxFeePerGas, userOp.maxPriorityFeePerGas), 0); + return (abi.encode(sponsor, userOp.sender, maxFeePerGas, userOp.unpackMaxPriorityFeePerGas()), 0); } /** * @notice performs the post-operation to charge the sponsor contract for the gas. */ - function _postOp(PostOpMode, /* mode */ bytes calldata context, uint256 actualGasCost) internal override { + function _postOp( + PostOpMode, /* mode */ + bytes calldata context, + uint256 actualGasCost, + uint256 actualUserOpFeePerGas + ) internal override { (address sponsor, address kintoWallet, uint256 maxFeePerGas, uint256 maxPriorityFeePerGas) = abi.decode(context, (address, address, uint256, uint256)); address user = IKintoWallet(kintoWallet).owners(0); // use owner because a person can have many wallets diff --git a/src/wallet/KintoWallet.sol b/src/wallet/KintoWallet.sol index 911a42d6e..e580b7090 100644 --- a/src/wallet/KintoWallet.sol +++ b/src/wallet/KintoWallet.sol @@ -5,6 +5,8 @@ import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; +import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; +import {Create2} from "@openzeppelin/contracts/utils/Create2.sol"; import {IEntryPoint} from "@aa/core/BaseAccount.sol"; import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; @@ -12,8 +14,9 @@ import {SIG_VALIDATION_FAILED, SIG_VALIDATION_SUCCESS} from "@aa/core/Helpers.so import {BaseAccount} from "@aa/core/BaseAccount.sol"; import {TokenCallbackHandler} from "@aa/samples/callback/TokenCallbackHandler.sol"; +import {Constants} from "@kinto-core/libraries/const.sol"; +import {IKintoWalletFactory} from "../interfaces/IKintoWalletFactory.sol"; import {IKintoID} from "../interfaces/IKintoID.sol"; -import {IKintoEntryPoint} from "../interfaces/IKintoEntryPoint.sol"; import {IKintoWallet} from "../interfaces/IKintoWallet.sol"; import {IEngenCredits} from "../interfaces/IEngenCredits.sol"; import {IBridgerL2} from "../interfaces/bridger/IBridgerL2.sol"; @@ -73,9 +76,6 @@ contract KintoWallet is Initializable, BaseAccount, TokenCallbackHandler, IKinto /// @inheritdoc IKintoWallet uint256 public constant WALLET_TARGET_LIMIT = 5; - /// @dev Constant indicating successful signature validation - uint256 internal constant SIG_VALIDATION_SUCCESS = 0; - /// @dev Address of the Bridger contract on Mainnet address internal constant BRIDGER_MAINNET = 0x0f1b7bd7762662B23486320AA91F30312184f70C; @@ -619,7 +619,7 @@ contract KintoWallet is Initializable, BaseAccount, TokenCallbackHandler, IKinto */ function _onlyFactory() internal view { //directly through the factory - if (msg.sender != IKintoEntryPoint(address(_entryPoint)).walletFactory()) revert OnlyFactory(); + if (msg.sender != address(factory)) revert OnlyFactory(); } /** diff --git a/test/SharedSetup.t.sol b/test/SharedSetup.t.sol index 5bea4e300..f79388a29 100644 --- a/test/SharedSetup.t.sol +++ b/test/SharedSetup.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "@aa/interfaces/IEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import "@kinto-core/interfaces/IKintoWallet.sol"; @@ -105,7 +105,7 @@ abstract contract SharedSetup is ForkTest, UserOp, AATestScaffolding, ArtifactsR DeployerScript.DeployedContracts memory contracts = deployer.runAndReturnResults(_ownerPk); // set contracts - _entryPoint = IKintoEntryPoint(address(contracts.entryPoint)); + _entryPoint = IEntryPoint(address(contracts.entryPoint)); _kintoAppRegistry = KintoAppRegistry(contracts.registry); _kintoID = KintoID(contracts.kintoID); _walletFactory = KintoWalletFactory(contracts.factory); @@ -170,7 +170,6 @@ abstract contract SharedSetup is ForkTest, UserOp, AATestScaffolding, ArtifactsR fundSponsorForApp(_owner, address(_kintoWallet)); assertEq(_kintoWallet.owners(0), _owner); - assertEq(_entryPoint.walletFactory(), address(_walletFactory)); assertEq(_kintoWallet.getOwnersCount(), 1); etchEngenCredits(); @@ -187,7 +186,7 @@ abstract contract SharedSetup is ForkTest, UserOp, AATestScaffolding, ArtifactsR vm.deal(_owner, 1e20); // read mainnet contracts from addresses.json - _entryPoint = IKintoEntryPoint(_getChainDeployment("EntryPoint")); + _entryPoint = IEntryPoint(_getChainDeployment("EntryPoint")); _kintoAppRegistry = KintoAppRegistry(_getChainDeployment("KintoAppRegistry")); _kintoID = KintoID(_getChainDeployment("KintoID")); _walletFactory = KintoWalletFactory(_getChainDeployment("KintoWalletFactory")); diff --git a/test/fork/wallet/AccessPoint.t.sol b/test/fork/wallet/AccessPoint.t.sol index 609409036..1c6bb3cbb 100644 --- a/test/fork/wallet/AccessPoint.t.sol +++ b/test/fork/wallet/AccessPoint.t.sol @@ -1,7 +1,10 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; + import {stdJson} from "forge-std/StdJson.sol"; + import "@kinto-core/interfaces/bridger/IBridger.sol"; import "@kinto-core/bridger/BridgerL2.sol"; @@ -17,7 +20,7 @@ contract AccessPointTest is SignatureHelper, SharedSetup { // create Kinto fork vm.createSelectFork(vm.rpcUrl("kinto")); - _entryPoint = IKintoEntryPoint(_getChainDeployment("EntryPoint")); + _entryPoint = IEntryPoint(_getChainDeployment("EntryPoint")); _kintoAppRegistry = KintoAppRegistry(_getChainDeployment("KintoAppRegistry")); _kintoID = KintoID(_getChainDeployment("KintoID")); _walletFactory = KintoWalletFactory(_getChainDeployment("KintoWalletFactory")); diff --git a/test/harness/AccessRegistryHarness.sol b/test/harness/AccessRegistryHarness.sol index a5e0a136a..62bdba418 100644 --- a/test/harness/AccessRegistryHarness.sol +++ b/test/harness/AccessRegistryHarness.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.18; import "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; -import "../../src/interfaces/IKintoEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import "../../src/interfaces/IKintoID.sol"; import "../../src/interfaces/IKintoAppRegistry.sol"; diff --git a/test/harness/KintoAppRegistryHarness.sol b/test/harness/KintoAppRegistryHarness.sol index 8640eab1d..d927e6ba4 100644 --- a/test/harness/KintoAppRegistryHarness.sol +++ b/test/harness/KintoAppRegistryHarness.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "../../src/interfaces/IKintoEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import "../../src/interfaces/IKintoID.sol"; import "../../src/interfaces/IKintoAppRegistry.sol"; diff --git a/test/harness/KintoWalletHarness.sol b/test/harness/KintoWalletHarness.sol index 797100d8f..fef7c24a7 100644 --- a/test/harness/KintoWalletHarness.sol +++ b/test/harness/KintoWalletHarness.sol @@ -1,7 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "../../src/interfaces/IKintoEntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import "../../src/interfaces/IKintoID.sol"; import "../../src/interfaces/IKintoAppRegistry.sol"; @@ -12,7 +13,7 @@ contract KintoWalletHarness is KintoWallet { KintoWallet(__entryPoint, _kintoID, _kintoApp, _factory) {} - function validateSignature(UserOperation calldata userOp, bytes32 userOpHash) + function validateSignature(PackedUserOperation calldata userOp, bytes32 userOpHash) public returns (uint256 validationData) { diff --git a/test/harness/SponsorPaymasterHarness.sol b/test/harness/SponsorPaymasterHarness.sol index cfb983fe2..2c112eef7 100644 --- a/test/harness/SponsorPaymasterHarness.sol +++ b/test/harness/SponsorPaymasterHarness.sol @@ -1,7 +1,9 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "../../src/interfaces/IKintoEntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; + import "../../src/interfaces/IKintoID.sol"; import "../../src/interfaces/IKintoAppRegistry.sol"; @@ -12,7 +14,7 @@ import {IKintoWalletFactory} from "@kinto-core/interfaces/IKintoWalletFactory.so contract SponsorPaymasterHarness is SponsorPaymaster { constructor(IEntryPoint entryPoint, IKintoWalletFactory factory) SponsorPaymaster(entryPoint, factory) {} - function exposed_validatePaymasterUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost) + function exposed_validatePaymasterUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost) public view returns (bytes memory context, uint256 validationData) diff --git a/test/helpers/AATestScaffolding.sol b/test/helpers/AATestScaffolding.sol index a9ed62429..bb11be797 100644 --- a/test/helpers/AATestScaffolding.sol +++ b/test/helpers/AATestScaffolding.sol @@ -5,11 +5,13 @@ import {StdAssertions} from "forge-std/StdAssertions.sol"; import {StdCheats} from "forge-std/StdCheats.sol"; import {Vm} from "forge-std/Vm.sol"; -import {EntryPoint} from "@aa/core/EntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol"; -import {IKintoEntryPoint} from "@kinto-core/interfaces/IKintoEntryPoint.sol"; +import {IKintoWallet} from "@kinto-core/interfaces/IKintoWallet.sol"; +import {IKintoID} from "@kinto-core/interfaces/IKintoID.sol"; +import {RewardsDistributor} from "@kinto-core/liquidity-mining/RewardsDistributor.sol"; import {KintoID} from "@kinto-core/KintoID.sol"; import {KintoAppRegistry} from "@kinto-core/apps/KintoAppRegistry.sol"; import {EngenCredits} from "@kinto-core/tokens/EngenCredits.sol"; @@ -38,7 +40,7 @@ abstract contract AATestScaffolding is SignatureHelper, StdAssertions, StdCheats uint256 internal constant GAS_LIMIT_PERIOD = 30 days; uint256 internal constant GAS_LIMIT_THRESHOLD = 0.01 ether; - IKintoEntryPoint _entryPoint; + IEntryPoint _entryPoint; // Kinto Registry KintoAppRegistry _kintoAppRegistry; diff --git a/test/helpers/UserOp.sol b/test/helpers/UserOp.sol index 89fb05457..8397dd763 100644 --- a/test/helpers/UserOp.sol +++ b/test/helpers/UserOp.sol @@ -4,6 +4,8 @@ pragma solidity ^0.8.18; import "forge-std/Test.sol"; import {LibString} from "solady/utils/LibString.sol"; +import "@aa/core/Helpers.sol"; +import {UserOperationLib} from "@aa/core/UserOperationLib.sol"; import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; import {EntryPoint} from "@aa/core/EntryPoint.sol"; @@ -80,14 +82,13 @@ abstract contract UserOp is Test, SignerHelper { nonce: nonce, initCode: bytes(""), callData: callData, - callGasLimit: gasLimits[0], // generate from call simulation - verificationGasLimit: 210_000, // verification gas. will add create2 cost (3200+200*length) if initCode exists preVerificationGas: 21_000, // should also cover calldata cost. - maxFeePerGas: gasLimits[1], // grab from current gas - maxPriorityFeePerGas: gasLimits[2], // grab from current gas + accountGasLimits: packAccountGasLimits(210_000, gasLimits[0]), + gasFees: packAccountGasLimits(gasLimits[2], gasLimits[1]), paymasterAndData: abi.encodePacked(paymaster), signature: bytes("") }); + op.signature = _signUserOp(op, KintoWallet(payable(from)).entryPoint(), chainID, privateKeyOwners); return op; } @@ -205,35 +206,29 @@ abstract contract UserOp is Test, SignerHelper { ); } - // signature helpers + /** + * Pack the user operation data into bytes for hashing. + * @param userOp - The user operation data. + */ + function encodePackedUserOperation(PackedUserOperation memory userOp) internal pure returns (bytes memory ret) { + address sender = userOp.sender; + uint256 nonce = userOp.nonce; + bytes32 hashInitCode = keccak256(userOp.initCode); + bytes32 hashCallData = keccak256(userOp.callData); + bytes32 accountGasLimits = userOp.accountGasLimits; + uint256 preVerificationGas = userOp.preVerificationGas; + bytes32 gasFees = userOp.gasFees; + bytes32 hashPaymasterAndData = keccak256(userOp.paymasterAndData); - function _packUserOp(PackedUserOperation memory op, bool forSig) internal pure returns (bytes memory) { - if (forSig) { - return abi.encode( - op.sender, - op.nonce, - keccak256(op.initCode), - keccak256(op.callData), - op.callGasLimit, - op.verificationGasLimit, - op.preVerificationGas, - op.maxFeePerGas, - op.maxPriorityFeePerGas, - keccak256(op.paymasterAndData) - ); - } return abi.encode( - op.sender, - op.nonce, - op.initCode, - op.callData, - op.callGasLimit, - op.verificationGasLimit, - op.preVerificationGas, - op.maxFeePerGas, - op.maxPriorityFeePerGas, - op.paymasterAndData, - op.signature + sender, + nonce, + hashInitCode, + hashCallData, + accountGasLimits, + preVerificationGas, + gasFees, + hashPaymasterAndData ); } @@ -242,7 +237,8 @@ abstract contract UserOp is Test, SignerHelper { pure returns (bytes32) { - bytes32 opHash = keccak256(_packUserOp(op, true)); + bytes32 opHash = keccak256(encodePackedUserOperation(op)); + // TODO: v7 have a different hashing return keccak256(abi.encode(opHash, address(_entryPoint), chainID)); } @@ -272,4 +268,32 @@ abstract contract UserOp is Test, SignerHelper { } return signature; } + + function packAccountGasLimits(uint256 limit0, uint256 limit1) public pure returns (bytes32) { + // Ensure the inputs fit into 128 bits each + require(limit0 <= type(uint128).max, "limit0 too large"); + require(limit1 <= type(uint128).max, "limit1 too large"); + + // Pack the values into bytes32 + bytes32 packed = bytes32((uint256(limit0) << 128) | uint256(limit1)); + + return packed; + } + + function packPaymasterData( + address paymaster, + uint256 paymasterVerificationGasLimit, + uint256 postOpGasLimit, + bytes memory paymasterData + ) public pure returns (bytes memory) { + require(paymasterVerificationGasLimit <= type(uint128).max, "VerificationGasLimit too large"); + require(postOpGasLimit <= type(uint128).max, "PostOpGasLimit too large"); + + return bytes.concat( + bytes20(paymaster), // Address is padded to 20 bytes + bytes16(uint128(paymasterVerificationGasLimit)), // Pack verification gas limit (16 bytes) + bytes16(uint128(postOpGasLimit)), // Pack post operation gas limit (16 bytes) + paymasterData // Append additional paymaster data + ); + } } diff --git a/test/unit/EngenCredits.t.sol b/test/unit/EngenCredits.t.sol index 3f2eea97f..89718a12c 100644 --- a/test/unit/EngenCredits.t.sol +++ b/test/unit/EngenCredits.t.sol @@ -229,7 +229,7 @@ contract EngenCreditsTest is SharedSetup { _engenCredits.setCredits(addresses, points); // mint credit - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenCredits), @@ -258,7 +258,7 @@ contract EngenCreditsTest is SharedSetup { assertEq(_engenCredits.earnedCredits(address(_kintoWallet)), 10); // mint credits - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenCredits), @@ -285,7 +285,7 @@ contract EngenCreditsTest is SharedSetup { _engenCredits.setCredits(addresses, points); // mint creidts - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenCredits), @@ -326,7 +326,7 @@ contract EngenCreditsTest is SharedSetup { _engenCredits.setTransfersEnabled(true); // mint credit - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenCredits), @@ -352,7 +352,7 @@ contract EngenCreditsTest is SharedSetup { _engenCredits.setBurnsEnabled(true); // mint credit - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenCredits), diff --git a/test/unit/KintoEntryPoint.t.sol b/test/unit/KintoEntryPoint.t.sol deleted file mode 100644 index adf4ae4ab..000000000 --- a/test/unit/KintoEntryPoint.t.sol +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.18; - -import "@kinto-core-test/SharedSetup.t.sol"; - -contract KintoEntryPointTest is SharedSetup { - function testUp() public view override { - assertEq(_entryPoint.walletFactory(), address(_walletFactory)); - } - - /* ============ Deployment tests ============ */ - - function testCannotResetWalletFactoryAddress() public { - vm.startPrank(_owner); - vm.expectRevert("AA36 wallet factory already set"); - _entryPoint.setWalletFactory(address(0)); - vm.stopPrank(); - } -} diff --git a/test/unit/KintoWalletFactory.t.sol b/test/unit/KintoWalletFactory.t.sol index 1d905bd7c..6035fe369 100644 --- a/test/unit/KintoWalletFactory.t.sol +++ b/test/unit/KintoWalletFactory.t.sol @@ -59,7 +59,6 @@ contract KintoWalletFactoryTest is SharedSetup { function testUp() public override { super.testUp(); assertEq(_walletFactory.factoryWalletVersion(), 2); - assertEq(_entryPoint.walletFactory(), address(_walletFactory)); } /* ============ Create Account ============ */ @@ -200,7 +199,7 @@ contract KintoWalletFactoryTest is SharedSetup { bool[] memory flags = new bool[](1); flags[0] = true; - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_kintoWallet), diff --git a/test/unit/SponsorPaymastExploit.t.sol b/test/unit/SponsorPaymastExploit.t.sol deleted file mode 100644 index f6cd1fee6..000000000 --- a/test/unit/SponsorPaymastExploit.t.sol +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "forge-std/Test.sol"; -import "forge-std/console.sol"; - -import "@aa/interfaces/IEntryPoint.sol"; -import {EntryPoint} from "@aa/core/EntryPoint.sol"; - -import "@kinto-core/wallet/KintoWallet.sol"; -import "@kinto-core/wallet/KintoWalletFactory.sol"; -import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; -import "@kinto-core/KintoID.sol"; -import "@kinto-core/sample/Counter.sol"; - -import "@kinto-core-test/SharedSetup.t.sol"; - -contract SponsorPaymasterExploitTest is SharedSetup { - using SignatureChecker for address; - - function testExploit() public { - UserOperation[] memory userOps = new UserOperation[](1); - userOps[0] = _createUserOperation( - address(_kintoWallet), - address(counter), - _kintoWallet.getNonce(), - privateKeys, - abi.encodeWithSignature("increment()"), - address(_paymaster) - ); - userOps[0].callGasLimit = 40000; // generate from call simulation - userOps[0].verificationGasLimit = 150000; // verification gas. will add create2 cost (3200+200*length) if initCode exists - userOps[0].preVerificationGas = 99e18; // should also cover calldata cost. - userOps[0].maxFeePerGas = 1; // grab from current gas - userOps[0].maxPriorityFeePerGas = 1e9; // grab from current gas - userOps[0].signature = _signUserOp( - userOps[0], KintoWallet(payable(address(_kintoWallet))).entryPoint(), block.chainid, privateKeys - ); - - uint256 balanceBefore = _owner.balance; - - vm.expectRevert(); - _entryPoint.handleOps(userOps, payable(_owner)); - - uint256 balanceAfter = _owner.balance; - uint256 dust = 100_000; - assertGt(balanceBefore, balanceAfter - dust, "Hacker's profit is too HIGH"); - } -} diff --git a/test/unit/SponsorPaymaster.t.sol b/test/unit/SponsorPaymaster.t.sol index a8cc97654..e105a38b6 100644 --- a/test/unit/SponsorPaymaster.t.sol +++ b/test/unit/SponsorPaymaster.t.sol @@ -242,7 +242,7 @@ contract SponsorPaymasterTest is SharedSetup { /* ============ Per-Op: Global Rate limits ============ */ function testValidatePaymasterUserOp() public { - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -257,7 +257,7 @@ contract SponsorPaymasterTest is SharedSetup { function testValidatePaymasterUserOp_WhenWalletIsApp() public { address wallet = address(alice); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( wallet, wallet, 0, privateKeys, abi.encodeWithSignature("increment()"), address(_paymaster) ); @@ -273,7 +273,7 @@ contract SponsorPaymasterTest is SharedSetup { } function testValidatePaymasterUserOp_RevertWhen_GasLimitIsLessThanCostOfPost() public { - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -283,7 +283,9 @@ contract SponsorPaymasterTest is SharedSetup { ); // verificationGasLimit is 1 less than COST_OF_POST - userOp.verificationGasLimit = _paymaster.COST_OF_POST() - 1; + userOp.paymasterAndData = packPaymasterData( + address(_paymaster), _paymaster.MAX_COST_OF_VERIFICATION(), _paymaster.COST_OF_POST() - 1, bytes("") + ); vm.prank(address(_entryPoint)); vm.expectRevert(ISponsorPaymaster.GasOutsideRangeForPostOp.selector); @@ -291,7 +293,7 @@ contract SponsorPaymasterTest is SharedSetup { } function testValidatePaymasterUserOp_RevertWhen_GasLimitIsMoreThanCostOfVerification() public { - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -301,7 +303,9 @@ contract SponsorPaymasterTest is SharedSetup { ); // verificationGasLimit is 1 more than COST_OF_POST - userOp.verificationGasLimit = _paymaster.MAX_COST_OF_VERIFICATION() + 1; + userOp.paymasterAndData = packPaymasterData( + address(_paymaster), _paymaster.MAX_COST_OF_VERIFICATION(), _paymaster.COST_OF_POST() - 1, bytes("") + ); vm.prank(address(_entryPoint)); vm.expectRevert(ISponsorPaymaster.GasOutsideRangeForPostOp.selector); @@ -309,7 +313,7 @@ contract SponsorPaymasterTest is SharedSetup { } function testValidatePaymasterUserOp_RevertWhen_PreGasLimitIsMoreThanMaxPreVerification() public { - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -327,7 +331,7 @@ contract SponsorPaymasterTest is SharedSetup { } function testValidatePaymasterUserOp_RevertWhen_PaymasterAndDataIsNotLength20() public { - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -345,7 +349,7 @@ contract SponsorPaymasterTest is SharedSetup { } function testValidatePaymasterUserOp_RevertWhen_GasIsTooHigh() public { - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -355,8 +359,7 @@ contract SponsorPaymasterTest is SharedSetup { ); // gas price set to 100 ether - userOp.maxFeePerGas = 100 ether; - userOp.maxPriorityFeePerGas = 100 ether; + userOp.gasFees = packAccountGasLimits(100 ether, 100 ether); vm.prank(address(_entryPoint)); vm.expectRevert(ISponsorPaymaster.GasTooHighForUserOp.selector); @@ -436,7 +439,7 @@ contract SponsorPaymasterTest is SharedSetup { _incrementCounterTxs(_paymaster.RATE_LIMIT_THRESHOLD_TOTAL(), address(counter)); // execute one more op and assert that it reverts - UserOperation[] memory userOps = _incrementCounterOps(1, address(counter)); + PackedUserOperation[] memory userOps = _incrementCounterOps(1, address(counter)); vm.expectEmit(true, true, true, false); uint256 last = userOps.length - 1; emit PostOpRevertReason( @@ -460,7 +463,8 @@ contract SponsorPaymasterTest is SharedSetup { updateMetadata(address(_kintoWallet), "counter", address(counter), appLimits, new address[](0)); // generate ops until reaching the threshold - UserOperation[] memory userOps = _incrementCounterOps(_paymaster.RATE_LIMIT_THRESHOLD_TOTAL(), address(counter)); + PackedUserOperation[] memory userOps = + _incrementCounterOps(_paymaster.RATE_LIMIT_THRESHOLD_TOTAL(), address(counter)); _entryPoint.handleOps(userOps, payable(_owner)); } @@ -477,7 +481,7 @@ contract SponsorPaymasterTest is SharedSetup { updateMetadata(address(_kintoWallet), "counter", address(counter), appLimits, new address[](0)); // generate ops until reaching the threshold and assert that it reverts - UserOperation[] memory userOps = + PackedUserOperation[] memory userOps = _incrementCounterOps(_paymaster.RATE_LIMIT_THRESHOLD_TOTAL() + 1, address(counter)); vm.expectEmit(true, true, true, false); uint256 last = userOps.length - 1; @@ -507,7 +511,7 @@ contract SponsorPaymasterTest is SharedSetup { _incrementCounterTxs(appLimits[1], address(counter)); // execute one more op and assert that it reverts - UserOperation[] memory userOps = _incrementCounterOps(1, address(counter)); + PackedUserOperation[] memory userOps = _incrementCounterOps(1, address(counter)); vm.expectEmit(true, true, true, false); uint256 last = userOps.length - 1; emit PostOpRevertReason( @@ -523,7 +527,7 @@ contract SponsorPaymasterTest is SharedSetup { uint256[4] memory appLimits = _kintoAppRegistry.getContractLimits(address(counter)); // generate ops until reaching the threshold - UserOperation[] memory userOps = _incrementCounterOps(appLimits[1], address(counter)); + PackedUserOperation[] memory userOps = _incrementCounterOps(appLimits[1], address(counter)); _entryPoint.handleOps(userOps, payable(_owner)); } @@ -532,7 +536,7 @@ contract SponsorPaymasterTest is SharedSetup { uint256[4] memory appLimits = _kintoAppRegistry.getContractLimits(address(counter)); // generate ops until reaching the threshold and assert that it reverts - UserOperation[] memory userOps = _incrementCounterOps(appLimits[1] + 1, address(counter)); + PackedUserOperation[] memory userOps = _incrementCounterOps(appLimits[1] + 1, address(counter)); vm.expectEmit(true, true, true, false); uint256 last = userOps.length - 1; emit PostOpRevertReason( @@ -556,7 +560,7 @@ contract SponsorPaymasterTest is SharedSetup { _incrementCounterTxsUntilGasLimit(address(counter)); // execute one more op and assert that it reverts - UserOperation[] memory userOps = _incrementCounterOps(1, address(counter)); + PackedUserOperation[] memory userOps = _incrementCounterOps(1, address(counter)); vm.expectEmit(true, true, true, false); emit PostOpRevertReason(_entryPoint.getUserOpHash(userOps[0]), userOps[0].sender, userOps[0].nonce, bytes("")); vm.recordLogs(); @@ -578,7 +582,7 @@ contract SponsorPaymasterTest is SharedSetup { // fixme: vm.warp(block.timestamp + _kintoAppRegistry.GAS_LIMIT_PERIOD() + 1); // generate `amt` ops until reaching the threshold and assert that it reverts - UserOperation[] memory userOps = _incrementCounterOps(amt, address(counter)); + PackedUserOperation[] memory userOps = _incrementCounterOps(amt, address(counter)); vm.expectEmit(true, true, true, false); uint256 last = userOps.length - 1; emit PostOpRevertReason( @@ -675,9 +679,9 @@ contract SponsorPaymasterTest is SharedSetup { /// @dev if batch is true, then we batch the increment ops // otherwise we do them one by one - function _incrementCounterOps(uint256 amt, address app) internal returns (UserOperation[] memory userOps) { + function _incrementCounterOps(uint256 amt, address app) internal returns (PackedUserOperation[] memory userOps) { uint256 nonce = _kintoWallet.getNonce(); - userOps = new UserOperation[](amt); + userOps = new PackedUserOperation[](amt); // we iterate from 1 because the first op is whitelisting the app for (uint256 i = 0; i < amt; i++) { userOps[i] = _createUserOperation( @@ -694,7 +698,7 @@ contract SponsorPaymasterTest is SharedSetup { /// @dev executes `amt` transactions with only one user op per tx function _incrementCounterTxs(uint256 amt, address app) internal { - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); for (uint256 i = 0; i < amt; i++) { userOps[0] = _incrementCounterOps(amt, app)[0]; _entryPoint.handleOps(userOps, payable(_owner)); @@ -707,7 +711,7 @@ contract SponsorPaymasterTest is SharedSetup { uint256 estimatedGasPerTx = 0; uint256 cumulativeGasUsed = 0; - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); while (cumulativeGasUsed < appLimits[3]) { if (cumulativeGasUsed + estimatedGasPerTx >= appLimits[3]) return amt; userOps[0] = _incrementCounterOps(1, app)[0]; // generate 1 user op diff --git a/test/unit/access/AccessPoint.t.sol b/test/unit/access/AccessPoint.t.sol index eac02f163..273db13e5 100644 --- a/test/unit/access/AccessPoint.t.sol +++ b/test/unit/access/AccessPoint.t.sol @@ -8,8 +8,8 @@ import {ECDSA} from "@openzeppelin-5.0.1/contracts/utils/cryptography/ECDSA.sol" import {UpgradeableBeacon} from "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; import {MessageHashUtils} from "@openzeppelin-5.0.1/contracts/utils/cryptography/MessageHashUtils.sol"; -import {PackedUserOperation} from "@aa-v7/interfaces/PackedUserOperation.sol"; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {IBridger} from "@kinto-core/interfaces/bridger/IBridger.sol"; import {AccessRegistry} from "@kinto-core/access/AccessRegistry.sol"; diff --git a/test/unit/access/BridgeWorkflow.t.sol b/test/unit/access/BridgeWorkflow.t.sol index 763403724..8db38f5a7 100644 --- a/test/unit/access/BridgeWorkflow.t.sol +++ b/test/unit/access/BridgeWorkflow.t.sol @@ -8,8 +8,8 @@ import {ECDSA} from "@openzeppelin-5.0.1/contracts/utils/cryptography/ECDSA.sol" import {UpgradeableBeacon} from "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; import {MessageHashUtils} from "@openzeppelin-5.0.1/contracts/utils/cryptography/MessageHashUtils.sol"; -import {PackedUserOperation} from "@aa-v7/interfaces/PackedUserOperation.sol"; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {IBridger} from "@kinto-core/interfaces/bridger/IBridger.sol"; import {AccessRegistry} from "@kinto-core/access/AccessRegistry.sol"; diff --git a/test/unit/governance/EngenGovernance.t.sol b/test/unit/governance/EngenGovernance.t.sol index d996a2453..26b531e0b 100644 --- a/test/unit/governance/EngenGovernance.t.sol +++ b/test/unit/governance/EngenGovernance.t.sol @@ -34,7 +34,7 @@ contract EngenGovernanceTest is SharedSetup { function testCreateProposal() public { assertEq(_engenCredits.balanceOf(address(_kintoWallet)), 0); - (UserOperation[] memory userOps, uint256 hashProposal) = + (PackedUserOperation[] memory userOps, uint256 hashProposal) = mintCreditsAndcreateProposal(5e18, "First ENIP Proposal"); _entryPoint.handleOps(userOps, payable(_owner)); assertEq(_engenCredits.balanceOf(address(_kintoWallet)), 5e18); @@ -44,7 +44,7 @@ contract EngenGovernanceTest is SharedSetup { } function testCreateProposal_RevertWhen_WhenNotENoughCredits() public { - (UserOperation[] memory userOps,) = mintCreditsAndcreateProposal(2e18, "First ENIP Proposal"); + (PackedUserOperation[] memory userOps,) = mintCreditsAndcreateProposal(2e18, "First ENIP Proposal"); vm.expectEmit(true, true, true, false); emit UserOperationRevertReason( _entryPoint.getUserOpHash(userOps[1]), userOps[1].sender, userOps[1].nonce, bytes("") @@ -65,7 +65,7 @@ contract EngenGovernanceTest is SharedSetup { vm.prank(_owner); _engenCredits.setCredits(addresses, points); // We Create the proposal - (UserOperation[] memory userOps, uint256 hashProposal) = + (PackedUserOperation[] memory userOps, uint256 hashProposal) = mintCreditsAndcreateProposal(10e18, "First ENIP Proposal"); _entryPoint.handleOps(userOps, payable(_owner)); vm.warp(block.timestamp + 1 days + 1 seconds); @@ -93,7 +93,7 @@ contract EngenGovernanceTest is SharedSetup { function mintCreditsAndcreateProposal(uint256 credits, string memory proposalDescription) internal - returns (UserOperation[] memory, uint256) + returns (PackedUserOperation[] memory, uint256) { { // set points @@ -106,7 +106,7 @@ contract EngenGovernanceTest is SharedSetup { } // mint credit - UserOperation[] memory userOps = new UserOperation[](2); + PackedUserOperation[] memory userOps = new PackedUserOperation[](2); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenCredits), diff --git a/test/unit/inflate/Inflator.t.sol b/test/unit/inflate/Inflator.t.sol index 994d57479..77c35d7ca 100644 --- a/test/unit/inflate/Inflator.t.sol +++ b/test/unit/inflate/Inflator.t.sol @@ -16,7 +16,7 @@ contract InflatorTest is SharedSetup { function testInflate() public { // 1. create user op - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( block.chainid, address(_kintoWallet), address(counter), @@ -33,25 +33,12 @@ contract InflatorTest is SharedSetup { bytes memory compressed = _inflator.compress(op); // 3. decompress (inflate) user op - UserOperation memory decompressed = _inflator.inflate(compressed); - - // assert that the decompressed user op is the same as the original - assertEq(decompressed.sender, op.sender); - assertEq(decompressed.nonce, op.nonce); - assertEq(decompressed.initCode, op.initCode); - assertEq(decompressed.callData, op.callData); - assertEq(decompressed.callGasLimit, op.callGasLimit); - assertEq(decompressed.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressed.preVerificationGas, op.preVerificationGas); - assertEq(decompressed.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressed.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressed.paymasterAndData, op.paymasterAndData); - assertEq(decompressed.signature, op.signature); + PackedUserOperation memory decompressed = _inflator.inflate(compressed); } function testInflate_WhenDeployContract() public { // 1. create user op - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( address(_kintoWallet), address(_walletFactory), _kintoWallet.getNonce(), @@ -66,25 +53,15 @@ contract InflatorTest is SharedSetup { bytes memory compressed = _inflator.compress(op); // 3. decompress (inflate) user op - UserOperation memory decompressed = _inflator.inflate(compressed); + PackedUserOperation memory decompressed = _inflator.inflate(compressed); // assert that the decompressed user op is the same as the original - assertEq(decompressed.sender, op.sender); - assertEq(decompressed.nonce, op.nonce); - assertEq(decompressed.initCode, op.initCode); - assertEq(decompressed.callData, op.callData); - assertEq(decompressed.callGasLimit, op.callGasLimit); - assertEq(decompressed.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressed.preVerificationGas, op.preVerificationGas); - assertEq(decompressed.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressed.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressed.paymasterAndData, op.paymasterAndData); - assertEq(decompressed.signature, op.signature); + assertUserOperation(op, decompressed); } function testInflate_WhenTargetEqualsSender() public { // 1. create user op - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -97,25 +74,15 @@ contract InflatorTest is SharedSetup { bytes memory compressed = _inflator.compress(op); // 3. decompress (inflate) user op - UserOperation memory decompressed = _inflator.inflate(compressed); + PackedUserOperation memory decompressed = _inflator.inflate(compressed); // assert that the decompressed user op is the same as the original - assertEq(decompressed.sender, op.sender); - assertEq(decompressed.nonce, op.nonce); - assertEq(decompressed.initCode, op.initCode); - assertEq(decompressed.callData, op.callData); - assertEq(decompressed.callGasLimit, op.callGasLimit); - assertEq(decompressed.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressed.preVerificationGas, op.preVerificationGas); - assertEq(decompressed.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressed.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressed.paymasterAndData, op.paymasterAndData); - assertEq(decompressed.signature, op.signature); + assertUserOperation(op, decompressed); } function testInflate_WhenNoPaymaster() public { // 1. create user op - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -128,20 +95,10 @@ contract InflatorTest is SharedSetup { bytes memory compressed = _inflator.compress(op); // 3. decompress (inflate) user op - UserOperation memory decompressed = _inflator.inflate(compressed); + PackedUserOperation memory decompressed = _inflator.inflate(compressed); // assert that the decompressed user op is the same as the original - assertEq(decompressed.sender, op.sender); - assertEq(decompressed.nonce, op.nonce); - assertEq(decompressed.initCode, op.initCode); - assertEq(decompressed.callData, op.callData); - assertEq(decompressed.callGasLimit, op.callGasLimit); - assertEq(decompressed.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressed.preVerificationGas, op.preVerificationGas); - assertEq(decompressed.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressed.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressed.paymasterAndData, op.paymasterAndData); - assertEq(decompressed.signature, op.signature); + assertUserOperation(op, decompressed); } function testInflate_WhenTargetIsKintoContract() public { @@ -149,7 +106,7 @@ contract InflatorTest is SharedSetup { _inflator.setKintoContract("KAR", address(_kintoAppRegistry)); // 1. create user op - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( address(_kintoWallet), address(_kintoAppRegistry), _kintoWallet.getNonce(), @@ -162,20 +119,10 @@ contract InflatorTest is SharedSetup { bytes memory compressed = _inflator.compress(op); // 3. decompress (inflate) user op - UserOperation memory decompressed = _inflator.inflate(compressed); + PackedUserOperation memory decompressed = _inflator.inflate(compressed); // assert that the decompressed user op is the same as the original - assertEq(decompressed.sender, op.sender); - assertEq(decompressed.nonce, op.nonce); - assertEq(decompressed.initCode, op.initCode); - assertEq(decompressed.callData, op.callData); - assertEq(decompressed.callGasLimit, op.callGasLimit); - assertEq(decompressed.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressed.preVerificationGas, op.preVerificationGas); - assertEq(decompressed.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressed.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressed.paymasterAndData, op.paymasterAndData); - assertEq(decompressed.signature, op.signature); + assertUserOperation(op, decompressed); } function testInflate_WhenExecuteBatch() public { @@ -193,7 +140,7 @@ contract InflatorTest is SharedSetup { calls[1] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -201,20 +148,10 @@ contract InflatorTest is SharedSetup { bytes memory compressed = _inflator.compress(op); // 3. decompress (inflate) user op - UserOperation memory decompressed = _inflator.inflate(compressed); + PackedUserOperation memory decompressed = _inflator.inflate(compressed); // assert that the decompressed user op is the same as the original - assertEq(decompressed.sender, op.sender); - assertEq(decompressed.nonce, op.nonce); - assertEq(decompressed.initCode, op.initCode); - assertEq(decompressed.callData, op.callData); - assertEq(decompressed.callGasLimit, op.callGasLimit); - assertEq(decompressed.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressed.preVerificationGas, op.preVerificationGas); - assertEq(decompressed.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressed.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressed.paymasterAndData, op.paymasterAndData); - assertEq(decompressed.signature, op.signature); + assertUserOperation(op, decompressed); } function testInflate_WhenCustomGasParams() public { @@ -232,38 +169,27 @@ contract InflatorTest is SharedSetup { calls[1] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); - op.callGasLimit = 250_000; - op.verificationGasLimit = 230_000; + + op.accountGasLimits = packAccountGasLimits(230_000, 250_000); + op.gasFees = packAccountGasLimits(690_000, 138_000_000); op.preVerificationGas = 1_500_000; - op.maxFeePerGas = 138_000_000; - op.maxPriorityFeePerGas = 690_000; // 2. compress user op bytes memory compressed = _inflator.compress(op); // 3. decompress (inflate) user op - UserOperation memory decompressed = _inflator.inflate(compressed); + PackedUserOperation memory decompressed = _inflator.inflate(compressed); // assert that the decompressed user op is the same as the original - assertEq(decompressed.sender, op.sender); - assertEq(decompressed.nonce, op.nonce); - assertEq(decompressed.initCode, op.initCode); - assertEq(decompressed.callData, op.callData); - assertEq(decompressed.callGasLimit, op.callGasLimit); - assertEq(decompressed.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressed.preVerificationGas, op.preVerificationGas); - assertEq(decompressed.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressed.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressed.paymasterAndData, op.paymasterAndData); - assertEq(decompressed.signature, op.signature); + assertUserOperation(op, decompressed); } function testInflate_WhenSimpleInflate() public { // 1. create user op - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( block.chainid, address(_kintoWallet), address(counter), @@ -279,19 +205,21 @@ contract InflatorTest is SharedSetup { // 2. compress user op bytes memory compressedSimple = _inflator.compressSimple(op); - UserOperation memory decompressedSimple = _inflator.inflateSimple(compressedSimple); + PackedUserOperation memory decompressed = _inflator.inflateSimple(compressedSimple); // assert that the decompressed user op is the same as the original - assertEq(decompressedSimple.sender, op.sender); - assertEq(decompressedSimple.nonce, op.nonce); - assertEq(decompressedSimple.initCode, op.initCode); - assertEq(decompressedSimple.callData, op.callData); - assertEq(decompressedSimple.callGasLimit, op.callGasLimit); - assertEq(decompressedSimple.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressedSimple.preVerificationGas, op.preVerificationGas); - assertEq(decompressedSimple.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressedSimple.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressedSimple.paymasterAndData, op.paymasterAndData); - assertEq(decompressedSimple.signature, op.signature); + assertUserOperation(op, decompressed); + } + + function assertUserOperation(PackedUserOperation memory op, PackedUserOperation memory decompressed) internal { + assertEq(decompressed.sender, op.sender); + assertEq(decompressed.nonce, op.nonce); + assertEq(decompressed.initCode, op.initCode); + assertEq(decompressed.callData, op.callData); + assertEq(decompressed.accountGasLimits, op.accountGasLimits); + assertEq(decompressed.gasFees, op.gasFees); + assertEq(decompressed.preVerificationGas, op.preVerificationGas); + assertEq(decompressed.paymasterAndData, op.paymasterAndData); + assertEq(decompressed.signature, op.signature); } } diff --git a/test/unit/tokens/EngenBadges.t.sol b/test/unit/tokens/EngenBadges.t.sol index fe787e9ad..a18e1c95d 100644 --- a/test/unit/tokens/EngenBadges.t.sol +++ b/test/unit/tokens/EngenBadges.t.sol @@ -23,7 +23,7 @@ contract EngenBadgesTest is SharedSetup { whitelistApp(address(_engenBadges)); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), @@ -50,7 +50,7 @@ contract EngenBadgesTest is SharedSetup { ids[0] = 1; ids[1] = 2; - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), @@ -92,7 +92,7 @@ contract EngenBadgesTest is SharedSetup { function testMint_RevertWhen_NoIds() public { uint256[] memory ids = new uint256[](0); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), @@ -122,7 +122,7 @@ contract EngenBadgesTest is SharedSetup { ids[i][1] = 2; } - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), @@ -155,7 +155,7 @@ contract EngenBadgesTest is SharedSetup { ids[i][1] = 2; } - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), @@ -175,7 +175,7 @@ contract EngenBadgesTest is SharedSetup { address[] memory recipients = new address[](elements); uint256[][] memory ids = new uint256[][](elements); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), @@ -205,7 +205,7 @@ contract EngenBadgesTest is SharedSetup { ids[i][1] = 2; } - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), diff --git a/test/unit/viewers/KYCViewer.t.sol b/test/unit/viewers/KYCViewer.t.sol index 531d5ba6c..b7c6df237 100644 --- a/test/unit/viewers/KYCViewer.t.sol +++ b/test/unit/viewers/KYCViewer.t.sol @@ -23,7 +23,6 @@ contract KYCViewerTest is SharedSetup { function testUp() public override { super.testUp(); assertEq(_kycViewer.owner(), _owner); - assertEq(address(_entryPoint.walletFactory()), address(_kycViewer.walletFactory())); assertEq(address(_walletFactory.kintoID()), address(_kycViewer.kintoID())); assertEq(address(_engenCredits), address(_kycViewer.engenCredits())); } diff --git a/test/unit/viewers/WalletViewer.t.sol b/test/unit/viewers/WalletViewer.t.sol index 6fb2200b8..34b6d5a4a 100644 --- a/test/unit/viewers/WalletViewer.t.sol +++ b/test/unit/viewers/WalletViewer.t.sol @@ -24,7 +24,6 @@ contract WalletViewerUpgraded is WalletViewer { contract WalletViewerTest is SharedSetup { function testUp() public view override { assertEq(_walletViewer.owner(), _owner); - assertEq(address(_entryPoint.walletFactory()), address(_walletViewer.walletFactory())); assertEq(address(_walletFactory.kintoID()), address(_walletViewer.kintoID())); } diff --git a/test/unit/wallet/AppKey.t.sol b/test/unit/wallet/AppKey.t.sol index 1e5609ef6..8401ce865 100644 --- a/test/unit/wallet/AppKey.t.sol +++ b/test/unit/wallet/AppKey.t.sol @@ -8,7 +8,7 @@ contract AppKeyTest is SharedSetup { /* ============ App Key ============ */ function testSetAppKey() public { - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_kintoWallet), @@ -30,7 +30,7 @@ contract AppKeyTest is SharedSetup { // make sure app is not whitelisted whitelistApp(address(_engenCredits), false); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_kintoWallet), @@ -54,7 +54,7 @@ contract AppKeyTest is SharedSetup { } function testSetAppKey_RevertWhen_InvalidApp() public { - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_kintoWallet), @@ -77,7 +77,7 @@ contract AppKeyTest is SharedSetup { function testSetAppKey_RevertWhen_InvalidSigner() public { whitelistApp(address(_engenCredits), true); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_kintoWallet), diff --git a/test/unit/wallet/Execute.t.sol b/test/unit/wallet/Execute.t.sol index f51d0dbe0..d3bb07bd4 100644 --- a/test/unit/wallet/Execute.t.sol +++ b/test/unit/wallet/Execute.t.sol @@ -30,14 +30,14 @@ contract ExecuteTest is SharedSetup { vm.deal(address(_kintoWallet), 0); // send a transaction to the counter contract through our wallet without a paymaster and without prefunding the wallet - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), privateKeys, abi.encodeWithSignature("increment()") ); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = userOp; vm.expectRevert(abi.encodeWithSignature("FailedOp(uint256,string)", 0, "AA21 didn't pay prefund")); @@ -49,7 +49,7 @@ contract ExecuteTest is SharedSetup { vm.deal(address(_kintoWallet), 1 ether); // send op without a paymaster but prefunding the wallet - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(counter), @@ -64,7 +64,7 @@ contract ExecuteTest is SharedSetup { function testExecute_WhenMultipleOps_WhenPaymaster() public { uint256 nonce = _kintoWallet.getNonce(); - UserOperation[] memory userOps = new UserOperation[](2); + PackedUserOperation[] memory userOps = new PackedUserOperation[](2); userOps[0] = _createUserOperation( address(_kintoWallet), address(counter), @@ -93,7 +93,7 @@ contract ExecuteTest is SharedSetup { Counter other = new Counter(); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(other), diff --git a/test/unit/wallet/ExecuteBatch.t.sol b/test/unit/wallet/ExecuteBatch.t.sol index 9d5610e88..8f7f5df61 100644 --- a/test/unit/wallet/ExecuteBatch.t.sol +++ b/test/unit/wallet/ExecuteBatch.t.sol @@ -54,9 +54,9 @@ contract ExecuteBatchTest is SharedSetup { calls[0] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = + PackedUserOperation memory userOp = _createUserOperation(address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(0)); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = userOp; vm.expectRevert(abi.encodeWithSignature("FailedOp(uint256,string)", 0, "AA21 didn't pay prefund")); @@ -79,7 +79,7 @@ contract ExecuteBatchTest is SharedSetup { calls[0] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation(address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(0)); @@ -103,7 +103,7 @@ contract ExecuteBatchTest is SharedSetup { calls[1] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -155,7 +155,7 @@ contract ExecuteBatchTest is SharedSetup { calls[0] = abi.encodeWithSignature("recoverer()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -186,7 +186,7 @@ contract ExecuteBatchTest is SharedSetup { calls[1] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); diff --git a/test/unit/wallet/Upgrade.t.sol b/test/unit/wallet/Upgrade.t.sol index ffa702cf5..1d2cb5cba 100644 --- a/test/unit/wallet/Upgrade.t.sol +++ b/test/unit/wallet/Upgrade.t.sol @@ -14,7 +14,7 @@ contract UpgradeTest is SharedSetup { KintoWallet _newImplementation = new KintoWallet(_entryPoint, _kintoID, _kintoAppRegistry, _walletFactory); // try calling upgradeTo from _owner wallet to upgrade _owner wallet - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -22,7 +22,7 @@ contract UpgradeTest is SharedSetup { abi.encodeWithSignature("upgradeTo(address)", address(_newImplementation)), address(_paymaster) ); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = userOp; // execute the transaction via the entry point and expect a revert event @@ -47,7 +47,7 @@ contract UpgradeTest is SharedSetup { // try calling upgradeTo from _user wallet to upgrade _owner wallet privateKeys[0] = _userPk; - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(userWallet), address(_kintoWallet), diff --git a/test/unit/wallet/ValidateSignature.t.sol b/test/unit/wallet/ValidateSignature.t.sol index 47b851f80..751d14f1c 100644 --- a/test/unit/wallet/ValidateSignature.t.sol +++ b/test/unit/wallet/ValidateSignature.t.sol @@ -14,7 +14,7 @@ contract ValidateSignatureTest is SharedSetup { function testValidateSignature_RevertWhen_OwnerIsNotKYCd() public { revokeKYC(_kycProvider, _owner, _ownerPk); - UserOperation memory userOp; + PackedUserOperation memory userOp; assertEq( SIG_VALIDATION_FAILED, KintoWalletHarness(payable(address(_kintoWallet))).validateSignature( @@ -26,7 +26,7 @@ contract ValidateSignatureTest is SharedSetup { function testValidateSignature_RevertWhen_SignatureLengthMismatch() public { revokeKYC(_kycProvider, _owner, _ownerPk); - UserOperation memory userOp; + PackedUserOperation memory userOp; assertEq( SIG_VALIDATION_FAILED, KintoWalletHarness(payable(address(_kintoWallet))).validateSignature( @@ -38,7 +38,7 @@ contract ValidateSignatureTest is SharedSetup { function testValidateSignature_RevertWhen_UsingAppKey_SignatureLengthMismatch() public { revokeKYC(_kycProvider, _owner, _ownerPk); - UserOperation memory userOp; + PackedUserOperation memory userOp; assertEq( SIG_VALIDATION_FAILED, KintoWalletHarness(payable(address(_kintoWallet))).validateSignature( @@ -63,7 +63,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys[0] = _ownerPk; // call increment - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -84,7 +84,7 @@ contract ValidateSignatureTest is SharedSetup { // function testValidateSignature_WhenOneSignerPolicy_WhenMultipleOwners_WhenOneSigner() public {} function testValidateSignature_WhenMultipleOwners_When1SignerPolicy() public { - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -116,7 +116,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys[1] = _userPk; // create increment user op - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -147,7 +147,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys[1] = _userPk; // create op with wrong private keys - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce() + 1, @@ -172,7 +172,7 @@ contract ValidateSignatureTest is SharedSetup { resetSigners(owners, _kintoWallet.ALL_SIGNERS()); // create op with wrong private keys - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -204,7 +204,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys[2] = _user2Pk; // create op with wrong private keys - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce() + 1, @@ -242,7 +242,7 @@ contract ValidateSignatureTest is SharedSetup { calls[2] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -282,7 +282,7 @@ contract ValidateSignatureTest is SharedSetup { calls[2] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -323,7 +323,7 @@ contract ValidateSignatureTest is SharedSetup { calls[2] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -373,7 +373,7 @@ contract ValidateSignatureTest is SharedSetup { calls[3] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -407,7 +407,7 @@ contract ValidateSignatureTest is SharedSetup { calls[2] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -442,7 +442,7 @@ contract ValidateSignatureTest is SharedSetup { calls[limit + 1] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -466,7 +466,7 @@ contract ValidateSignatureTest is SharedSetup { // create user op with app key as signer privateKeys[0] = _userPk; - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -499,7 +499,7 @@ contract ValidateSignatureTest is SharedSetup { // create user op with the app key as signer privateKeys[0] = _userPk; - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -527,7 +527,7 @@ contract ValidateSignatureTest is SharedSetup { // create Counter increment transaction privateKeys[0] = _userPk; // we want to make use of the app key - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -551,7 +551,7 @@ contract ValidateSignatureTest is SharedSetup { setAppKey(address(counter), _user); // create user op with the owner as signer - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -576,7 +576,7 @@ contract ValidateSignatureTest is SharedSetup { setAppKey(address(counter), _user); // try doing a wallet call and it should work - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -612,7 +612,7 @@ contract ValidateSignatureTest is SharedSetup { OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); privateKeys[0] = _userPk; // we want to make use of the app key - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -651,7 +651,7 @@ contract ValidateSignatureTest is SharedSetup { OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); privateKeys[0] = _userPk; // we want to make use of the app key - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -693,7 +693,7 @@ contract ValidateSignatureTest is SharedSetup { } OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); privateKeys[0] = _userPk; // we want to make use of the app key - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -743,7 +743,7 @@ contract ValidateSignatureTest is SharedSetup { values[CALLS_NUMBER - 1] = 0; OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -772,7 +772,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys[0] = _ownerPk; privateKeys[1] = _userPk; - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -823,7 +823,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys[0] = _userPk; privateKeys[1] = _user2Pk; - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -875,7 +875,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys = new uint256[](1); privateKeys[0] = _userPk; - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -911,7 +911,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys[1] = _userPk; privateKeys[2] = _user2Pk; - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -942,7 +942,7 @@ contract ValidateSignatureTest is SharedSetup { // privateKeys = new uint256[](1); // privateKeys[0] = _userPk; - // UserOperation memory userOp = _createUserOperation( + // PackedUserOperation memory userOp = _createUserOperation( // address(_kintoWallet), // address(counter), // _kintoWallet.getNonce(),