Skip to content

Commit

Permalink
Merge branch 'main' into casino-suapp
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroXbrock committed Feb 27, 2024
2 parents 95b7136 + fecc9df commit 006c33b
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.8"

services:
suave-mevm:
image: flashbots/suave-geth:latest
image: flashbots/suave-geth:v0.1.2
command:
- --suave.dev
- --http.addr=0.0.0.0
Expand Down
16 changes: 6 additions & 10 deletions examples/app-ofa-private/ofa-private.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.8;

import "suave-std/suavelib/Suave.sol";
import "suave-std/Context.sol";

contract OFAPrivate {
// Struct to hold hint-related information for an order.
Expand All @@ -17,7 +18,7 @@ contract OFAPrivate {
// Internal function to save order details and generate a hint.
function saveOrder(uint64 decryptionCondition) internal returns (HintOrder memory) {
// Retrieve the bundle data from the confidential inputs
bytes memory bundleData = Suave.confidentialInputs();
bytes memory bundleData = Context.confidentialInputs();

// Simulate the bundle and extract its score.
uint64 egp = Suave.simulateBundle(bundleData);
Expand All @@ -42,22 +43,18 @@ contract OFAPrivate {
return hintOrder;
}

function emitHint(HintOrder memory order) public payable {
function emitHint(HintOrder memory order) public {
emit HintEvent(order.id, order.hint);
}

// Function to create a new user order
function newOrder(uint64 decryptionCondition) external payable returns (bytes memory) {
function newOrder(uint64 decryptionCondition) external returns (bytes memory) {
HintOrder memory hintOrder = saveOrder(decryptionCondition);
return abi.encodeWithSelector(this.emitHint.selector, hintOrder);
}

// Function to match and backrun another dataRecord.
function newMatch(Suave.DataId shareDataRecordId, uint64 decryptionCondition)
external
payable
returns (bytes memory)
{
function newMatch(Suave.DataId shareDataRecordId, uint64 decryptionCondition) external returns (bytes memory) {
HintOrder memory hintOrder = saveOrder(decryptionCondition);

// Merge the dataRecords and store them in the confidential datastore.
Expand All @@ -70,13 +67,12 @@ contract OFAPrivate {
return abi.encodeWithSelector(this.emitHint.selector, hintOrder);
}

function emitMatchDataRecordAndHintCallback(string memory bundleRawResponse) external payable {
function emitMatchDataRecordAndHintCallback(string memory bundleRawResponse) external {
emit BundleEmitted(bundleRawResponse);
}

function emitMatchDataRecordAndHint(string memory builderUrl, Suave.DataId dataRecordId)
external
payable
returns (bytes memory)
{
bytes memory bundleData = Suave.fillMevShareBundle(dataRecordId);
Expand Down
4 changes: 2 additions & 2 deletions examples/mevm-confidential-store/confidential-store.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ pragma solidity ^0.8.8;
import "suave-std/suavelib/Suave.sol";

contract ConfidentialStore {
function callback() external payable {}
function callback() external {}

function example() external payable returns (bytes memory) {
function example() external returns (bytes memory) {
address[] memory allowedList = new address[](1);
allowedList[0] = address(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ library UniswapV3 {
contract ExternalUniswapV3Quote {
function callback() external payable {}

function example(UniswapV3.ExactOutputSingleParams memory params) external payable returns (bytes memory) {
function example(UniswapV3.ExactOutputSingleParams memory params) external returns (bytes memory) {
UniswapV3.exactOutputSingle(params);

return abi.encodeWithSelector(this.callback.selector);
Expand Down
4 changes: 2 additions & 2 deletions examples/mevm-is-confidential/is-confidential.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ pragma solidity ^0.8.8;
import "suave-std/suavelib/Suave.sol";

contract IsConfidential {
function callback() external payable {}
function callback() external {}

function example() external payable returns (bytes memory) {
function example() external returns (bytes memory) {
require(Suave.isConfidential());

return abi.encodeWithSelector(this.callback.selector);
Expand Down
2 changes: 1 addition & 1 deletion examples/onchain-callback/onchain-callback.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ contract OnChainCallback {
emit CallbackEvent(num);
}

function example() external payable returns (bytes memory) {
function example() external returns (bytes memory) {
// event emitted in the off-chain confidential context, no effect.
emit NilEvent();

Expand Down
6 changes: 3 additions & 3 deletions examples/onchain-state/onchain-state.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import "suave-std/suavelib/Suave.sol";
contract OnChainState {
uint64 state;

function nilExampleCallback() external payable {}
function nilExampleCallback() external {}

function getState() external view returns (uint64) {
return state;
}

// nilExample is a function executed in a confidential request
// that CANNOT modify the state of the smart contract.
function nilExample() external payable returns (bytes memory) {
function nilExample() external returns (bytes memory) {
require(Suave.isConfidential());
state++;
return abi.encodeWithSelector(this.nilExampleCallback.selector);
Expand All @@ -26,7 +26,7 @@ contract OnChainState {

// example is a function executed in a confidential request that includes
// a callback that can modify the state.
function example() external payable returns (bytes memory) {
function example() external returns (bytes memory) {
require(Suave.isConfidential());
return bytes.concat(this.exampleCallback.selector);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.8;

import "suave-std/suavelib/Suave.sol";
import "suave-std/Context.sol";

contract PublicSuapp {
event ContractRegistered(Suave.DataId dataId);

function registerContractCallback(Suave.DataId dataId) public payable {
function registerContractCallback(Suave.DataId dataId) public {
emit ContractRegistered(dataId);
}

function registerContract() public payable returns (bytes memory) {
bytes memory bytecode = Suave.confidentialInputs();
function registerContract() public returns (bytes memory) {
bytes memory bytecode = Context.confidentialInputs();

address[] memory allowedList = new address[](1);
allowedList[0] = address(this);
Expand All @@ -23,7 +25,7 @@ contract PublicSuapp {

function exampleCallback() public {}

function example(Suave.DataId dataId) public payable returns (bytes memory) {
function example(Suave.DataId dataId) public returns (bytes memory) {
bytes memory bytecode = Suave.confidentialRetrieve(dataId, "bytecode");
address addr = deploy(bytecode);

Expand Down
8 changes: 5 additions & 3 deletions examples/private-library/private-library.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.8;

import "suave-std/suavelib/Suave.sol";
import "suave-std/Context.sol";

contract PublicSuapp {
function callback() public payable {}
function callback() public {}

function example() public payable returns (bytes memory) {
bytes memory bytecode = Suave.confidentialInputs();
function example() public returns (bytes memory) {
bytes memory bytecode = Context.confidentialInputs();
address addr = deploy(bytecode);

PrivateLibraryI c = PrivateLibraryI(addr);
Expand Down
8 changes: 5 additions & 3 deletions examples/std-transaction-signing/transaction-signing.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.8;

import "suave-std/suavelib/Suave.sol";
import "suave-std/Transactions.sol";
import "suave-std/Context.sol";

contract TransactionSigning {
using Transactions for *;

event TxnSignature(bytes32 r, bytes32 s);

function callback(bytes32 r, bytes32 s) public payable {
function callback(bytes32 r, bytes32 s) public {
emit TxnSignature(r, s);
}

function example() public payable returns (bytes memory) {
string memory signingKey = string(Suave.confidentialInputs());
function example() public returns (bytes memory) {
string memory signingKey = string(Context.confidentialInputs());

Transactions.EIP155Request memory txnWithToAddress = Transactions.EIP155Request({
to: address(0x00000000000000000000000000000000DeaDBeef),
Expand Down

0 comments on commit 006c33b

Please sign in to comment.