diff --git a/contracts/AGWAccount.sol b/contracts/AGWAccount.sol index e59863b..a3453aa 100644 --- a/contracts/AGWAccount.sol +++ b/contracts/AGWAccount.sol @@ -48,10 +48,13 @@ contract AGWAccount is uint256 public constant VERSION = 1; + address public immutable KNOWN_TRUSTED_EOA_VALIDATOR; + /** * @notice Constructor for the account implementation */ - constructor() { + constructor(address knownTrustedEoaValidator) { + KNOWN_TRUSTED_EOA_VALIDATOR = knownTrustedEoaValidator; _disableInitializers(); } @@ -76,14 +79,19 @@ contract AGWAccount is if (address(this) != expectedAddress) { revert Errors.INVALID_SALT(); } + + // add the initial k1 owner as an owner + _k1AddOwner(initialK1Owner); + address thisDeployer = factory.accountToDeployer(address(this)); if (thisDeployer != factory.deployer()) { if (initialK1Owner != thisDeployer) { - revert Errors.NOT_FROM_DEPLOYER(); + // disregard any modules and initial call as the deployer is untrusted + _k1AddValidator(KNOWN_TRUSTED_EOA_VALIDATOR); + return; } } - _k1AddOwner(initialK1Owner); _k1AddValidator(initialK1Validator); for (uint256 i = 0; i < modules.length; ) { diff --git a/deploy/deploy.ts b/deploy/deploy.ts index df1bd73..9b088ae 100644 --- a/deploy/deploy.ts +++ b/deploy/deploy.ts @@ -40,7 +40,7 @@ export default async function (): Promise { implementation = await deployContract( hre, 'ClaveImplementation', - [await batchCaller.getAddress()], + [await eoaValidator.getAddress()], { wallet: fundingWallet, silent: false, diff --git a/test/utils/deployer.ts b/test/utils/deployer.ts index 547416f..3b15199 100644 --- a/test/utils/deployer.ts +++ b/test/utils/deployer.ts @@ -40,11 +40,11 @@ export class ClaveDeployer { ); } - public async implementation(): Promise { + public async implementation(eoaValidator: string): Promise { return await deployContract( this.hre, CONTRACT_NAMES.IMPLEMENTATION, - [], + [eoaValidator], { wallet: this.deployerWallet, silent: true, @@ -95,13 +95,13 @@ export class ClaveDeployer { return factory; } - public async setupFactory(): Promise<{ + public async setupFactory(eoaValidator: string): Promise<{ registry: Contract; implementation: Contract; factory: Contract; }> { const registry = await this.registry(); - const implementation = await this.implementation(); + const implementation = await this.implementation(eoaValidator); const factory = await this.factory(implementation, registry); return { registry, implementation, factory }; diff --git a/test/utils/fixture.ts b/test/utils/fixture.ts index 8b69658..0de4171 100644 --- a/test/utils/fixture.ts +++ b/test/utils/fixture.ts @@ -31,9 +31,9 @@ export const fixture = async ( const wallet = HDNodeWallet.createRandom(); const registry = await deployer.registry(); - const implementation = await deployer.implementation(); - const factory = await deployer.factory(implementation, registry); const eoaValidator = await deployer.validator(VALIDATORS.EOA); + const implementation = await deployer.implementation(await eoaValidator.getAddress()); + const factory = await deployer.factory(implementation, registry); const teeValidator = await deployer.validator(VALIDATORS.TEE); const mockValidator = await deployer.validator(VALIDATORS.MOCK); const passkeyValidator = await deployer.validator(VALIDATORS.PASSKEY);