Skip to content

Commit

Permalink
Another fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranbt committed Jan 31, 2024
1 parent a3ef6c4 commit 7e4551b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
4 changes: 2 additions & 2 deletions suave/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ address public constant {{encodeAddrName .Name}} =
{{end}}
// Returns whether execution is off- or on-chain
function isConfidential() internal view returns (bool b) {
function isConfidential() internal returns (bool b) {
(bool success, bytes memory isConfidentialBytes) = IS_CONFIDENTIAL_ADDR.call("");
if (!success) {
revert PeekerReverted(IS_CONFIDENTIAL_ADDR, isConfidentialBytes);
Expand All @@ -411,7 +411,7 @@ function isConfidential() internal view returns (bool b) {
}
{{range .Functions}}
function {{.Name}}({{range .Input}}{{styp .Typ}} {{.Name}}, {{end}}) internal view returns ({{range .Output.Fields}}{{styp .Typ}}, {{end}}) {
function {{.Name}}({{range .Input}}{{styp .Typ}} {{.Name}}, {{end}}) internal returns ({{range .Output.Fields}}{{styp .Typ}}, {{end}}) {
{{if .IsConfidential}}require(isConfidential());{{end}}
(bool success, bytes memory data) = {{encodeAddrName .Name}}.call(abi.encode({{range .Input}}{{.Name}}, {{end}}));
if (!success) {
Expand Down
36 changes: 14 additions & 22 deletions suave/sol/libraries/Suave.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ library Suave {
address public constant SUBMIT_ETH_BLOCK_TO_RELAY = 0x0000000000000000000000000000000042100002;

// Returns whether execution is off- or on-chain
function isConfidential() internal view returns (bool b) {
function isConfidential() internal returns (bool b) {
(bool success, bytes memory isConfidentialBytes) = IS_CONFIDENTIAL_ADDR.call("");
if (!success) {
revert PeekerReverted(IS_CONFIDENTIAL_ADDR, isConfidentialBytes);
Expand All @@ -110,7 +110,6 @@ library Suave {

function buildEthBlock(BuildBlockArgs memory blockArgs, DataId dataId, string memory namespace)
internal
view
returns (bytes memory, bytes memory)
{
(bool success, bytes memory data) = BUILD_ETH_BLOCK.call(abi.encode(blockArgs, dataId, namespace));
Expand All @@ -121,7 +120,7 @@ library Suave {
return abi.decode(data, (bytes, bytes));
}

function confidentialInputs() internal view returns (bytes memory) {
function confidentialInputs() internal returns (bytes memory) {
(bool success, bytes memory data) = CONFIDENTIAL_INPUTS.call(abi.encode());
if (!success) {
revert PeekerReverted(CONFIDENTIAL_INPUTS, data);
Expand All @@ -130,7 +129,7 @@ library Suave {
return data;
}

function confidentialRetrieve(DataId dataId, string memory key) internal view returns (bytes memory) {
function confidentialRetrieve(DataId dataId, string memory key) internal returns (bytes memory) {
(bool success, bytes memory data) = CONFIDENTIAL_RETRIEVE.call(abi.encode(dataId, key));
if (!success) {
revert PeekerReverted(CONFIDENTIAL_RETRIEVE, data);
Expand All @@ -139,14 +138,14 @@ library Suave {
return data;
}

function confidentialStore(DataId dataId, string memory key, bytes memory value) internal view {
function confidentialStore(DataId dataId, string memory key, bytes memory value) internal {
(bool success, bytes memory data) = CONFIDENTIAL_STORE.call(abi.encode(dataId, key, value));
if (!success) {
revert PeekerReverted(CONFIDENTIAL_STORE, data);
}
}

function doHTTPRequest(HttpRequest memory request) internal view returns (bytes memory) {
function doHTTPRequest(HttpRequest memory request) internal returns (bytes memory) {
(bool success, bytes memory data) = DO_HTTPREQUEST.call(abi.encode(request));
if (!success) {
revert PeekerReverted(DO_HTTPREQUEST, data);
Expand All @@ -155,7 +154,7 @@ library Suave {
return abi.decode(data, (bytes));
}

function ethcall(address contractAddr, bytes memory input1) internal view returns (bytes memory) {
function ethcall(address contractAddr, bytes memory input1) internal returns (bytes memory) {
(bool success, bytes memory data) = ETHCALL.call(abi.encode(contractAddr, input1));
if (!success) {
revert PeekerReverted(ETHCALL, data);
Expand All @@ -164,7 +163,7 @@ library Suave {
return abi.decode(data, (bytes));
}

function extractHint(bytes memory bundleData) internal view returns (bytes memory) {
function extractHint(bytes memory bundleData) internal returns (bytes memory) {
require(isConfidential());
(bool success, bytes memory data) = EXTRACT_HINT.call(abi.encode(bundleData));
if (!success) {
Expand All @@ -174,7 +173,7 @@ library Suave {
return data;
}

function fetchDataRecords(uint64 cond, string memory namespace) internal view returns (DataRecord[] memory) {
function fetchDataRecords(uint64 cond, string memory namespace) internal returns (DataRecord[] memory) {
(bool success, bytes memory data) = FETCH_DATA_RECORDS.call(abi.encode(cond, namespace));
if (!success) {
revert PeekerReverted(FETCH_DATA_RECORDS, data);
Expand All @@ -183,7 +182,7 @@ library Suave {
return abi.decode(data, (DataRecord[]));
}

function fillMevShareBundle(DataId dataId) internal view returns (bytes memory) {
function fillMevShareBundle(DataId dataId) internal returns (bytes memory) {
require(isConfidential());
(bool success, bytes memory data) = FILL_MEV_SHARE_BUNDLE.call(abi.encode(dataId));
if (!success) {
Expand All @@ -193,7 +192,7 @@ library Suave {
return data;
}

function newBuilder() internal view returns (string memory) {
function newBuilder() internal returns (string memory) {
(bool success, bytes memory data) = NEW_BUILDER.call(abi.encode());
if (!success) {
revert PeekerReverted(NEW_BUILDER, data);
Expand All @@ -207,7 +206,7 @@ library Suave {
address[] memory allowedPeekers,
address[] memory allowedStores,
string memory dataType
) internal view returns (DataRecord memory) {
) internal returns (DataRecord memory) {
(bool success, bytes memory data) =
NEW_DATA_RECORD.call(abi.encode(decryptionCondition, allowedPeekers, allowedStores, dataType));
if (!success) {
Expand All @@ -219,7 +218,6 @@ library Suave {

function signEthTransaction(bytes memory txn, string memory chainId, string memory signingKey)
internal
view
returns (bytes memory)
{
(bool success, bytes memory data) = SIGN_ETH_TRANSACTION.call(abi.encode(txn, chainId, signingKey));
Expand All @@ -230,7 +228,7 @@ library Suave {
return abi.decode(data, (bytes));
}

function signMessage(bytes memory digest, string memory signingKey) internal view returns (bytes memory) {
function signMessage(bytes memory digest, string memory signingKey) internal returns (bytes memory) {
require(isConfidential());
(bool success, bytes memory data) = SIGN_MESSAGE.call(abi.encode(digest, signingKey));
if (!success) {
Expand All @@ -240,7 +238,7 @@ library Suave {
return abi.decode(data, (bytes));
}

function simulateBundle(bytes memory bundleData) internal view returns (uint64) {
function simulateBundle(bytes memory bundleData) internal returns (uint64) {
(bool success, bytes memory data) = SIMULATE_BUNDLE.call(abi.encode(bundleData));
if (!success) {
revert PeekerReverted(SIMULATE_BUNDLE, data);
Expand All @@ -251,7 +249,6 @@ library Suave {

function simulateTransaction(string memory sessionid, bytes memory txn)
internal
view
returns (SimulateTransactionResult memory)
{
(bool success, bytes memory data) = SIMULATE_TRANSACTION.call(abi.encode(sessionid, txn));
Expand All @@ -264,7 +261,6 @@ library Suave {

function submitBundleJsonRPC(string memory url, string memory method, bytes memory params)
internal
view
returns (bytes memory)
{
require(isConfidential());
Expand All @@ -276,11 +272,7 @@ library Suave {
return data;
}

function submitEthBlockToRelay(string memory relayUrl, bytes memory builderBid)
internal
view
returns (bytes memory)
{
function submitEthBlockToRelay(string memory relayUrl, bytes memory builderBid) internal returns (bytes memory) {
require(isConfidential());
(bool success, bytes memory data) = SUBMIT_ETH_BLOCK_TO_RELAY.call(abi.encode(relayUrl, builderBid));
if (!success) {
Expand Down

0 comments on commit 7e4551b

Please sign in to comment.