Skip to content

Commit 5c9ae79

Browse files
committed
fixed issues
1 parent 1789277 commit 5c9ae79

File tree

7 files changed

+250
-196
lines changed

7 files changed

+250
-196
lines changed

Makefile

Lines changed: 160 additions & 130 deletions
Large diffs are not rendered by default.

deploy/constants/fee-collector-factory-owner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ module.exports = {
1212
8217: '0xa38038f9Ac2b3A7b4247804A46C787960E160Aed', // Klaytn (not safe)
1313
8453: '0xa4659995DC39d891C1bA9131Aaf5F000E5B57224', // Base
1414
59144: '0x9cCf4d6B76976Ab11CF9f9219A38BA28983A9a27', // Linea
15-
146: '0x56E44874F624EbDE6efCc783eFD685f0FBDC6dcF', // Sonic (not safe)
16-
130: '0x56E44874F624EbDE6efCc783eFD685f0FBDC6dcF', // Unichain (not safe)
15+
146: '0x385004992b43F1A73c6Cb2F7D2B88B79a3c0120f', // Sonic
16+
130: '0xc985620F2F18a6560ca68F1f85107674735CF8e7', // Unichain
1717
324: '0x5cEf041D1C3198Ce7F9D5E0521867e670da7520e', // zksync
1818
};
1919

deploy/constants/fee-collector-owner.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ module.exports = {
1212
8453: '0xa4659995DC39d891C1bA9131Aaf5F000E5B57224', // Base
1313
59144: '0x9cCf4d6B76976Ab11CF9f9219A38BA28983A9a27', // Linea
1414
324: '0x5cEf041D1C3198Ce7F9D5E0521867e670da7520e', // zksync
15+
146: '0x385004992b43F1A73c6Cb2F7D2B88B79a3c0120f', // Sonic
16+
130: '0xc985620F2F18a6560ca68F1f85107674735CF8e7', // Unichain
1517
31337: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
1618
};
1719

deploy/deploy-create3.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

deploy/deploy-new-fee-collector.js

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,38 @@ module.exports = async ({ config }) => {
88
console.log('network id ', chainId);
99
console.log('deployOpts', config.deployOpts);
1010

11-
const feeCollectorOperatorName = config.deployOpts?.feeCollectorOperatorName;
11+
if (!constants.FEE_COLLECTOR_FACTORY[chainId]) {
12+
console.log(`Skipping deployment on chain ${chainId} as no FeeCollectorFactory is set`);
13+
return;
14+
}
1215

13-
const salt = ethers.keccak256(ethers.toUtf8Bytes(feeCollectorOperatorName)); // Use correct salt, for instance: from `deploy/upgrade-fee-collector.js`
16+
for (const feeCollectorOperatorName of config.deployOpts.feeCollectorOperatorNames) {
17+
console.log('Deploying FeeCollector for operator name:', feeCollectorOperatorName);
1418

15-
const feeCollectorFactory = await ethers.getContractAt('FeeCollectorFactory', constants.FEE_COLLECTOR_FACTORY[chainId]);
16-
await feeCollectorFactory.deployFeeCollector(salt);
17-
const feeCollectorAddress = await feeCollectorFactory.getFeeCollectorAddress(salt);
18-
console.log('FeeCollector deployed at', feeCollectorAddress);
19+
if (!constants.FEE_COLLECTOR_OPERATOR?.[chainId]?.[feeCollectorOperatorName]) {
20+
console.log(`Skipping deployment on chain ${chainId} as no operator is set for name ${feeCollectorOperatorName}`);
21+
continue;
22+
}
1923

20-
if (await getChainId() !== '31337') {
21-
await hre.run('verify:verify', {
22-
address: feeCollectorAddress,
23-
constructorArguments: [constants.FEE_COLLECTOR_FACTORY[chainId], '0x'],
24-
});
25-
}
24+
const salt = ethers.keccak256(ethers.toUtf8Bytes(feeCollectorOperatorName)); // Use correct salt, for instance: from `deploy/upgrade-fee-collector.js`
25+
26+
const feeCollectorFactory = await ethers.getContractAt('FeeCollectorFactory', constants.FEE_COLLECTOR_FACTORY[chainId]);
27+
await feeCollectorFactory.deployFeeCollector(salt);
28+
const feeCollectorAddress = await feeCollectorFactory.getFeeCollectorAddress(salt);
29+
console.log('FeeCollector deployed at', feeCollectorAddress);
2630

27-
const OPERATOR = constants.FEE_COLLECTOR_OPERATOR[chainId][feeCollectorOperatorName]; // Replace with the actual operator address
28-
const feeCollector = await ethers.getContractAt('FeeCollector', feeCollectorAddress);
29-
await feeCollector.setOperator(OPERATOR);
30-
console.log('feeCollectorOperator set to', feeCollectorAddress);
31+
if (chainId !== '31337') {
32+
await hre.run('verify:verify', {
33+
address: feeCollectorAddress,
34+
constructorArguments: [constants.FEE_COLLECTOR_FACTORY[chainId], '0x'],
35+
});
36+
}
37+
38+
const OPERATOR = constants.FEE_COLLECTOR_OPERATOR[chainId][feeCollectorOperatorName]; // Replace with the actual operator address
39+
const feeCollector = await ethers.getContractAt('FeeCollector', feeCollectorAddress);
40+
await feeCollector.setOperator(OPERATOR);
41+
console.log('feeCollectorOperator set to', feeCollectorAddress);
42+
}
3143
};
3244

