Skip to content

Commit

Permalink
Merge pull request #77 from etherspot/deploy-modular-etherspot-wallet…
Browse files Browse the repository at this point in the history
…-factory-all-chains

- Added scripts, FactoryStaker.sol and deployed and staked new factories
  • Loading branch information
cryptonoyaiba authored Aug 20, 2024
2 parents c7c519e + 8c21317 commit 9d12265
Show file tree
Hide file tree
Showing 112 changed files with 20,823 additions and 74 deletions.
173 changes: 165 additions & 8 deletions DEPLOYMENTS_MODULAR.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/7810ea4a0b1001fe4f85cee7595e8e6b.json"
"buildInfo": "../../../../build-info/47dc323db6fafbe3d93a9be5111ed9f5.json"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/7810ea4a0b1001fe4f85cee7595e8e6b.json"
"buildInfo": "../../../../build-info/47dc323db6fafbe3d93a9be5111ed9f5.json"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../../build-info/7810ea4a0b1001fe4f85cee7595e8e6b.json"
"buildInfo": "../../../../../build-info/47dc323db6fafbe3d93a9be5111ed9f5.json"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../../build-info/7810ea4a0b1001fe4f85cee7595e8e6b.json"
"buildInfo": "../../../../../build-info/47dc323db6fafbe3d93a9be5111ed9f5.json"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../../build-info/7810ea4a0b1001fe4f85cee7595e8e6b.json"
"buildInfo": "../../../../../build-info/47dc323db6fafbe3d93a9be5111ed9f5.json"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/7810ea4a0b1001fe4f85cee7595e8e6b.json"
"buildInfo": "../../../../build-info/47dc323db6fafbe3d93a9be5111ed9f5.json"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/7810ea4a0b1001fe4f85cee7595e8e6b.json"
"buildInfo": "../../../../build-info/47dc323db6fafbe3d93a9be5111ed9f5.json"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/7810ea4a0b1001fe4f85cee7595e8e6b.json"
"buildInfo": "../../../../build-info/47dc323db6fafbe3d93a9be5111ed9f5.json"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/7810ea4a0b1001fe4f85cee7595e8e6b.json"
"buildInfo": "../../../../build-info/47dc323db6fafbe3d93a9be5111ed9f5.json"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../../build-info/7810ea4a0b1001fe4f85cee7595e8e6b.json"
"buildInfo": "../../../../../build-info/47dc323db6fafbe3d93a9be5111ed9f5.json"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../../build-info/7810ea4a0b1001fe4f85cee7595e8e6b.json"
"buildInfo": "../../../../../build-info/47dc323db6fafbe3d93a9be5111ed9f5.json"
}
9 changes: 9 additions & 0 deletions config/etherscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const etherscan: HardhatUserConfig['etherscan'] = {
ancient8TestnetV2: process.env.BASESCAN_API_KEY!, // works with same key
amoy: process.env.POLYSCAN_API_KEY!,
mantleSepolia: process.env.BASEGOERLI_BLOCKSCOUT_API_KEY!, // works with same key
xdcApothem: process.env.XDC_API_KEY!,
},
customChains: [
{
Expand Down Expand Up @@ -261,6 +262,14 @@ const etherscan: HardhatUserConfig['etherscan'] = {
browserURL: 'https://rootstock-testnet.blockscout.com/',
},
},
{
network: 'xdcApothem',
chainId: 51,
urls: {
apiURL: 'https://abapi.blocksscan.io/',
browserURL: 'https://explorer.apothem.network/',
},
},
],
};

Expand Down
5 changes: 5 additions & 0 deletions config/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ const networks: HardhatUserConfig['networks'] = {
url: 'https://rpc.apothem.network',
accounts: [process.env.DEPLOYER_PRIVATE_KEY!],
},
xdc: {
chainId: 50,
url: 'https://rpc.xdc.org',
accounts: [process.env.DEPLOYER_PRIVATE_KEY!],
},
dev: { url: 'http://localhost:8545' },
};
export default networks;
64 changes: 64 additions & 0 deletions deploy/012_deploy_modular_factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { ethers } from 'ethers';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';

