Skip to content

Commit e737a6b

Browse files
committed
Refactor FactoryDeployer to use chainId and streamline factory initialization; update config for optional factoryType and salt
1 parent 69be4ab commit e737a6b

File tree

5 files changed

+16
-25
lines changed

5 files changed

+16
-25
lines changed

config/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
"ERC1538Proxy": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
138138
"IexecLibOrders_v5": "0xE8b04c85C47fcEc0e9eE30D4034e2997f6519123",
139139
"factory": "0xfAC000a12dA42B871c0AaD5F25391aAe62958Db1",
140+
"factoryType": "generic",
140141
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000"
141142
}
142143
},
@@ -154,6 +155,8 @@
154155
},
155156
"v5": {
156157
"factory": "0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed",
158+
"factoryType": "createx",
159+
"ERC1538Proxy": "0x14B465079537655E1662F012e99EBa3863c8B9E0",
157160
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000"
158161
}
159162
},
@@ -169,6 +172,7 @@
169172
},
170173
"v5": {
171174
"factory": "0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed",
175+
"factoryType": "createx",
172176
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000"
173177
}
174178
},

deploy/0_deploy.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ export default async function deploy() {
5656
const chainId = (await ethers.provider.getNetwork()).chainId;
5757
const [owner] = await ethers.getSigners();
5858
const deploymentOptions = config.getChainConfigOrDefault(chainId);
59-
const salt = process.env.SALT || deploymentOptions.v5.salt || ethers.ZeroHash;
60-
const factoryAddress = process.env.FACTORY_ADDRESS || deploymentOptions.v5.factory;
61-
const factoryDeployer = new FactoryDeployer(owner, salt, factoryAddress);
59+
const factoryDeployer = new FactoryDeployer(owner, chainId);
6260
// Deploy RLC
6361
const isTokenMode = !config.isNativeChain(deploymentOptions);
6462
let rlcInstanceAddress = isTokenMode

scripts/deploy-timelock.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { duration } from '@nomicfoundation/hardhat-network-helpers/dist/src/help
55
import { ethers } from 'hardhat';
66
import { TimelockController__factory } from '../typechain';
77
import { FactoryDeployer } from '../utils/FactoryDeployer';
8-
import config from '../utils/config';
98

109
/**
1110
* Deploy TimelockController contract using the generic factory.
@@ -15,12 +14,7 @@ export const deploy = async () => {
1514
console.log('Deploying TimelockController..');
1615
const chainId = (await ethers.provider.getNetwork()).chainId;
1716
const [owner] = await ethers.getSigners();
18-
const deploymentOptions = config.getChainConfigOrDefault(chainId);
19-
const salt = process.env.SALT || deploymentOptions.v5.salt;
20-
21-
// Initialize factory deployer
22-
const factoryAddress = process.env.FACTORY_ADDRESS || deploymentOptions.v5.factory;
23-
const factoryDeployer = new FactoryDeployer(owner, salt, factoryAddress);
17+
const factoryDeployer = new FactoryDeployer(owner, chainId);
2418

2519
// Deploy TimelockController
2620
const ONE_WEEK_IN_SECONDS = duration.days(7);

utils/FactoryDeployer.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,22 @@ import factorySignedTxJson from 'createx/scripts/presigned-createx-deployment-tr
66
import { ContractFactory } from 'ethers';
77
import { deployments, ethers } from 'hardhat';
88
import { GenericFactory, GenericFactory__factory, ICreateX, ICreateX__factory } from '../typechain';
9+
import config from '../utils/config';
910
import { getBaseNameFromContractFactory } from './deploy-tools';
10-
11-
// Define factory types
12-
type FactoryType = 'createx' | 'generic';
13-
1411
export class FactoryDeployer {
1512
owner: SignerWithAddress;
1613
salt: string;
1714
factoryAddress?: string;
18-
factoryType: FactoryType;
15+
factoryType: string;
1916
factory?: ICreateX | GenericFactory;
2017

21-
constructor(
22-
owner: SignerWithAddress,
23-
salt: string,
24-
factoryAddress?: string,
25-
factoryType: FactoryType = 'createx',
26-
) {
18+
constructor(owner: SignerWithAddress, chainId: bigint) {
19+
const deploymentOptions = config.getChainConfigOrDefault(chainId);
2720
this.owner = owner;
28-
this.salt = salt;
29-
this.factoryAddress = factoryAddress;
30-
this.factoryType = factoryType;
21+
this.salt = process.env.SALT || deploymentOptions.v5.salt || ethers.ZeroHash;
22+
this.factoryAddress = process.env.FACTORY_ADDRESS || deploymentOptions.v5.factory;
23+
this.factoryType =
24+
process.env.FACTORY_TYPE || deploymentOptions.v5.factoryType || 'createx';
3125
}
3226

3327
/**

utils/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ type ChainConfig = {
5050
};
5151
v5: {
5252
factory?: string;
53-
salt: string;
53+
factoryType?: string;
54+
salt?: string;
5455
AppRegistry?: string;
5556
DatasetRegistry?: string;
5657
WorkerpoolRegistry?: string;

0 commit comments

Comments
 (0)