diff --git a/src/forge/SuaveAddrs.sol b/src/forge/SuaveAddrs.sol index 5054c45..568ef73 100644 --- a/src/forge/SuaveAddrs.sol +++ b/src/forge/SuaveAddrs.sol @@ -6,7 +6,7 @@ import "../suavelib/Suave.sol"; library SuaveAddrs { function getSuaveAddrs() external pure returns (address[] memory) { - address[] memory addrList = new address[](24); + address[] memory addrList = new address[](25); addrList[0] = Suave.IS_CONFIDENTIAL_ADDR; addrList[1] = Suave.AES_DECRYPT; @@ -17,21 +17,22 @@ library SuaveAddrs { addrList[6] = Suave.CONFIDENTIAL_STORE; addrList[7] = Suave.CONTEXT_GET; addrList[8] = Suave.DO_HTTPREQUEST; - addrList[9] = Suave.ETHCALL; - addrList[10] = Suave.EXTRACT_HINT; - addrList[11] = Suave.FETCH_DATA_RECORDS; - addrList[12] = Suave.FILL_MEV_SHARE_BUNDLE; - addrList[13] = Suave.GET_INSECURE_TIME; - addrList[14] = Suave.NEW_BUILDER; - addrList[15] = Suave.NEW_DATA_RECORD; - addrList[16] = Suave.PRIVATE_KEY_GEN; - addrList[17] = Suave.RANDOM_BYTES; - addrList[18] = Suave.SIGN_ETH_TRANSACTION; - addrList[19] = Suave.SIGN_MESSAGE; - addrList[20] = Suave.SIMULATE_BUNDLE; - addrList[21] = Suave.SIMULATE_TRANSACTION; - addrList[22] = Suave.SUBMIT_BUNDLE_JSON_RPC; - addrList[23] = Suave.SUBMIT_ETH_BLOCK_TO_RELAY; + addrList[9] = Suave.DO_HTTPREQUEST2; + addrList[10] = Suave.ETHCALL; + addrList[11] = Suave.EXTRACT_HINT; + addrList[12] = Suave.FETCH_DATA_RECORDS; + addrList[13] = Suave.FILL_MEV_SHARE_BUNDLE; + addrList[14] = Suave.GET_INSECURE_TIME; + addrList[15] = Suave.NEW_BUILDER; + addrList[16] = Suave.NEW_DATA_RECORD; + addrList[17] = Suave.PRIVATE_KEY_GEN; + addrList[18] = Suave.RANDOM_BYTES; + addrList[19] = Suave.SIGN_ETH_TRANSACTION; + addrList[20] = Suave.SIGN_MESSAGE; + addrList[21] = Suave.SIMULATE_BUNDLE; + addrList[22] = Suave.SIMULATE_TRANSACTION; + addrList[23] = Suave.SUBMIT_BUNDLE_JSON_RPC; + addrList[24] = Suave.SUBMIT_ETH_BLOCK_TO_RELAY; return addrList; } diff --git a/src/suavelib/Suave.sol b/src/suavelib/Suave.sol index 15fe9a2..b6afaf5 100644 --- a/src/suavelib/Suave.sol +++ b/src/suavelib/Suave.sol @@ -70,6 +70,16 @@ library Suave { uint64 timeout; } + /// @notice Description of an HTTP response. + /// @param status HTTP status code of the response + /// @param body Body of the response + /// @param error Error message if any + struct HttpResponse { + uint64 status; + bytes body; + bytes error; + } + /// @notice Result of a simulated transaction. /// @param egp Effective Gas Price of the transaction /// @param logs Logs emitted during the simulation @@ -126,6 +136,8 @@ library Suave { address public constant DO_HTTPREQUEST = 0x0000000000000000000000000000000043200002; + address public constant DO_HTTPREQUEST2 = 0x0000000000000000000000000000000043200003; + address public constant ETHCALL = 0x0000000000000000000000000000000042100003; address public constant EXTRACT_HINT = 0x0000000000000000000000000000000042100037; @@ -296,6 +308,18 @@ library Suave { return abi.decode(data, (bytes)); } + /// @notice Performs an HTTP request and returns the response. `request` is the request to perform. + /// @param request Request to perform + /// @return httpResponse Response of the request + function doHTTPRequest2(HttpRequest memory request) internal returns (HttpResponse memory) { + (bool success, bytes memory data) = DO_HTTPREQUEST2.call(abi.encode(request)); + if (!success) { + revert PeekerReverted(DO_HTTPREQUEST2, data); + } + + return abi.decode(data, (HttpResponse)); + } + /// @notice Uses the `eth_call` JSON RPC method to let you simulate a function call and return the response. /// @param contractAddr Address of the contract to call /// @param input1 Data to send to the contract @@ -348,8 +372,8 @@ library Suave { return data; } - /// @notice Returns the current Kettle Unix time in seconds. - /// @return time Current Unix time in seconds + /// @notice Returns the current Kettle Unix time in milliseconds. Insecure because it assumes trust in Kettle's clock. + /// @return time Current Unix time in milliseconds function getInsecureTime() internal returns (uint256) { (bool success, bytes memory data) = GET_INSECURE_TIME.call(abi.encode()); if (!success) {