-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
factory should return the wallet account address even if it has alrea…
…dy been created
- Loading branch information
1 parent
48ebff2
commit ac50018
Showing
8 changed files
with
121 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule account-abstraction
updated
16 files
+78 −44 | contracts/core/EntryPoint.sol | |
+1 −1 | contracts/core/EntryPointSimulations.sol | |
+12 −0 | contracts/interfaces/IEntryPoint.sol | |
+0 −2 | contracts/interfaces/IEntryPointSimulations.sol | |
+2 −2 | contracts/interfaces/PackedUserOperation.sol | |
+1 −0 | contracts/package.json | |
+1 −1 | contracts/samples/TokenPaymaster.sol | |
+15 −8 | erc/ERCS/erc-4337.md | |
+2 −0 | package.json | |
+20 −20 | reports/gas-checker.txt | |
+1 −1 | test/UserOp.ts | |
+105 −16 | test/entrypoint.test.ts | |
+73 −4 | test/entrypointsimulations.test.ts | |
+2 −1 | test/samples/TokenPaymaster.test.ts | |
+87 −1 | test/testutils.ts | |
+12 −0 | yarn.lock |
Submodule forge-std
updated
27 files
+1 −0 | .gitattributes | |
+48 −6 | .github/workflows/ci.yml | |
+1 −1 | package.json | |
+635 −0 | scripts/vm.py | |
+4 −3 | src/Script.sol | |
+23 −6 | src/StdChains.sol | |
+174 −11 | src/StdCheats.sol | |
+16 −1 | src/StdInvariant.sol | |
+19 −15 | src/StdJson.sol | |
+54 −3 | src/StdStorage.sol | |
+2 −2 | src/StdStyle.sol | |
+62 −34 | src/StdUtils.sol | |
+4 −3 | src/Test.sol | |
+989 −374 | src/Vm.sol | |
+234 −0 | src/mocks/MockERC20.sol | |
+235 −0 | src/mocks/MockERC721.sol | |
+93 −77 | test/StdAssertions.t.sol | |
+93 −37 | test/StdChains.t.sol | |
+210 −45 | test/StdCheats.t.sol | |
+13 −11 | test/StdError.t.sol | |
+27 −12 | test/StdMath.t.sol | |
+66 −34 | test/StdStorage.t.sol | |
+4 −4 | test/StdStyle.t.sol | |
+66 −36 | test/StdUtils.t.sol | |
+15 −0 | test/Vm.t.sol | |
+441 −0 | test/mocks/MockERC20.t.sol | |
+721 −0 | test/mocks/MockERC721.t.sol |
Submodule nitro-contracts
updated
66 files
Submodule openzeppelin-contracts
updated
337 files
Submodule openzeppelin-contracts-upgradeable
updated
265 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.20; | ||
|
||
import "forge-std/Test.sol"; | ||
import {EntryPoint} from "@account-abstraction/contracts/core/EntryPoint.sol"; | ||
import "@source/validator/SoulWalletDefaultValidator.sol"; | ||
import {SoulWalletFactory} from "@source/factory/SoulWalletFactory.sol"; | ||
import "@source/modules/securityControlModule/SecurityControlModule.sol"; | ||
import "@source/modules/securityControlModule/trustedContractManager/trustedModuleManager/TrustedModuleManager.sol"; | ||
import "@source/modules/securityControlModule/trustedContractManager/trustedHookManager/TrustedHookManager.sol"; | ||
import | ||
"@source/modules/securityControlModule/trustedContractManager/trustedValidatorManager/TrustedValidatorManager.sol"; | ||
import "@source/libraries/TypeConversion.sol"; | ||
import {SoulWalletLogicInstence} from "../base/SoulWalletLogicInstence.sol"; | ||
import {UserOpHelper} from "../../helper/UserOpHelper.t.sol"; | ||
import {UserOperationHelper} from "@soulwallet-core/test/dev/userOperationHelper.sol"; | ||
import "@source/abstract/DefaultCallbackHandler.sol"; | ||
|
||
contract SoulWalletFactoryTest is Test, UserOpHelper { | ||
using TypeConversion for address; | ||
|
||
SoulWalletDefaultValidator public soulWalletDefaultValidator; | ||
SoulWalletLogicInstence public soulWalletLogicInstence; | ||
SoulWalletFactory public soulWalletFactory; | ||
DefaultCallbackHandler public defaultCallbackHandler; | ||
|
||
function setUp() public { | ||
defaultCallbackHandler = new DefaultCallbackHandler(); | ||
entryPoint = new EntryPoint(); | ||
soulWalletDefaultValidator = new SoulWalletDefaultValidator(); | ||
soulWalletLogicInstence = new SoulWalletLogicInstence( | ||
address(entryPoint), | ||
address(soulWalletDefaultValidator) | ||
); | ||
address logic = address(soulWalletLogicInstence.soulWalletLogic()); | ||
|
||
soulWalletFactory = new SoulWalletFactory( | ||
logic, | ||
address(entryPoint), | ||
address(this) | ||
); | ||
require(soulWalletFactory._WALLETIMPL() == logic, "logic address not match"); | ||
|
||
} | ||
|
||
function test_deployWallet() public { | ||
bytes[] memory modules; | ||
bytes[] memory hooks; | ||
bytes32[] memory owners = new bytes32[](1); | ||
owners[0] = address(this).toBytes32(); | ||
bytes32 salt = bytes32(0); | ||
bytes memory initializer = abi.encodeWithSignature( | ||
"initialize(bytes32[],address,bytes[],bytes[])", | ||
owners, | ||
defaultCallbackHandler, | ||
modules, | ||
hooks | ||
); | ||
address walletAddress1 = soulWalletFactory.getWalletAddress( | ||
initializer, | ||
salt | ||
); | ||
address walletAddress2 = soulWalletFactory.createWallet( | ||
initializer, | ||
salt | ||
); | ||
require( | ||
walletAddress1 == walletAddress2, | ||
"walletAddress1 != walletAddress2" | ||
); | ||
} | ||
// test return the wallet account address even if it has already been created | ||
function test_alreadyDeployedWallet() public { | ||
bytes[] memory modules; | ||
bytes[] memory hooks; | ||
bytes32[] memory owners = new bytes32[](1); | ||
owners[0] = address(this).toBytes32(); | ||
bytes32 salt = bytes32(0); | ||
bytes memory initializer = abi.encodeWithSignature( | ||
"initialize(bytes32[],address,bytes[],bytes[])", | ||
owners, | ||
defaultCallbackHandler, | ||
modules, | ||
hooks | ||
); | ||
address walletAddress1 = soulWalletFactory.getWalletAddress( | ||
initializer, | ||
salt | ||
); | ||
address walletAddress2 = soulWalletFactory.createWallet( | ||
initializer, | ||
salt | ||
); | ||
require( | ||
walletAddress1 == walletAddress2, | ||
"walletAddress1 != walletAddress2" | ||
); | ||
address walletAddress3 = soulWalletFactory.createWallet( | ||
initializer, | ||
salt | ||
); | ||
require( | ||
walletAddress3 == walletAddress2, | ||
"walletAddress3 != walletAddress2" | ||
); | ||
} | ||
|
||
} |