const deployModular: DeployFunction = async function (
hre: HardhatRuntimeEnvironment
) {
const { deployments, getNamedAccounts } = hre;
const { deploy, execute, read } = deployments;
const { from } = await getNamedAccounts();
const ENTRYPOINT_07 = '0x0000000071727De22E5E9d8BAf0edAc6f37da032';
const IMPLEMENTATION = '0x202A5598bDba2cE62bFfA13EcccB04969719Fad9';

console.log('starting deployments...');

// Wait for 5 blocks
let currentBlock = await hre.ethers.provider.getBlockNumber();
while (currentBlock + 5 > (await hre.ethers.provider.getBlockNumber())) {}

console.log('deploying ModularEtherspotWalletFactory...');
const factory = await deploy('ModularEtherspotWalletFactory', {
from,
args: [IMPLEMENTATION, from],
log: true,
});
console.log('ModularEtherspotWalletFactory deployed at:', factory.address);

// Wait for 5 blocks
currentBlock = await hre.ethers.provider.getBlockNumber();
while (currentBlock + 5 > (await hre.ethers.provider.getBlockNumber())) {}

// check implementation set correctly
console.log('Checking implementation in ModularEtherspotWalletFactory...');
console.log(
`check implementation matches: ${await read(
'ModularEtherspotWalletFactory',
'implementation'
)} == ${IMPLEMENTATION}`
);

// Wait for 5 blocks
currentBlock = await hre.ethers.provider.getBlockNumber();
while (currentBlock + 5 > (await hre.ethers.provider.getBlockNumber())) {}

console.log('Staking ModularEtherspotWalletFactory with EntryPoint...');
await execute(
'ModularEtherspotWalletFactory',
{
from,
value: await ethers.utils.parseEther('0.1'),
log: true,
gasLimit: 6e6,
},
'addStake',
ENTRYPOINT_07,
86400
);

console.log(`Done!`);
};

deployModular.tags = ['deploy-modular'];

export default deployModular;
117 changes: 117 additions & 0 deletions deploy/013_deploy_all_modular.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { ethers } from 'ethers';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';

const deployAllModular: DeployFunction = async function (
hre: HardhatRuntimeEnvironment
) {
const { deployments, getNamedAccounts } = hre;
const { deploy, execute, read } = deployments;
const { from } = await getNamedAccounts();
const ENTRYPOINT_07 = '0x0000000071727De22E5E9d8BAf0edAc6f37da032';
// bytes32(abi.encodePacked("ModularEtherspotWallet:Create2:salt"));
const SALT =
'0x4d6f64756c6172457468657273706f7457616c6c65743a437265617465323a73';

console.log('starting deployments...');

console.log('deploying ModularEtherspotWallet...');
const implementation = await deploy('ModularEtherspotWallet', {
deterministicDeployment: SALT,
from,
args: [],
gasLimit: 6e6,
log: true,
});
console.log(`ModularEtherspotWallet deployed at: ${implementation.address}`);

// Wait for 5 blocks
let currentBlock = await hre.ethers.provider.getBlockNumber();
while (currentBlock + 5 > (await hre.ethers.provider.getBlockNumber())) {}

console.log('deploying ModularEtherspotWalletFactory...');
const factory = await deploy('ModularEtherspotWalletFactory', {
deterministicDeployment: SALT,
from,
args: [implementation.address, from],
log: true,
});
console.log('ModularEtherspotWalletFactory deployed at:', factory.address);

// Wait for 5 blocks
currentBlock = await hre.ethers.provider.getBlockNumber();
while (currentBlock + 5 > (await hre.ethers.provider.getBlockNumber())) {}

// check implementation set correctly
console.log('Checking implementation in ModularEtherspotWalletFactory...');
console.log(
`check implementation matches: ${await read(
'ModularEtherspotWalletFactory',
'implementation'
)} == ${implementation.address}`
);

// Wait for 5 blocks
currentBlock = await hre.ethers.provider.getBlockNumber();
while (currentBlock + 5 > (await hre.ethers.provider.getBlockNumber())) {}

console.log('deploying Bootstrap...');
const bootstrap = await deploy('Bootstrap', {
deterministicDeployment: SALT,
from,
args: [],
log: true,
});
console.log('Bootstrap deployed at:', bootstrap.address);

// Wait for 5 blocks
currentBlock = await hre.ethers.provider.getBlockNumber();
while (currentBlock + 5 > (await hre.ethers.provider.getBlockNumber())) {}

console.log('deploying MultipleOwnerECDSAValidator...');
const ecdsaValidator = await deploy('MultipleOwnerECDSAValidator', {
deterministicDeployment: SALT,
from,
args: [],
log: true,
});
console.log(
'MultipleOwnerECDSAValidator deployed at:',
ecdsaValidator.address
);

// Wait for 5 blocks
currentBlock = await hre.ethers.provider.getBlockNumber();
while (currentBlock + 5 > (await hre.ethers.provider.getBlockNumber())) {}

// console.log('deploying ERC20SessionKeyValidator...');
// const sessionKeyValidator = await deploy('ERC20SessionKeyValidator', {
// from,
// args: [],
// log: true,
// });
// console.log(
// 'ERC20SessionKeyValidator deployed at:',
// sessionKeyValidator.address
// );

console.log('Staking ModularEtherspotWalletFactory with EntryPoint...');
await execute(
'ModularEtherspotWalletFactory',
{
from,
value: await ethers.utils.parseEther('0.01'),
log: true,
gasLimit: 6e6,
},
'addStake',
ENTRYPOINT_07,
86400
);

console.log(`Done!`);
};

