Skip to content

Commit

Permalink
Update Suave.sol library to flashbots/suave-geth@06b7e72 (#104)
Browse files Browse the repository at this point in the history
Co-authored-by: sukoneck <[email protected]>
  • Loading branch information
github-actions[bot] and sukoneck authored Dec 4, 2024
1 parent 8fbdc1a commit 796452e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 18 deletions.
33 changes: 17 additions & 16 deletions src/forge/SuaveAddrs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
28 changes: 26 additions & 2 deletions src/suavelib/Suave.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 796452e

Please sign in to comment.