@@ -22,13 +22,13 @@ contract AgentRegistryFactory {
2222 /// @notice Emitted when a new AgentRegistrar clone is deployed
2323 /// @param registrar The address of the newly deployed registrar clone
2424 /// @param registry The registry the registrar mints to
25- /// @param owner The owner of the registrar
26- event RegistrarDeployed (address indexed registrar , address indexed registry , address indexed owner );
25+ /// @param admin The admin of the registrar (receives ADMIN_ROLE, DEFAULT_ADMIN_ROLE, and MINTER_ROLE)
26+ event RegistrarDeployed (address indexed registrar , address indexed registry , address indexed admin );
2727
2828 /// @notice Emitted when both registry and registrar are deployed together
2929 /// @param registry The address of the registry
3030 /// @param registrar The address of the registrar
31- /// @param admin The admin/owner address
31+ /// @param admin The admin address (receives all roles in both contracts)
3232 event RegistryAndRegistrarDeployed (address indexed registry , address indexed registrar , address indexed admin );
3333
3434 /* --- State Variables --- */
@@ -56,17 +56,15 @@ contract AgentRegistryFactory {
5656
5757 /* --- Constructor --- */
5858
59- /// @notice Deploy the factory with new implementation contracts
60- /// @dev Creates AgentRegistry and AgentRegistrar implementations for cloning
61- constructor () {
62- registryImplementation = address (new AgentRegistry ());
63- // Deploy registrar implementation with dummy values (will be overwritten on clone init)
64- registrarImplementation = address (new AgentRegistrar (
65- AgentRegistry (registryImplementation),
66- 0 ,
67- 0 ,
68- address (this )
69- ));
59+ /// @notice Deploy the factory with pre-deployed implementation contracts
60+ /// @param _registryImplementation The address of the AgentRegistry implementation
61+ /// @param _registrarImplementation The address of the AgentRegistrar implementation
62+ /// @dev Deploy implementations separately first to avoid "max initcode size exceeded" errors
63+ constructor (address _registryImplementation , address _registrarImplementation ) {
64+ require (_registryImplementation != address (0 ), "Invalid registry implementation " );
65+ require (_registrarImplementation != address (0 ), "Invalid registrar implementation " );
66+ registryImplementation = _registryImplementation;
67+ registrarImplementation = _registrarImplementation;
7068 }
7169
7270 /* --- Registry Deployment --- */
@@ -165,27 +163,27 @@ contract AgentRegistryFactory {
165163 /// @param registry The AgentRegistry to mint to
166164 /// @param mintPrice Price per mint in wei (0 = free)
167165 /// @param maxSupply Maximum supply (0 = unlimited)
168- /// @param owner Owner of the registrar
166+ /// @param admin Admin of the registrar (receives ADMIN_ROLE, DEFAULT_ADMIN_ROLE, and MINTER_ROLE)
169167 /// @return registrar The address of the newly deployed registrar
170168 function deployRegistrar (
171169 AgentRegistry registry ,
172170 uint256 mintPrice ,
173171 uint256 maxSupply ,
174- address owner
172+ address admin
175173 ) external returns (address registrar ) {
176174 registrar = registrarImplementation.clone ();
177- AgentRegistrar (payable (registrar)).initialize (registry, mintPrice, maxSupply, owner );
175+ AgentRegistrar (payable (registrar)).initialize (registry, mintPrice, maxSupply, admin );
178176
179177 deployedRegistrars.push (registrar);
180178 isDeployedRegistrar[registrar] = true ;
181179
182- emit RegistrarDeployed (registrar, address (registry), owner );
180+ emit RegistrarDeployed (registrar, address (registry), admin );
183181 }
184182
185183 /* --- Combined Deployment --- */
186184
187185 /// @notice Deploy both a registry and registrar together
188- /// @param admin The admin for the registry and owner of the registrar
186+ /// @param admin The admin for the registry and registrar (receives all roles in both contracts)
189187 /// @param mintPrice Price per mint in wei (0 = free)
190188 /// @param maxSupply Maximum supply (0 = unlimited)
191189 /// @return registry The address of the deployed registry
@@ -233,7 +231,7 @@ contract AgentRegistryFactory {
233231 }
234232
235233 /// @notice Deploy both a registry and registrar together with a name
236- /// @param admin The admin for the registry and owner of the registrar
234+ /// @param admin The admin for the registry and registrar (receives all roles in both contracts)
237235 /// @param mintPrice Price per mint in wei (0 = free)
238236 /// @param maxSupply Maximum supply (0 = unlimited)
239237 /// @param name The name for the registry (stored as ERC-8049 contract metadata)
@@ -286,7 +284,7 @@ contract AgentRegistryFactory {
286284 }
287285
288286 /// @notice Deploy both a registry and registrar with deterministic addresses
289- /// @param admin The admin for the registry and owner of the registrar
287+ /// @param admin The admin for the registry and registrar (receives all roles in both contracts)
290288 /// @param mintPrice Price per mint in wei (0 = free)
291289 /// @param maxSupply Maximum supply (0 = unlimited)
292290 /// @param registrySalt Salt for registry address
@@ -338,7 +336,7 @@ contract AgentRegistryFactory {
338336 }
339337
340338 /// @notice Deploy both a registry and registrar with deterministic addresses and a name
341- /// @param admin The admin for the registry and owner of the registrar
339+ /// @param admin The admin for the registry and registrar (receives all roles in both contracts)
342340 /// @param mintPrice Price per mint in wei (0 = free)
343341 /// @param maxSupply Maximum supply (0 = unlimited)
344342 /// @param registrySalt Salt for registry address
0 commit comments