diff --git a/modules/passkey/CHANGELOG.md b/modules/passkey/CHANGELOG.md index 0c6b3da6..a12f625d 100644 --- a/modules/passkey/CHANGELOG.md +++ b/modules/passkey/CHANGELOG.md @@ -13,12 +13,9 @@ EVM target: Paris - `SafeWebAuthnSignerFactory` at `0x1d31F259eE307358a26dFb23EB365939E8641195` - `SafeWebAuthnSharedSigner` at `0x94a4F6affBd8975951142c3999aEAB7ecee555c2` +- `DaimoP256Verifier` at `0xc2b78104907F722DABAc4C69f826a522B2754De4` ([source](https://p256.eth.limo/)) - `FCLP256Verifier` at `0xA86e0054C51E4894D88762a017ECc5E5235f5DBA` -### Official Deployment Address from 3rd party - -- `DaimoP256Verifier` at `0xc2b78104907F722DABAc4C69f826a522B2754De4` ([Source](https://p256.eth.limo/)) - ## Changes ### Security Fixes diff --git a/modules/passkey/src/deploy/verifiers.ts b/modules/passkey/src/deploy/verifiers.ts index ec377d77..c55c18db 100644 --- a/modules/passkey/src/deploy/verifiers.ts +++ b/modules/passkey/src/deploy/verifiers.ts @@ -1,18 +1,24 @@ +import type { HardhatRuntimeEnvironment } from 'hardhat/types' import type { DeployFunction } from 'hardhat-deploy/types' import DaimoP256Verifier from '../vendor/daimo-eth/P256Verifier.json' -const deploy: DeployFunction = async ({ deployments, getNamedAccounts }) => { +const deploy: DeployFunction = async (hre) => { + const { deployments, getNamedAccounts } = hre + const { deployer } = await getNamedAccounts() const { deploy } = deployments - await deploy('DaimoP256Verifier', { - from: deployer, - contract: DaimoP256Verifier, - args: [], - deterministicDeployment: true, - log: true, - }) + // The official Daimo P-256 verifier contract is deployed using the Arachnid CREATE2 deployer. + await withArachnidDeterministicDeploymentProxy(hre, () => + deploy('DaimoP256Verifier', { + from: deployer, + contract: DaimoP256Verifier, + args: [], + deterministicDeployment: true, + log: true, + }), + ) await deploy('FCLP256Verifier', { from: deployer, @@ -22,4 +28,17 @@ const deploy: DeployFunction = async ({ deployments, getNamedAccounts }) => { }) } +function withArachnidDeterministicDeploymentProxy({ config }: HardhatRuntimeEnvironment, f: () => Promise): Promise { + // This is a bit hacky - but the `hardhat-deploy` package reads that deterministic deployment + // configuration before deploying each contract. This means that we can temporarily override the + // the configuration to `undefined` so that it uses the (default) Arachnid deterministic + // deployment proxy for a specific deployment, and then restore the configuration afterwards so + // that remaining contracts use the deterministic deployment factory from `hardhat.config.ts`. + const existingConfig = config.deterministicDeployment + config.deterministicDeployment = undefined + return f().finally(() => { + config.deterministicDeployment = existingConfig + }) +} + export default deploy diff --git a/packages/4337-local-bundler/src/deploy/entrypoint.ts b/packages/4337-local-bundler/src/deploy/entrypoint.ts index 8983b69b..4197b6d3 100644 --- a/packages/4337-local-bundler/src/deploy/entrypoint.ts +++ b/packages/4337-local-bundler/src/deploy/entrypoint.ts @@ -1,7 +1,9 @@ import EntryPoint from '@account-abstraction/contracts/artifacts/EntryPoint.json' -import { DeployFunction } from 'hardhat-deploy/types' +import type { HardhatRuntimeEnvironment } from 'hardhat/types' +import type { DeployFunction } from 'hardhat-deploy/types' -const deploy: DeployFunction = async ({ deployments, getNamedAccounts, network }) => { +const deploy: DeployFunction = async (hre) => { + const { deployments, getNamedAccounts, network } = hre if (!network.tags.entrypoint) { return } @@ -9,12 +11,28 @@ const deploy: DeployFunction = async ({ deployments, getNamedAccounts, network } const { deployer } = await getNamedAccounts() const { deploy } = deployments - await deploy('EntryPoint', { - from: deployer, - contract: EntryPoint, - args: [], - log: true, - deterministicDeployment: '0x90d8084deab30c2a37c45e8d47f49f2f7965183cb6990a98943ef94940681de3', + // The official ERC-4337 entry point contract is deployed using the Arachnid CREATE2 deployer. + await withArachnidDeterministicDeploymentProxy(hre, () => + deploy('EntryPoint', { + from: deployer, + contract: EntryPoint, + args: [], + log: true, + deterministicDeployment: '0x90d8084deab30c2a37c45e8d47f49f2f7965183cb6990a98943ef94940681de3', + }), + ) +} + +function withArachnidDeterministicDeploymentProxy({ config }: HardhatRuntimeEnvironment, f: () => Promise): Promise { + // This is a bit hacky - but the `hardhat-deploy` package reads that deterministic deployment + // configuration before deploying each contract. This means that we can temporarily override the + // the configuration to `undefined` so that it uses the (default) Arachnid deterministic + // deployment proxy for a specific deployment, and then restore the configuration afterwards so + // that remaining contracts use the deterministic deployment factory from `hardhat.config.ts`. + const existingConfig = config.deterministicDeployment + config.deterministicDeployment = undefined + return f().finally(() => { + config.deterministicDeployment = existingConfig }) }