@@ -12,21 +12,11 @@ import {MagicDropTokenImplRegistry} from "../../contracts/registry/MagicDropToke
1212import {TokenStandard} from "../../contracts/common/Structs.sol " ;
1313
1414contract MockERC721Initializable is MockERC721 {
15- function initialize (
16- string memory ,
17- string memory ,
18- address ,
19- uint256
20- ) public {}
15+ function initialize (string memory , string memory , address , uint256 ) public {}
2116}
2217
2318contract MockERC1155Initializable is MockERC1155 {
24- function initialize (
25- string memory ,
26- string memory ,
27- address ,
28- uint256
29- ) public {}
19+ function initialize (string memory , string memory , address , uint256 ) public {}
3020}
3121
3222contract InvalidImplementation is MockERC721 {
@@ -54,16 +44,12 @@ contract MagicDropCloneFactoryTest is Test {
5444 invalidImplementation = new InvalidImplementation ();
5545
5646 // Deploy and initialize registry
57- address registryImpl = LibClone.clone (
58- address (new MagicDropTokenImplRegistry ())
59- );
47+ address registryImpl = LibClone.clone (address (new MagicDropTokenImplRegistry ()));
6048 registry = MagicDropTokenImplRegistry (payable (registryImpl));
6149 registry.initialize (owner);
6250
6351 // Deploy factory
64- address factoryImpl = LibClone.clone (
65- address (new MagicDropCloneFactory ())
66- );
52+ address factoryImpl = LibClone.clone (address (new MagicDropCloneFactory ()));
6753 factory = MagicDropCloneFactory (payable (factoryImpl));
6854 factory.initialize (owner, address (registry));
6955
@@ -72,19 +58,10 @@ contract MagicDropCloneFactoryTest is Test {
7258 erc1155Impl = new MockERC1155Initializable ();
7359
7460 // Register implementations
75- erc721ImplId = registry.registerImplementation (
76- TokenStandard.ERC721 ,
77- address (erc721Impl),
78- true ,
79- 0.01 ether,
80- 0.00001 ether
81- );
61+ erc721ImplId =
62+ registry.registerImplementation (TokenStandard.ERC721 , address (erc721Impl), true , 0.01 ether, 0.00001 ether);
8263 erc1155ImplId = registry.registerImplementation (
83- TokenStandard.ERC1155 ,
84- address (erc1155Impl),
85- true ,
86- 0.01 ether,
87- 0.00001 ether
64+ TokenStandard.ERC1155 , address (erc1155Impl), true , 0.01 ether, 0.00001 ether
8865 );
8966
9067 // Fund user
@@ -97,11 +74,7 @@ contract MagicDropCloneFactoryTest is Test {
9774 vm.startPrank (user);
9875
9976 address newContract = factory.createContract {value: 0.01 ether }(
100- "TestNFT " ,
101- "TNFT " ,
102- TokenStandard.ERC721 ,
103- payable (user),
104- erc721ImplId
77+ "TestNFT " , "TNFT " , TokenStandard.ERC721 , payable (user), erc721ImplId
10578 );
10679
10780 MockERC721Initializable nft = MockERC721Initializable (newContract);
@@ -116,13 +89,8 @@ contract MagicDropCloneFactoryTest is Test {
11689 function testCreateERC721ContractWithDefaultImplementation () public {
11790 vm.startPrank (user);
11891
119- address newContract = factory.createContract {value: 0.01 ether }(
120- "TestNFT " ,
121- "TNFT " ,
122- TokenStandard.ERC721 ,
123- payable (user),
124- 0
125- );
92+ address newContract =
93+ factory.createContract {value: 0.01 ether }("TestNFT " , "TNFT " , TokenStandard.ERC721 , payable (user), 0 );
12694
12795 MockERC721Initializable nft = MockERC721Initializable (newContract);
12896 // Test minting
@@ -136,11 +104,7 @@ contract MagicDropCloneFactoryTest is Test {
136104 vm.startPrank (user);
137105
138106 address newContract = factory.createContract {value: 0.01 ether }(
139- "TestMultiToken " ,
140- "TMT " ,
141- TokenStandard.ERC1155 ,
142- payable (user),
143- erc1155ImplId
107+ "TestMultiToken " , "TMT " , TokenStandard.ERC1155 , payable (user), erc1155ImplId
144108 );
145109
146110 MockERC1155Initializable nft = MockERC1155Initializable (newContract);
@@ -155,13 +119,8 @@ contract MagicDropCloneFactoryTest is Test {
155119 function testCreateERC1155ContractWithDefaultImplementation () public {
156120 vm.startPrank (user);
157121
158- address newContract = factory.createContract {value: 0.01 ether }(
159- "TestMultiToken " ,
160- "TMT " ,
161- TokenStandard.ERC1155 ,
162- payable (user),
163- 0
164- );
122+ address newContract =
123+ factory.createContract {value: 0.01 ether }("TestMultiToken " , "TMT " , TokenStandard.ERC1155 , payable (user), 0 );
165124
166125 MockERC1155Initializable nft = MockERC1155Initializable (newContract);
167126
@@ -179,23 +138,10 @@ contract MagicDropCloneFactoryTest is Test {
179138 bytes32 [] memory salts = new bytes32 [](numSalts);
180139
181140 for (uint256 i = 0 ; i < numSalts; i++ ) {
182- salts[i] = keccak256 (
183- abi.encodePacked (i, block .timestamp , msg .sender )
184- );
185- address predictedAddress = factory.predictDeploymentAddress (
186- TokenStandard.ERC721 ,
187- erc721ImplId,
188- salts[i]
189- );
190- address deployedAddress = factory.createContractDeterministic {
191- value: 0.01 ether
192- }(
193- "TestNFT " ,
194- "TNFT " ,
195- TokenStandard.ERC721 ,
196- payable (user),
197- erc721ImplId,
198- salts[i]
141+ salts[i] = keccak256 (abi.encodePacked (i, block .timestamp , msg .sender ));
142+ address predictedAddress = factory.predictDeploymentAddress (TokenStandard.ERC721 , erc721ImplId, salts[i]);
143+ address deployedAddress = factory.createContractDeterministic {value: 0.01 ether }(
144+ "TestNFT " , "TNFT " , TokenStandard.ERC721 , payable (user), erc721ImplId, salts[i]
199145 );
200146 assertEq (predictedAddress, deployedAddress);
201147 }
@@ -208,34 +154,18 @@ contract MagicDropCloneFactoryTest is Test {
208154
209155 vm.prank (user);
210156 vm.expectRevert ();
211- factory.createContract (
212- "TestNFT " ,
213- "TNFT " ,
214- TokenStandard.ERC721 ,
215- payable (user),
216- invalidImplId
217- );
157+ factory.createContract ("TestNFT " , "TNFT " , TokenStandard.ERC721 , payable (user), invalidImplId);
218158 }
219159
220160 function testCreateDeterministicContractWithSameSalt () public {
221161 vm.startPrank (user);
222162
223163 factory.createContractDeterministic {value: 0.01 ether }(
224- "TestNFT1 " ,
225- "TNFT1 " ,
226- TokenStandard.ERC721 ,
227- payable (user),
228- erc721ImplId,
229- bytes32 (uint256 (100 ))
164+ "TestNFT1 " , "TNFT1 " , TokenStandard.ERC721 , payable (user), erc721ImplId, bytes32 (uint256 (100 ))
230165 );
231166 vm.expectRevert ();
232167 factory.createContractDeterministic {value: 0.01 ether }(
233- "TestNFT2 " ,
234- "TNFT2 " ,
235- TokenStandard.ERC721 ,
236- payable (user),
237- erc721ImplId,
238- bytes32 (uint256 (100 ))
168+ "TestNFT2 " , "TNFT2 " , TokenStandard.ERC721 , payable (user), erc721ImplId, bytes32 (uint256 (100 ))
239169 );
240170 }
241171
@@ -248,23 +178,14 @@ contract MagicDropCloneFactoryTest is Test {
248178 string memory symbol = "TT " ;
249179
250180 // Predict the address where the contract will be deployed
251- address predictedAddress = factory.predictDeploymentAddress (
252- standard,
253- implId,
254- salt
255- );
181+ address predictedAddress = factory.predictDeploymentAddress (standard, implId, salt);
256182
257183 // Deploy a dummy contract to the predicted address
258184 vm.etch (predictedAddress, address (erc721Impl).code);
259185 vm.expectRevert ();
260186 // Try to create a contract with the same parameters
261187 factory.createContractDeterministic {value: 0.01 ether }(
262- name,
263- symbol,
264- standard,
265- payable (initialOwner),
266- implId,
267- salt
188+ name, symbol, standard, payable (initialOwner), implId, salt
268189 );
269190 }
270191
@@ -273,38 +194,21 @@ contract MagicDropCloneFactoryTest is Test {
273194
274195 vm.startPrank (owner);
275196
276- uint32 implId = registry.registerImplementation (
277- standard,
278- address (invalidImplementation),
279- false ,
280- 0.01 ether,
281- 0.00001 ether
282- );
197+ uint32 implId =
198+ registry.registerImplementation (standard, address (invalidImplementation), false , 0.01 ether, 0.00001 ether);
283199 vm.stopPrank ();
284200
285201 vm.expectRevert (MagicDropCloneFactory.InitializationFailed.selector );
286202 factory.createContractDeterministic {value: 0.01 ether }(
287- "TestNFT " ,
288- "TNFT " ,
289- standard,
290- payable (user),
291- implId,
292- bytes32 (uint256 (102 ))
203+ "TestNFT " , "TNFT " , standard, payable (user), implId, bytes32 (uint256 (102 ))
293204 );
294205 }
295206
296207 function testInsufficientDeploymentFee () public {
297208 vm.startPrank (user);
298- vm.expectRevert (
299- MagicDropCloneFactory.InsufficientDeploymentFee.selector
300- );
209+ vm.expectRevert (MagicDropCloneFactory.InsufficientDeploymentFee.selector );
301210 factory.createContractDeterministic {value: 0.005 ether }(
302- "TestNFT " ,
303- "TNFT " ,
304- TokenStandard.ERC721 ,
305- payable (user),
306- erc721ImplId,
307- bytes32 (uint256 (103 ))
211+ "TestNFT " , "TNFT " , TokenStandard.ERC721 , payable (user), erc721ImplId, bytes32 (uint256 (103 ))
308212 );
309213 }
310214
@@ -314,13 +218,7 @@ contract MagicDropCloneFactoryTest is Test {
314218
315219 function testWithdraw () public {
316220 vm.startPrank (user);
317- factory.createContract {value: 0.01 ether }(
318- "TestMultiToken " ,
319- "TMT " ,
320- TokenStandard.ERC1155 ,
321- payable (user),
322- 0
323- );
221+ factory.createContract {value: 0.01 ether }("TestMultiToken " , "TMT " , TokenStandard.ERC1155 , payable (user), 0 );
324222 vm.stopPrank ();
325223
326224 vm.startPrank (owner);
0 commit comments