Skip to content

Commit

Permalink
Using safe-singleton-factory
Browse files Browse the repository at this point in the history
  • Loading branch information
remedcu committed Aug 5, 2024
1 parent d2def83 commit f57763d
Show file tree
Hide file tree
Showing 9 changed files with 415 additions and 284 deletions.
29 changes: 22 additions & 7 deletions modules/4337/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This changelog only contains changes starting from version 0.2.0

# Version 0.3.0
# Version 0.3.1

## Compiler settings

Expand All @@ -16,18 +16,33 @@ The official deployments support the EntryPoint v0.7.0 with the canonical deploy

## Expected addresses

- `SafeModuleSetup` at `0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47`
- `Safe4337Module` at `0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226`
- `SafeModuleSetup` at `0xF2C2C95C168Ef121b052B4c518889CFe166cB4Fa`
- `Safe4337Module` at `0x68C77b778228823a06e3CbcDA816d46D80B1C728`

## Changes

### Security Fixes
### General

None
- Using the [`safe-singleton-factory`](https://github.com/safe-global/safe-singleton-factory) to deploy contracts.

### Compatibility Fixes
# Version 0.3.0

## Compiler settings

None
Solidity compiler: [0.8.23](https://github.com/ethereum/solidity/releases/tag/v0.8.23)

Solidity optimizer: enabled with 10.000.000 runs

## Supported EntryPoint

The official deployments support the EntryPoint v0.7.0 with the canonical deployment at `0x0000000071727De22E5E9d8BAf0edAc6f37da032`.

## Expected addresses

- `SafeModuleSetup` at `0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47`
- `Safe4337Module` at `0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226`

## Changes

### General

Expand Down
30 changes: 26 additions & 4 deletions modules/4337/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import 'hardhat-deploy'
import dotenv from 'dotenv'
import type { HardhatUserConfig, HttpNetworkUserConfig } from 'hardhat/types'
import yargs from 'yargs/yargs'
import { getSingletonFactoryInfo } from "@safe-global/safe-singleton-factory";
import { DeterministicDeploymentInfo } from "hardhat-deploy/dist/types";
import './src/tasks/localVerify'
import './src/tasks/deployContracts'
import './src/tasks/codesize'

const argv = yargs(process.argv.slice(2))
.options({ network: { type: 'string', default: 'hardhat' } })
Expand All @@ -30,10 +35,6 @@ if (['mainnet', 'sepolia', 'polygon', 'amoy'].includes(argv.network) && INFURA_K
throw new Error(`Could not find Infura key in env, unable to connect to network ${argv.network}`)
}

import './src/tasks/localVerify'
import './src/tasks/deployContracts'
import './src/tasks/codesize'

const solidityVersion = SOLIDITY_VERSION || '0.8.23'
const soliditySettings = SOLIDITY_SETTINGS
? JSON.parse(SOLIDITY_SETTINGS)
Expand All @@ -45,6 +46,26 @@ const soliditySettings = SOLIDITY_SETTINGS
},
}

const deterministicDeployment = (network: string): DeterministicDeploymentInfo => {
const info = getSingletonFactoryInfo(parseInt(network));
if (!info) {
throw new Error(`
Safe factory not found for network ${network}. You can request a new deployment at https://github.com/safe-global/safe-singleton-factory.
For more information, see https://github.com/safe-global/safe-smart-account#replay-protection-eip-155
`);
}

const gasLimit = BigInt(info.gasLimit)
const gasPrice = BigInt(info.gasPrice)

return {
factory: info.address,
deployer: info.signerAddress,
funding: String(gasLimit * gasPrice),
signedTx: info.transaction,
};
};

