-
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.
Feature: Add deploy-all task to passkeys (#387)
I needed to deploy the passkeys contracts and found out that there's no deploy command/task This PR: - Adds a `deploy-all` task to the passkey package, similarly to how its used in other packages (4337 and safe-smart-account) The command works (doesn't include output from failed attempts where I had to increase gas price): ``` npm run deploy-all sepolia -w modules/passkey > @safe-global/safe-passkey@0.2.0-alpha.1 deploy-all > hardhat deploy-contracts --network sepolia Nothing to compile No need to generate any newer typings. reusing "SafeSignerLaunchpad" at 0xf9E93EfBF37B588f9c79d509c48b87A26c3DfEB9 reusing "DaimoP256Verifier" at 0xc2b78104907F722DABAc4C69f826a522B2754De4 reusing "FCLP256Verifier" at 0xcA89CBa4813D5B40AeC6E57A30d0Eeb500d6531b reusing "SafeWebAuthnSignerFactory" at 0xc40156AbFEE908E2e3269DA84fa9609bcCDDec60 Verification status for DaimoP256Verifier: SKIPPED Verification status for FCLP256Verifier: SUCCESS Verification status for SafeSignerLaunchpad: SUCCESS Verification status for SafeWebAuthnSignerFactory: SUCCESS already verified: DaimoP256Verifier (0xc2b78104907F722DABAc4C69f826a522B2754De4), skipping. verifying FCLP256Verifier (0xcA89CBa4813D5B40AeC6E57A30d0Eeb500d6531b) ... waiting for result... => contract FCLP256Verifier is now verified verifying SafeSignerLaunchpad (0xf9E93EfBF37B588f9c79d509c48b87A26c3DfEB9) ... waiting for result... => contract SafeSignerLaunchpad is now verified verifying SafeWebAuthnSignerFactory (0xc40156AbFEE908E2e3269DA84fa9609bcCDDec60) ... waiting for result... => contract SafeWebAuthnSignerFactory is now verified ```
- Loading branch information
Showing
5 changed files
with
114 additions
and
0 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
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,9 @@ | ||
import { task } from 'hardhat/config' | ||
|
||
task('deploy-contracts', 'Deploys and verifies Safe contracts').setAction(async (_, hre) => { | ||
await hre.run('deploy') | ||
await hre.run('local-verify') | ||
await hre.run('etherscan-verify', { forceLicense: true, license: 'LGPL-3.0' }) | ||
}) | ||
|
||
export {} |
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,51 @@ | ||
import { task } from 'hardhat/config' | ||
import { loadSolc } from '../utils/solc' | ||
|
||
task('local-verify', 'Verifies that the local deployment files correspond to the on chain code').setAction(async (_, hre) => { | ||
const allowedSourceKey = ['keccak256', 'content'] | ||
const deployedContracts = await hre.deployments.all() | ||
for (const contract of Object.keys(deployedContracts)) { | ||
const deployment = await hre.deployments.get(contract) | ||
if (!deployment.metadata) { | ||
console.log(`Verification status for ${contract}: SKIPPED`) | ||
continue | ||
} | ||
const meta = JSON.parse(deployment.metadata) | ||
const solcjs = await loadSolc(meta.compiler.version) | ||
delete meta.compiler | ||
delete meta.output | ||
delete meta.version | ||
const sources = Object.values<Record<string, unknown>>(meta.sources) | ||
for (const source of sources) { | ||
for (const key of Object.keys(source)) { | ||
if (allowedSourceKey.indexOf(key) < 0) delete source[key] | ||
} | ||
} | ||
meta.settings.outputSelection = {} | ||
const targets = Object.entries<string>(meta.settings.compilationTarget) | ||
for (const [key, value] of targets) { | ||
meta.settings.outputSelection[key] = {} | ||
meta.settings.outputSelection[key][value] = ['evm.deployedBytecode.object', 'evm.deployedBytecode.immutableReferences'] | ||
} | ||
delete meta.settings.compilationTarget | ||
const compiled = solcjs.compile(JSON.stringify(meta)) | ||
const output = JSON.parse(compiled) | ||
for (const [key, value] of targets) { | ||
const compiledContract = output.contracts[key][value] | ||
const onChainCode = hre.ethers.getBytes(await hre.ethers.provider.getCode(deployment.address)) | ||
for (const references of Object.values<{ start: number; length: number }[]>( | ||
compiledContract.evm.deployedBytecode.immutableReferences, | ||
)) { | ||
for (const { start, length } of references) { | ||
onChainCode.fill(0, start, start + length) | ||
} | ||
} | ||
const onchainBytecodeHash = hre.ethers.keccak256(onChainCode) | ||
const localBytecodeHash = hre.ethers.keccak256(`0x${compiledContract.evm.deployedBytecode.object}`) | ||
const verifySuccess = onchainBytecodeHash === localBytecodeHash ? 'SUCCESS' : 'FAILURE' | ||
console.log(`Verification status for ${value}: ${verifySuccess}`) | ||
} | ||
} | ||
}) | ||
|
||
export {} |