@@ -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 {
@@ -49,16 +39,12 @@ contract MagicDropCloneFactoryTest is Test {
4939 vm.startPrank (owner);
5040
5141 // Deploy and initialize registry
52- address registryImpl = LibClone.clone (
53- address (new MagicDropTokenImplRegistry ())
54- );
42+ address registryImpl = LibClone.clone (address (new MagicDropTokenImplRegistry ()));
5543 registry = MagicDropTokenImplRegistry (payable (registryImpl));
5644 registry.initialize (owner);
5745
5846 // Deploy factory
59- address factoryImpl = LibClone.clone (
60- address (new MagicDropCloneFactory ())
61- );
47+ address factoryImpl = LibClone.clone (address (new MagicDropCloneFactory ()));
6248 factory = MagicDropCloneFactory (payable (factoryImpl));
6349 factory.initialize (owner, address (registry));
6450
@@ -67,19 +53,10 @@ contract MagicDropCloneFactoryTest is Test {
6753 erc1155Impl = new MockERC1155Initializable ();
6854
6955 // Register implementations
70- erc721ImplId = registry.registerImplementation (
71- TokenStandard.ERC721 ,
72- address (erc721Impl),
73- true ,
74- 0.01 ether,
75- 0.00001 ether
76- );
56+ erc721ImplId =
57+ registry.registerImplementation (TokenStandard.ERC721 , address (erc721Impl), true , 0.01 ether, 0.00001 ether);
7758 erc1155ImplId = registry.registerImplementation (
78- TokenStandard.ERC1155 ,
79- address (erc1155Impl),
80- true ,
81- 0.01 ether,
82- 0.00001 ether
59+ TokenStandard.ERC1155 , address (erc1155Impl), true , 0.01 ether, 0.00001 ether
8360 );
8461
8562 // Fund user
@@ -92,11 +69,7 @@ contract MagicDropCloneFactoryTest is Test {
9269 vm.startPrank (user);
9370
9471 address newContract = factory.createContract {value: 0.01 ether }(
95- "TestNFT " ,
96- "TNFT " ,
97- TokenStandard.ERC721 ,
98- payable (user),
99- erc721ImplId
72+ "TestNFT " , "TNFT " , TokenStandard.ERC721 , payable (user), erc721ImplId
10073 );
10174
10275 MockERC721Initializable nft = MockERC721Initializable (newContract);
@@ -111,13 +84,8 @@ contract MagicDropCloneFactoryTest is Test {
11184 function testCreateERC721ContractWithDefaultImplementation () public {
11285 vm.startPrank (user);
11386
114- address newContract = factory.createContract {value: 0.01 ether }(
115- "TestNFT " ,
116- "TNFT " ,
117- TokenStandard.ERC721 ,
118- payable (user),
119- 0
120- );
87+ address newContract =
88+ factory.createContract {value: 0.01 ether }("TestNFT " , "TNFT " , TokenStandard.ERC721 , payable (user), 0 );
12189
12290 MockERC721Initializable nft = MockERC721Initializable (newContract);
12391 // Test minting
@@ -131,11 +99,7 @@ contract MagicDropCloneFactoryTest is Test {
13199 vm.startPrank (user);
132100
133101 address newContract = factory.createContract {value: 0.01 ether }(
134- "TestMultiToken " ,
135- "TMT " ,
136- TokenStandard.ERC1155 ,
137- payable (user),
138- erc1155ImplId
102+ "TestMultiToken " , "TMT " , TokenStandard.ERC1155 , payable (user), erc1155ImplId
139103 );
140104
141105 MockERC1155Initializable nft = MockERC1155Initializable (newContract);
@@ -150,13 +114,8 @@ contract MagicDropCloneFactoryTest is Test {
150114 function testCreateERC1155ContractWithDefaultImplementation () public {
151115 vm.startPrank (user);
152116
153- address newContract = factory.createContract {value: 0.01 ether }(
154- "TestMultiToken " ,
155- "TMT " ,
156- TokenStandard.ERC1155 ,
157- payable (user),
158- 0
159- );
117+ address newContract =
118+ factory.createContract {value: 0.01 ether }("TestMultiToken " , "TMT " , TokenStandard.ERC1155 , payable (user), 0 );
160119
161120 MockERC1155Initializable nft = MockERC1155Initializable (newContract);
162121
@@ -174,23 +133,10 @@ contract MagicDropCloneFactoryTest is Test {
174133 bytes32 [] memory salts = new bytes32 [](numSalts);
175134
176135 for (uint256 i = 0 ; i < numSalts; 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]
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]
194140 );
195141 assertEq (predictedAddress, deployedAddress);
196142 }
@@ -203,34 +149,18 @@ contract MagicDropCloneFactoryTest is Test {
203149
204150 vm.prank (user);
205151 vm.expectRevert ();
206- factory.createContract (
207- "TestNFT " ,
208- "TNFT " ,
209- TokenStandard.ERC721 ,
210- payable (user),
211- invalidImplId
212- );
152+ factory.createContract ("TestNFT " , "TNFT " , TokenStandard.ERC721 , payable (user), invalidImplId);
213153 }
214154
215155 function testCreateDeterministicContractWithSameSalt () public {
216156 vm.startPrank (user);
217157
218158 factory.createContractDeterministic {value: 0.01 ether }(
219- "TestNFT1 " ,
220- "TNFT1 " ,
221- TokenStandard.ERC721 ,
222- payable (user),
223- erc721ImplId,
224- bytes32 (uint256 (100 ))
159+ "TestNFT1 " , "TNFT1 " , TokenStandard.ERC721 , payable (user), erc721ImplId, bytes32 (uint256 (100 ))
225160 );
226161 vm.expectRevert ();
227162 factory.createContractDeterministic {value: 0.01 ether }(
228- "TestNFT2 " ,
229- "TNFT2 " ,
230- TokenStandard.ERC721 ,
231- payable (user),
232- erc721ImplId,
233- bytes32 (uint256 (100 ))
163+ "TestNFT2 " , "TNFT2 " , TokenStandard.ERC721 , payable (user), erc721ImplId, bytes32 (uint256 (100 ))
234164 );
235165 }
236166
@@ -243,23 +173,14 @@ contract MagicDropCloneFactoryTest is Test {
243173 string memory symbol = "TT " ;
244174
245175 // Predict the address where the contract will be deployed
246- address predictedAddress = factory.predictDeploymentAddress (
247- standard,
248- implId,
249- salt
250- );
176+ address predictedAddress = factory.predictDeploymentAddress (standard, implId, salt);
251177
252178 // Deploy a dummy contract to the predicted address
253179 vm.etch (predictedAddress, address (erc721Impl).code);
254180 vm.expectRevert ();
255181 // Try to create a contract with the same parameters
256182 factory.createContractDeterministic {value: 0.01 ether }(
257- name,
258- symbol,
259- standard,
260- payable (initialOwner),
261- implId,
262- salt
183+ name, symbol, standard, payable (initialOwner), implId, salt
263184 );
264185 }
265186
@@ -268,38 +189,20 @@ contract MagicDropCloneFactoryTest is Test {
268189
269190 vm.startPrank (owner);
270191 InvalidImplementation impl = new InvalidImplementation ();
271- uint32 implId = registry.registerImplementation (
272- standard,
273- address (impl),
274- false ,
275- 0.01 ether,
276- 0.00001 ether
277- );
192+ uint32 implId = registry.registerImplementation (standard, address (impl), false , 0.01 ether, 0.00001 ether);
278193 vm.stopPrank ();
279194
280195 vm.expectRevert (MagicDropCloneFactory.InitializationFailed.selector );
281196 factory.createContractDeterministic {value: 0.01 ether }(
282- "TestNFT " ,
283- "TNFT " ,
284- standard,
285- payable (user),
286- implId,
287- bytes32 (uint256 (102 ))
197+ "TestNFT " , "TNFT " , standard, payable (user), implId, bytes32 (uint256 (102 ))
288198 );
289199 }
290200
291201 function testInsufficientDeploymentFee () public {
292202 vm.startPrank (user);
293- vm.expectRevert (
294- MagicDropCloneFactory.InsufficientDeploymentFee.selector
295- );
203+ vm.expectRevert (MagicDropCloneFactory.InsufficientDeploymentFee.selector );
296204 factory.createContractDeterministic {value: 0.005 ether }(
297- "TestNFT " ,
298- "TNFT " ,
299- TokenStandard.ERC721 ,
300- payable (user),
301- erc721ImplId,
302- bytes32 (uint256 (103 ))
205+ "TestNFT " , "TNFT " , TokenStandard.ERC721 , payable (user), erc721ImplId, bytes32 (uint256 (103 ))
303206 );
304207 }
305208
@@ -309,13 +212,7 @@ contract MagicDropCloneFactoryTest is Test {
309212
310213 function testWithdraw () public {
311214 vm.startPrank (user);
312- factory.createContract {value: 0.01 ether }(
313- "TestMultiToken " ,
314- "TMT " ,
315- TokenStandard.ERC1155 ,
316- payable (user),
317- 0
318- );
215+ factory.createContract {value: 0.01 ether }("TestMultiToken " , "TMT " , TokenStandard.ERC1155 , payable (user), 0 );
319216 vm.stopPrank ();
320217
321218 vm.startPrank (owner);
0 commit comments