Skip to content

Commit

Permalink
🔨 simplify factory scripts
Browse files Browse the repository at this point in the history
Following recent factory updates, the factory scripts have been simplified.
All scripts related to the upgradeability have been removed.
  • Loading branch information
qd-qd committed Apr 4, 2024
1 parent a60b1b3 commit e3ce147
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 93 deletions.
13 changes: 6 additions & 7 deletions script/Account/01_AccountDeployImplementation.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,15 @@ contract SmartAccountDeploy is BaseScript {
// 2. Check if the address of the entryPoint is deployed
require(entryPointAddress.code.length > 0, "The entrypoint is not deployed");

// 3. Run the script using the entrypoint address
return run(entryPointAddress);
}

function run(address entryPointAddress) internal broadcast returns (SmartAccount) {
// 3. Get the address of the verifier and check if it is deployed
address verifier = vm.envAddress("WEBAUTHN_VERIFIER");

// 1. Check if the address of the verifier is correct
require(verifier.code.length > 0, "The verifier is not deployed");

// 3. Run the script using the entrypoint address
return run(entryPointAddress, verifier);
}

function run(address entryPointAddress, address verifier) internal broadcast returns (SmartAccount) {
// 2. Deploy the smart account
SmartAccount account = new SmartAccount(entryPointAddress, verifier);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ import { Metadata } from "src/v1/Metadata.sol";
/// @title FactoryDeployImplementation
/// @notice Deploy an implementation of the account factory
contract FactoryDeployImplementation is BaseScript {
function run() public broadcast returns (AccountFactory) {
function run() public returns (AccountFactory) {
// 1. get the environment variables
address payable accountImplementation = payable(vm.envAddress("ACCOUNT_IMPLEMENTATION"));
address factorySigner = vm.envAddress("FACTORY_SIGNER");

// 1. Check if the account implementation is deployed
// 2. Check if the account implementation is deployed
require(address(accountImplementation).code.length > 0, "Account not deployed");

// 2. Check the version of the account is the expected one
// 3. Check the version of the account is the expected one
require(Metadata.VERSION == SmartAccount(accountImplementation).version(), "Version mismatch");

// 3. Confirm the account implementation address with the user
// 4. Confirm the account implementation address with the user
string memory prompt = string(
abi.encodePacked(
"The account implementation can never be changed in the factory contract."
Expand All @@ -41,8 +43,13 @@ contract FactoryDeployImplementation is BaseScript {
revert("Entrypoint address not approved");
}

// 5. run the script
return run(accountImplementation, factorySigner);
}

function run(address accountImplementation, address factorySigner) internal broadcast returns (AccountFactory) {
// 4. Deploy the account factory
AccountFactory accountFactoryImplementation = new AccountFactory(accountImplementation);
AccountFactory accountFactoryImplementation = new AccountFactory(accountImplementation, factorySigner);

// 5. Check the version of the account factory is the expected one
require(Metadata.VERSION == accountFactoryImplementation.version(), "Version mismatch");
Expand Down
40 changes: 0 additions & 40 deletions script/AccountFactory/02_FactoryDeployInstance.s.sol

This file was deleted.

23 changes: 0 additions & 23 deletions script/AccountFactory/03_FactoryGetProxyAdminInformation.sol

This file was deleted.

18 changes: 0 additions & 18 deletions script/AccountFactory/07_FactoryGetAccountImplem.s.sol

This file was deleted.

0 comments on commit e3ce147

Please sign in to comment.