-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
587 additions
and
123 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
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 openzeppelin-contracts-upgradeable
added at
723f8c
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
@eth-infinitism/=lib/account-abstraction/contracts/ | ||
@openzeppelin/=lib/openzeppelin-contracts/contracts/ | ||
@openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/ | ||
ds-test/=lib/forge-std/lib/ds-test/src/ | ||
forge-std/=lib/forge-std/src/ | ||
@webauthn/=lib/webauthn.git/src/ |
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
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
script/AccountFactory/01_FactoryDeployImplementation.s.sol
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,52 @@ | ||
// SPDX-License-Identifier: APACHE-2.0 | ||
pragma solidity >=0.8.19 <0.9.0; | ||
|
||
import { AccountFactory } from "src/v1/AccountFactory.sol"; | ||
import { SmartAccount } from "src/v1/Account/SmartAccount.sol"; | ||
import { BaseScript } from "../Base.s.sol"; | ||
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) { | ||
address payable accountImplementation = payable(vm.envAddress("ACCOUNT_IMPLEMENTATION")); | ||
|
||
// 1. 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 | ||
require(Metadata.VERSION == SmartAccount(accountImplementation).VERSION(), "Version mismatch"); | ||
|
||
// 3. 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." | ||
" If you would like to update it later on, consider proxing the account implementaton", | ||
" contract and passing the proxy address as the account implementation.", | ||
"\n\n", | ||
"Are you sure you want to use the following contract? (yes for approval): ", | ||
vm.toString(accountImplementation) | ||
) | ||
); | ||
try vm.prompt(prompt) returns (string memory res) { | ||
// solhint-disable-next-line custom-errors | ||
// forgefmt: disable-next-item | ||
require( | ||
keccak256(abi.encodePacked(res)) == keccak256(abi.encodePacked("yes")), | ||
"Script aborted by the user" | ||
); | ||
} catch (bytes memory) { | ||
// solhint-disable-next-line custom-errors | ||
revert("Entrypoint address not approved"); | ||
} | ||
|
||
// 4. Deploy the account factory | ||
AccountFactory accountFactoryImplementation = new AccountFactory(accountImplementation); | ||
|
||
// 5. Check the version of the account factory is the expected one | ||
require(Metadata.VERSION == accountFactoryImplementation.version(), "Version mismatch"); | ||
|
||
return accountFactoryImplementation; | ||
} | ||
} |
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,40 @@ | ||
// SPDX-License-Identifier: APACHE-2.0 | ||
pragma solidity >=0.8.19 <0.9.0; | ||
|
||
import { AccountFactory } from "src/v1/AccountFactory.sol"; | ||
import { BaseScript } from "../Base.s.sol"; | ||
import { TransparentUpgradeableProxy } from "src/v1/Proxy/TransparentProxy.sol"; | ||
|
||
bytes32 constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; | ||
|
||
/// @title FactoryDeployInstance | ||
/// @notice Deploy an instance of the account factory | ||
contract FactoryDeployInstance is BaseScript { | ||
function run() public broadcast returns (AccountFactory accountFactory, address proxyAdmin) { | ||
// 1. check the proxy owner is valid | ||
address proxyOwner = vm.envAddress("PROXY_OWNER"); | ||
require(proxyOwner != address(0), "Invalid owner address"); | ||
|
||
// 2. check the factory signer is valid | ||
address factorySigner = vm.envAddress("FACTORY_SIGNER"); | ||
require(factorySigner != address(0), "Invalid factory signer address"); | ||
|
||
// 3. check the factory implementation is valid | ||
address payable factoryImplementation = payable(vm.envAddress("FACTORY_IMPLEMENTATION")); | ||
require(address(factoryImplementation).code.length > 0, "Factory implem' not deployed"); | ||
|
||
// 4. Deploy a instance of the factory | ||
accountFactory = AccountFactory( | ||
address( | ||
new TransparentUpgradeableProxy( | ||
factoryImplementation, | ||
proxyOwner, | ||
abi.encodeWithSelector(AccountFactory.initialize.selector, factorySigner) | ||
) | ||
) | ||
); | ||
|
||
// 5. fetch the proxy admin | ||
proxyAdmin = abi.decode(abi.encodePacked(vm.load(address(accountFactory), ADMIN_SLOT)), (address)); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
script/AccountFactory/03_FactoryGetProxyAdminInformation.sol
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,23 @@ | ||
// SPDX-License-Identifier: APACHE-2.0 | ||
pragma solidity >=0.8.19 <0.9.0; | ||
|
||
import { BaseScript } from "../Base.s.sol"; | ||
import { ProxyAdmin } from "src/v1/Proxy/TransparentProxy.sol"; | ||
|
||
bytes32 constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; | ||
|
||
/// @title FactoryGetProxyAdminInformation | ||
/// @notice Fetch the proxy admin and the owner of the proxy admin | ||
contract FactoryGetProxyAdminInformation is BaseScript { | ||
function run() public broadcast returns (address proxyAdmin, address proxyOwner) { | ||
// 1. check the factory implementation is valid | ||
address payable factoryInstance = payable(vm.envAddress("FACTORY_INSTANCE")); | ||
require(address(factoryInstance).code.length > 0, "Factory implem' not deployed"); | ||
|
||
// 2. fetch the proxy admin | ||
proxyAdmin = abi.decode(abi.encodePacked(vm.load(factoryInstance, ADMIN_SLOT)), (address)); | ||
|
||
// 3. fetch the proxy owner | ||
proxyOwner = ProxyAdmin(proxyAdmin).owner(); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
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
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
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
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,8 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity >=0.8.19 <0.9.0; | ||
|
||
import { | ||
ProxyAdmin, | ||
ITransparentUpgradeableProxy, | ||
TransparentUpgradeableProxy | ||
} from "@openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol"; |
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
Oops, something went wrong.