@@ -153,12 +153,14 @@ contract VerifyFactoryContracts is Script, GraphQLQuery {
153153 " --constructor-args " ,
154154 vm.toString (constructorArgs),
155155 " --watch " ,
156- " >/dev/tty 2>&1 " //Redirect to terminal directly
156+ " 2>&1 || true " // Capture output; exit 0 so ffi doesn't revert
157157 );
158158
159- try vm.ffi (cmd) returns (bytes memory ) {
159+ bytes memory output = vm.ffi (cmd);
160+ // forge verify-contract prints "OK" on success
161+ if (_containsOK (output)) {
160162 result.status = VerificationStatus.Verified;
161- } catch {
163+ } else {
162164 result.status = VerificationStatus.NotVerified;
163165 }
164166 }
@@ -265,13 +267,22 @@ contract VerifyFactoryContracts is Script, GraphQLQuery {
265267 return abi.encode (m.poolId (), m.contractUpdater ());
266268 }
267269
270+ /// @dev Check if ffi output contains "OK" (forge verify-contract success marker)
271+ function _containsOK (bytes memory data ) internal pure returns (bool ) {
272+ if (data.length < 2 ) return false ;
273+ for (uint256 i = 0 ; i <= data.length - 2 ; i++ ) {
274+ if (data[i] == "O " && data[i + 1 ] == "K " ) return true ;
275+ }
276+ return false ;
277+ }
278+
268279 // ANSI color codes
269280 string constant GREEN = "\x1b[32m " ;
270281 string constant RED = "\x1b[31m " ;
271282 string constant YELLOW = "\x1b[33m " ;
272283 string constant RESET = "\x1b[0m " ;
273284
274- function _logSummary (VerificationResult[] memory results ) internal pure {
285+ function _logSummary (VerificationResult[] memory results ) internal view {
275286 console.log ("" );
276287 console.log ("---------------------------------------- " );
277288 console.log (" VERIFICATION SUMMARY " );
0 commit comments