3345
module.exports.skip = async () => true;

deploy/deploy.js

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,66 @@
11
const { getChainId } = require('hardhat');
2-
const { deployAndGetContract } = require('@1inch/solidity-utils');
2+
const { deployAndGetContract, deployAndGetContractWithCreate3 } = require('@1inch/solidity-utils');
33

44
const constants = require('./constants');
55

66
module.exports = async ({ deployments, getNamedAccounts, config }) => {
7+
const networkName = hre.network.name;
78
console.log('running deploy script');
8-
99
const chainId = await getChainId();
1010
console.log('network id ', chainId);
11-
console.log('deployOpts', config.deployOpts);
12-
13-
const CONTRACT_HELPER_NAME = config.deployOpts?.contractHelperName;
14-
15-
const { deployer } = await getNamedAccounts();
16-
await deployAndGetContract({
17-
contractName: CONTRACT_HELPER_NAME,
18-
deployments,
19-
deployer,
20-
constructorArgs: constants.CONSTRUCTOR_ARGS?.[CONTRACT_HELPER_NAME]?.[chainId] ?? [],
21-
});
11+
12+
if (
13+
networkName in hre.config.networks &&
14+
chainId !== hre.config.networks[networkName].chainId.toString()
15+
) {
16+
console.log(`network chain id: ${hre.config.networks[networkName].chainId}, your chain id ${chainId}`);
17+
console.log('skipping wrong chain id deployment');
18+
return;
19+
}
20+
21+
let DEPLOYMENT_METHOD = config.deployOpts?.deploymentMethod || 'create3';
22+
23+
if (chainId === '324') { // create3 is not supported for zksync
24+
DEPLOYMENT_METHOD = 'create';
25+
}
26+
27+
for (const contractHelperName of config.deployOpts.contractHelperNames) {
28+
console.log('Deploying contract helper for name:', contractHelperName);
29+
30+
let result;
31+
32+
if (DEPLOYMENT_METHOD === 'create3') {
33+
let salt = ethers.keccak256(ethers.toUtf8Bytes(contractHelperName));
34+
if (contractHelperName === 'EvmHelpers') {
35+
salt = ethers.keccak256(ethers.toUtf8Bytes('EvmHelpers-new'));
36+
}
37+
if (!constants.CREATE3_DEPLOYER?.[chainId]) {
38+
console.log(`Skipping deployment on chain ${chainId} as no Create3Deployer is set`);
39+
continue;
40+
}
41+
42+
result = await deployAndGetContractWithCreate3({
43+
contractName: contractHelperName,
44+
constructorArgs: constants.CONSTRUCTOR_ARGS?.[contractHelperName]?.[chainId] ?? [],
45+
deploymentName: contractHelperName,
46+
create3Deployer: constants.CREATE3_DEPLOYER[chainId],
47+
salt,
48+
deployments,
49+
});
50+
} else {
51+
const { deployer } = await getNamedAccounts();
52+
53+
result = await deployAndGetContract({
54+
contractName: contractHelperName,
55+
deployments,
56+
deployer,
57+
constructorArgs: constants.CONSTRUCTOR_ARGS?.[contractHelperName]?.[chainId] ?? [],
58+
});
59+
}
60+
61+
console.log(`Address for ${contractHelperName}: ${await result.getAddress()}`);
62+
63+
}
2264
};
2365

2466
module.exports.skip = async () => true;

hardhat.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ module.exports = {
5353
settings: {},
5454
},
5555
deployOpts: {
56-
contractHelperName: process.env.CONTRACT_HELPER_NAME || '',
57-
feeCollectorOperatorName: process.env.FEE_COLLECTOR_OPERATOR_NAME || '',
56+
contractHelperNames: process.env.OPS_EVM_HELPER_NAMES || [],
57+
feeCollectorOperatorNames: process.env.OPS_FEE_COLLECTOR_OPERATOR_NAMES || [],
58+
deploymentMethod: process.env.OPS_DEPLOYMENT_METHOD || 'create3',
5859
},
5960
};

0 commit comments

Comments
 (0)