deployAllModular.tags = ['deploy-all-modular'];

export default deployAllModular;
55 changes: 55 additions & 0 deletions deploy/014_verify_all_modular.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';

const verifyAllModular: DeployFunction = async function (
hre: HardhatRuntimeEnvironment
) {
const { getNamedAccounts } = hre;
const { from } = await getNamedAccounts();

const WALLET_FACTORY_ADDRESS = '0xB7361924B4F56af570680d56A03895A16bC54Be0';
const WALLET_IMPLEMENTATION_ADDRESS =
'0x9A54329dCEc6b961F788bE5017110ac30c76b107';
const BOOTSTRAP_ADDRESS = '0x805650ce74561C85baA44a8Bd13E19633Fd0F79d';
const MULTIPLE_OWNER_ECDSA_VALIDATOR_ADDRESS =
'0x68BA597bf6B9097b1D89b8E0D34646D30997f773';

console.log('starting verification...');
console.log('verifying wallet factory...');
await hre.run('verify:verify', {
address: WALLET_FACTORY_ADDRESS,
contract:
'src/modular-etherspot-wallet/wallet/ModularEtherspotWallet.sol:ModularEtherspotWallet',
constructorArguments: [],
});

console.log('verifying wallet implementation...');
await hre.run('verify:verify', {
address: WALLET_IMPLEMENTATION_ADDRESS,
contract:
'src/modular-etherspot-wallet/wallet/ModularEtherspotWalletFactory.sol:ModularEtherspotWalletFactory',
constructorArguments: [WALLET_FACTORY_ADDRESS, from],
});

console.log('verifying bootstrap...');
await hre.run('verify:verify', {
address: BOOTSTRAP_ADDRESS,
contract:
'src/modular-etherspot-wallet/erc7579-ref-impl/utils/Bootstrap.sol:Bootstrap',
constructorArguments: [],
});

console.log('verifying multiple owner ecdsa validator...');
await hre.run('verify:verify', {
address: MULTIPLE_OWNER_ECDSA_VALIDATOR_ADDRESS,
contract:
'src/modular-etherspot-wallet/modules/validators/MultipleOwnerECDSAValidator.sol:MultipleOwnerECDSAValidator',
constructorArguments: [],
});

console.log('completed verification!');
};

verifyAllModular.tags = ['verify-all-modular'];

export default verifyAllModular;
1 change: 1 addition & 0 deletions deployments/xdc/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
50
Loading

0 comments on commit 9d12265

Please sign in to comment.