Skip to content

Commit

Permalink
use new lib in ofa example
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroXbrock committed May 24, 2024
1 parent bb2c583 commit 8766260
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions examples/app-ofa-private/ofa-private.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ library DagStore {
if (!success) {
revert PeekerReverted(DAG_RETRIEVE, data);
}
return data;
}

function set(bytes32 dagId, bytes memory data) public {
function set(bytes memory data) public returns (bytes32 dagId) {
bytes32 dagId = keccak256(data);
(bool success, bytes memory data) = DAG_STORE.call(abi.encode(dagId, data));
if (!success) {
revert PeekerReverted(DAG_STORE, data);
}
return dagId;
}
}

contract OFAPrivate {
// Struct to hold hint-related information for an order.
struct HintOrder {
Suave.DataId id;
bytes32 id;
bytes hint;
}

Expand All @@ -51,12 +54,13 @@ contract OFAPrivate {
allowedList[1] = 0x0000000000000000000000000000000043200001;

// Store the bundle and the simulation results in the confidential datastore.
Suave.DataRecord memory dataRecord = Suave.newDataRecord(decryptionCondition, allowedList, allowedList, "");
Suave.confidentialStore(dataRecord.id, "mevshare:v0:ethBundles", bundleData);
Suave.confidentialStore(dataRecord.id, "mevshare:v0:ethBundleSimResults", abi.encode(egp));
// Suave.DataRecord memory dataRecord = Suave.newDataRecord(decryptionCondition, allowedList, allowedList, "");
// Suave.confidentialStore(dataRecord.id, "mevshare:v0:ethBundles", bundleData);
// Suave.confidentialStore(dataRecord.id, "mevshare:v0:ethBundleSimResults", abi.encode(egp));
dagId = DagStore.set(bundleData);

HintOrder memory hintOrder;
hintOrder.id = dataRecord.id;
hintOrder.id = dagId;
hintOrder.hint = hint;

return hintOrder;
Expand All @@ -73,17 +77,18 @@ contract OFAPrivate {
}

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

// Merge the dataRecords and store them in the confidential datastore.
// The 'fillMevShareBundle' precompile will use this information to send the bundles.
Suave.DataId[] memory dataRecords = new Suave.DataId[](2);
dataRecords[0] = shareDataRecordId;
dataRecords[1] = hintOrder.id;
Suave.confidentialStore(hintOrder.id, "mevshare:v0:mergedDataRecords", abi.encode(dataRecords));
// Suave.confidentialStore(hintOrder.id, "mevshare:v0:mergedDataRecords", abi.encode(dataRecords));
bytes32 recordsId = DagStore.set(abi.encode(dataRecords));

return abi.encodeWithSelector(this.emitHint.selector, hintOrder);
return abi.encodeWithSelector(this.emitHint.selector, recordsId);
}

function emitMatchDataRecordAndHintCallback(string memory bundleRawResponse) external {
Expand Down

0 comments on commit 8766260

Please sign in to comment.