const customNetwork = NODE_URL
? {
custom: {
Expand Down Expand Up @@ -98,6 +119,7 @@ const userConfig: HardhatUserConfig = {
},
...customNetwork,
},
deterministicDeployment,
namedAccounts: {
deployer: 0,
},
Expand Down
2 changes: 0 additions & 2 deletions modules/allowances/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import '@nomicfoundation/hardhat-toolbox'
import 'hardhat-deploy'

import './tasks/deploy_verify'

import dotenv from 'dotenv'
import { HardhatUserConfig, HttpNetworkUserConfig } from 'hardhat/types'
import { DeterministicDeploymentInfo } from 'hardhat-deploy/dist/types'
Expand Down
9 changes: 5 additions & 4 deletions modules/passkey/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ EVM target: Paris

## Expected addresses

- `SafeWebAuthnSignerFactory` at `TBD`
- `SafeWebAuthnSharedSigner` at `TBD`
- `DaimoP256Verifier` at `0xc2b78104907F722DABAc4C69f826a522B2754De4`
- `FCLP256Verifier` at `TBD`
- `SafeWebAuthnSignerFactory` at `0x1d31F259eE307358a26dFb23EB365939E8641195`
- `SafeWebAuthnSharedSigner` at `0x94a4F6affBd8975951142c3999aEAB7ecee555c2`
- `DaimoP256Verifier` at `0xfd08a316255D83133c5d74EcF62B625414f68C14`
- `FCLP256Verifier` at `0xA86e0054C51E4894D88762a017ECc5E5235f5DBA`

## Changes

Expand All @@ -28,6 +28,7 @@ EVM target: Paris
- Index the `signer` field for `Created` event in the `SafeWebAuthnSignerFactory` contract.
- Use more consistent compiler version pragmas throughout the contracts.
- Initial release of the `SafeWebAuthnSharedSigner` contract.
- Using the [`safe-singleton-factory`](https://github.com/safe-global/safe-singleton-factory) to deploy contracts.

# Version 0.2.0

Expand Down
23 changes: 23 additions & 0 deletions modules/passkey/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { HttpNetworkUserConfig } from 'hardhat/types'
import './src/tasks/codesize'
import './src/tasks/deployContracts'
import './src/tasks/localVerify'
import { getSingletonFactoryInfo } from "@safe-global/safe-singleton-factory";

Check failure on line 10 in modules/passkey/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `"@safe-global/safe-singleton-factory";` with `'@safe-global/safe-singleton-factory'`
import { DeterministicDeploymentInfo } from "hardhat-deploy/dist/types";

Check failure on line 11 in modules/passkey/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `"hardhat-deploy/dist/types";` with `'hardhat-deploy/dist/types'`

dotenv.config()
const { CUSTOM_NODE_URL, MNEMONIC, ETHERSCAN_API_KEY, PK } = process.env
Expand Down Expand Up @@ -43,6 +45,26 @@ const compilerSettings = {
},
}

const deterministicDeployment = (network: string): DeterministicDeploymentInfo => {
const info = getSingletonFactoryInfo(parseInt(network));

Check failure on line 49 in modules/passkey/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `;`
if (!info) {
throw new Error(`

Check failure on line 51 in modules/passkey/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
Safe factory not found for network ${network}. You can request a new deployment at https://github.com/safe-global/safe-singleton-factory.
For more information, see https://github.com/safe-global/safe-smart-account#replay-protection-eip-155
`);

Check failure on line 54 in modules/passkey/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `;`
}

const gasLimit = BigInt(info.gasLimit)
const gasPrice = BigInt(info.gasPrice)

return {
factory: info.address,

Check failure on line 61 in modules/passkey/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
deployer: info.signerAddress,

Check failure on line 62 in modules/passkey/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
funding: String(gasLimit * gasPrice),

Check failure on line 63 in modules/passkey/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `······` with `····`
signedTx: info.transaction,

Check failure on line 64 in modules/passkey/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
};

Check failure on line 65 in modules/passkey/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `;`
};

const config: HardhatUserConfig = {
paths: {
artifacts: 'build/artifacts',
Expand All @@ -65,6 +87,7 @@ const config: HardhatUserConfig = {
},
...customNetwork,
},
deterministicDeployment,
solidity: {
compilers: [compilerSettings],
overrides: {
Expand Down
22 changes: 22 additions & 0 deletions modules/recovery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

# Version 0.1.1

## Compiler settings

Solidity compiler: [0.8.20](https://github.com/ethereum/solidity/releases/tag/v0.8.20)

Solidity optimizer: enabled via IR with 1.000.000 runs

## Recovery Period

The recovery period is 14 days.

## Expected addresses

- `SocialRecoveryModule` at `0x9BacD92F4687Db306D7ded5d4513a51EA05df25b`

## Changes

### General

- Using the [`safe-singleton-factory`](https://github.com/safe-global/safe-singleton-factory) to deploy contracts.

# Version 0.1.0

## Compiler settings
Expand Down
23 changes: 23 additions & 0 deletions modules/recovery/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'hardhat-deploy'
import dotenv from 'dotenv'
import type { HardhatUserConfig, HttpNetworkUserConfig } from 'hardhat/types'
import yargs from 'yargs/yargs'
import { getSingletonFactoryInfo } from "@safe-global/safe-singleton-factory";
import { DeterministicDeploymentInfo } from "hardhat-deploy/dist/types";

import './src/tasks/deployContracts'
import './src/tasks/localVerify'
Expand Down Expand Up @@ -42,6 +44,26 @@ const customNetwork = CUSTOM_NODE_URL
}
: {}

const deterministicDeployment = (network: string): DeterministicDeploymentInfo => {
const info = getSingletonFactoryInfo(parseInt(network));
if (!info) {
throw new Error(`
Safe factory not found for network ${network}. You can request a new deployment at https://github.com/safe-global/safe-singleton-factory.
For more information, see https://github.com/safe-global/safe-smart-account#replay-protection-eip-155
`);
}

const gasLimit = BigInt(info.gasLimit)
const gasPrice = BigInt(info.gasPrice)

return {
factory: info.address,
deployer: info.signerAddress,
funding: String(gasLimit * gasPrice),
signedTx: info.transaction,
};
};

const userConfig: HardhatUserConfig = {
paths: {
artifacts: 'build/artifacts',
Expand Down Expand Up @@ -71,6 +93,7 @@ const userConfig: HardhatUserConfig = {
},
...customNetwork,
},
deterministicDeployment,
namedAccounts: {
deployer: 0,
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"pnpm": "^9"
},
"devDependencies": {
"@safe-global/safe-singleton-factory": "^1.0.31",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "^7.12.0",
"eslint": "^8.57.0",
Expand Down
Loading

0 comments on commit f57763d

Please sign in to comment.