@@ -138,6 +138,15 @@ contract MagicDropCloneFactory is Ownable {
138138 = PUBLIC VIEW METHODS =
139139 ==============================================================*/
140140
141+
142+ /// @notice Calculates the address of a deployed contract via create2
143+ /// @param _sender The account that deploys the contract.
144+ /// @param _bytecodeHash The correctly formatted hash of the bytecode.
145+ /// @param _salt The create2 salt.
146+ /// @param _input The constructor data.
147+ /// @return newAddress The derived address of the account.
148+
149+
141150 /// @notice Predicts the deployment address of a proxy contract
142151 /// @param salt The salt used for address generation
143152 /// @return The predicted proxy deployment address
@@ -146,21 +155,26 @@ contract MagicDropCloneFactory is Ownable {
146155 bytes memory constructorArgs = abi.encode (implementation);
147156 bytes memory deploymentBytecode = bytes .concat (bytecode, constructorArgs);
148157
149- (bool success , bytes memory result ) = CONTRACT_DEPLOYER.staticcall (
150- abi.encodeWithSignature (
151- "getNewAddressCreate2(address,bytes32,bytes32,bytes) " ,
152- address (this ),
153- keccak256 (deploymentBytecode),
154- salt,
155- constructorArgs
156- )
157- );
158-
159- if (! success) {
160- revert ("Failed to predict deployment address " );
161- }
162-
163- return abi.decode (result, (address ));
158+ // (bool success, bytes memory result) = CONTRACT_DEPLOYER.staticcall(
159+ // abi.encodeWithSignature(
160+ // "getNewAddressCreate2(address,bytes32,bytes32,bytes)",
161+ // address(this),
162+ // keccak256(deploymentBytecode),
163+ // salt,
164+ // constructorArgs
165+ // )
166+ // );
167+
168+ ContractDeployer deployer = ContractDeployer (CONTRACT_DEPLOYER);
169+ address predictedAddress =
170+ deployer.getNewAddressCreate2 (address (this ), keccak256 (deploymentBytecode), salt, deploymentBytecode);
171+
172+ // if (!success) {
173+ // revert("Failed to predict deployment address");
174+ // }
175+
176+ // return abi.decode(result, (address));
177+ return predictedAddress;
164178 }
165179
166180 /*==============================================================
0 commit comments