@@ -12,11 +12,21 @@ import {MagicDropTokenImplRegistry} from "../../contracts/registry/MagicDropToke
1212import {TokenStandard} from "../../contracts/common/Structs.sol " ;
1313
1414contract MockERC721Initializable is MockERC721 {
15- function initialize (string memory , string memory , address , uint256 ) public {}
15+ function initialize (
16+ string memory ,
17+ string memory ,
18+ address ,
19+ uint256
20+ ) public {}
1621}
1722
1823contract MockERC1155Initializable is MockERC1155 {
19- function initialize (string memory , string memory , address , uint256 ) public {}
24+ function initialize (
25+ string memory ,
26+ string memory ,
27+ address ,
28+ uint256
29+ ) public {}
2030}
2131
2232contract InvalidImplementation is MockERC721 {
@@ -39,12 +49,16 @@ contract MagicDropCloneFactoryTest is Test {
3949 vm.startPrank (owner);
4050
4151 // Deploy and initialize registry
42- address registryImpl = LibClone.clone (address (new MagicDropTokenImplRegistry ()));
52+ address registryImpl = LibClone.clone (
53+ address (new MagicDropTokenImplRegistry ())
54+ );
4355 registry = MagicDropTokenImplRegistry (payable (registryImpl));
4456 registry.initialize (owner);
4557
4658 // Deploy factory
47- address factoryImpl = LibClone.clone (address (new MagicDropCloneFactory ()));
59+ address factoryImpl = LibClone.clone (
60+ address (new MagicDropCloneFactory ())
61+ );
4862 factory = MagicDropCloneFactory (payable (factoryImpl));
4963 factory.initialize (owner, address (registry));
5064
@@ -53,10 +67,19 @@ contract MagicDropCloneFactoryTest is Test {
5367 erc1155Impl = new MockERC1155Initializable ();
5468
5569 // Register implementations
56- erc721ImplId =
57- registry.registerImplementation (TokenStandard.ERC721 , address (erc721Impl), true , 0.01 ether, 0.00001 ether);
70+ erc721ImplId = registry.registerImplementation (
71+ TokenStandard.ERC721 ,
72+ address (erc721Impl),
73+ true ,
74+ 0.01 ether,
75+ 0.00001 ether
76+ );
5877 erc1155ImplId = registry.registerImplementation (
59- TokenStandard.ERC1155 , address (erc1155Impl), true , 0.01 ether, 0.00001 ether
78+ TokenStandard.ERC1155 ,
79+ address (erc1155Impl),
80+ true ,
81+ 0.01 ether,
82+ 0.00001 ether
6083 );
6184
6285 // Fund user
@@ -69,7 +92,11 @@ contract MagicDropCloneFactoryTest is Test {
6992 vm.startPrank (user);
7093
7194 address newContract = factory.createContract {value: 0.01 ether }(
72- "TestNFT " , "TNFT " , TokenStandard.ERC721 , payable (user), erc721ImplId
95+ "TestNFT " ,
96+ "TNFT " ,
97+ TokenStandard.ERC721 ,
98+ payable (user),
99+ erc721ImplId
73100 );
74101
75102 MockERC721Initializable nft = MockERC721Initializable (newContract);
@@ -84,8 +111,13 @@ contract MagicDropCloneFactoryTest is Test {
84111 function testCreateERC721ContractWithDefaultImplementation () public {
85112 vm.startPrank (user);
86113
87- address newContract =
88- factory.createContract {value: 0.01 ether }("TestNFT " , "TNFT " , TokenStandard.ERC721 , payable (user), 0 );
114+ address newContract = factory.createContract {value: 0.01 ether }(
115+ "TestNFT " ,
116+ "TNFT " ,
117+ TokenStandard.ERC721 ,
118+ payable (user),
119+ 0
120+ );
89121
90122 MockERC721Initializable nft = MockERC721Initializable (newContract);
91123 // Test minting
@@ -99,7 +131,11 @@ contract MagicDropCloneFactoryTest is Test {
99131 vm.startPrank (user);
100132
101133 address newContract = factory.createContract {value: 0.01 ether }(
102- "TestMultiToken " , "TMT " , TokenStandard.ERC1155 , payable (user), erc1155ImplId
134+ "TestMultiToken " ,
135+ "TMT " ,
136+ TokenStandard.ERC1155 ,
137+ payable (user),
138+ erc1155ImplId
103139 );
104140
105141 MockERC1155Initializable nft = MockERC1155Initializable (newContract);
@@ -114,8 +150,13 @@ contract MagicDropCloneFactoryTest is Test {
114150 function testCreateERC1155ContractWithDefaultImplementation () public {
115151 vm.startPrank (user);
116152
117- address newContract =
118- factory.createContract {value: 0.01 ether }("TestMultiToken " , "TMT " , TokenStandard.ERC1155 , payable (user), 0 );
153+ address newContract = factory.createContract {value: 0.01 ether }(
154+ "TestMultiToken " ,
155+ "TMT " ,
156+ TokenStandard.ERC1155 ,
157+ payable (user),
158+ 0
159+ );
119160
120161 MockERC1155Initializable nft = MockERC1155Initializable (newContract);
121162
@@ -133,10 +174,23 @@ contract MagicDropCloneFactoryTest is Test {
133174 bytes32 [] memory salts = new bytes32 [](numSalts);
134175
135176 for (uint256 i = 0 ; i < numSalts; i++ ) {
136- salts[i] = keccak256 (abi.encodePacked (i, block .timestamp , msg .sender ));
137- address predictedAddress = factory.predictDeploymentAddress (TokenStandard.ERC721 , erc721ImplId, salts[i]);
138- address deployedAddress = factory.createContractDeterministic {value: 0.01 ether }(
139- "TestNFT " , "TNFT " , TokenStandard.ERC721 , payable (user), erc721ImplId, salts[i]
177+ salts[i] = keccak256 (
178+ abi.encodePacked (i, block .timestamp , msg .sender )
179+ );
180+ address predictedAddress = factory.predictDeploymentAddress (
181+ TokenStandard.ERC721 ,
182+ erc721ImplId,
183+ salts[i]
184+ );
185+ address deployedAddress = factory.createContractDeterministic {
186+ value: 0.01 ether
187+ }(
188+ "TestNFT " ,
189+ "TNFT " ,
190+ TokenStandard.ERC721 ,
191+ payable (user),
192+ erc721ImplId,
193+ salts[i]
140194 );
141195 assertEq (predictedAddress, deployedAddress);
142196 }
@@ -149,38 +203,63 @@ contract MagicDropCloneFactoryTest is Test {
149203
150204 vm.prank (user);
151205 vm.expectRevert ();
152- factory.createContract ("TestNFT " , "TNFT " , TokenStandard.ERC721 , payable (user), invalidImplId);
206+ factory.createContract (
207+ "TestNFT " ,
208+ "TNFT " ,
209+ TokenStandard.ERC721 ,
210+ payable (user),
211+ invalidImplId
212+ );
153213 }
154214
155215 function testCreateDeterministicContractWithSameSalt () public {
156216 vm.startPrank (user);
157217
158218 factory.createContractDeterministic {value: 0.01 ether }(
159- "TestNFT1 " , "TNFT1 " , TokenStandard.ERC721 , payable (user), erc721ImplId, bytes32 (0 )
219+ "TestNFT1 " ,
220+ "TNFT1 " ,
221+ TokenStandard.ERC721 ,
222+ payable (user),
223+ erc721ImplId,
224+ bytes32 (uint256 (100 ))
160225 );
161226 vm.expectRevert ();
162227 factory.createContractDeterministic {value: 0.01 ether }(
163- "TestNFT2 " , "TNFT2 " , TokenStandard.ERC721 , payable (user), erc721ImplId, bytes32 (0 )
228+ "TestNFT2 " ,
229+ "TNFT2 " ,
230+ TokenStandard.ERC721 ,
231+ payable (user),
232+ erc721ImplId,
233+ bytes32 (uint256 (100 ))
164234 );
165235 }
166236
167237 function testContractAlreadyDeployed () public {
168- bytes32 salt = bytes32 (uint256 (1 ));
238+ bytes32 salt = bytes32 (uint256 (101 ));
169239 uint32 implId = 1 ;
170240 TokenStandard standard = TokenStandard.ERC721 ;
171241 address initialOwner = address (0x1 );
172242 string memory name = "TestToken " ;
173243 string memory symbol = "TT " ;
174244
175245 // Predict the address where the contract will be deployed
176- address predictedAddress = factory.predictDeploymentAddress (standard, implId, salt);
246+ address predictedAddress = factory.predictDeploymentAddress (
247+ standard,
248+ implId,
249+ salt
250+ );
177251
178252 // Deploy a dummy contract to the predicted address
179253 vm.etch (predictedAddress, address (erc721Impl).code);
180254 vm.expectRevert ();
181255 // Try to create a contract with the same parameters
182256 factory.createContractDeterministic {value: 0.01 ether }(
183- name, symbol, standard, payable (initialOwner), implId, salt
257+ name,
258+ symbol,
259+ standard,
260+ payable (initialOwner),
261+ implId,
262+ salt
184263 );
185264 }
186265
@@ -189,20 +268,38 @@ contract MagicDropCloneFactoryTest is Test {
189268
190269 vm.startPrank (owner);
191270 InvalidImplementation impl = new InvalidImplementation ();
192- uint32 implId = registry.registerImplementation (standard, address (impl), false , 0.01 ether, 0.00001 ether);
271+ uint32 implId = registry.registerImplementation (
272+ standard,
273+ address (impl),
274+ false ,
275+ 0.01 ether,
276+ 0.00001 ether
277+ );
193278 vm.stopPrank ();
194279
195280 vm.expectRevert (MagicDropCloneFactory.InitializationFailed.selector );
196281 factory.createContractDeterministic {value: 0.01 ether }(
197- "TestNFT " , "TNFT " , standard, payable (user), implId, bytes32 (0 )
282+ "TestNFT " ,
283+ "TNFT " ,
284+ standard,
285+ payable (user),
286+ implId,
287+ bytes32 (uint256 (102 ))
198288 );
199289 }
200290
201291 function testInsufficientDeploymentFee () public {
202292 vm.startPrank (user);
203- vm.expectRevert (MagicDropCloneFactory.InsufficientDeploymentFee.selector );
293+ vm.expectRevert (
294+ MagicDropCloneFactory.InsufficientDeploymentFee.selector
295+ );
204296 factory.createContractDeterministic {value: 0.005 ether }(
205- "TestNFT " , "TNFT " , TokenStandard.ERC721 , payable (user), erc721ImplId, bytes32 (0 )
297+ "TestNFT " ,
298+ "TNFT " ,
299+ TokenStandard.ERC721 ,
300+ payable (user),
301+ erc721ImplId,
302+ bytes32 (uint256 (103 ))
206303 );
207304 }
208305
@@ -212,7 +309,13 @@ contract MagicDropCloneFactoryTest is Test {
212309
213310 function testWithdraw () public {
214311 vm.startPrank (user);
215- factory.createContract {value: 0.01 ether }("TestMultiToken " , "TMT " , TokenStandard.ERC1155 , payable (user), 0 );
312+ factory.createContract {value: 0.01 ether }(
313+ "TestMultiToken " ,
314+ "TMT " ,
315+ TokenStandard.ERC1155 ,
316+ payable (user),
317+ 0
318+ );
216319 vm.stopPrank ();
217320
218321 vm.startPrank (owner);
0 commit comments