Skip to content

Commit

Permalink
port onchain orders
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco <[email protected]>
  • Loading branch information
fulminmaxi committed Dec 2, 2023
1 parent 2191986 commit 3115842
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/EncodedCalls.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
pragma solidity 0.8.23;

// Inheritances
import {IEncodedCalls} from "./interfaces/IEncodedCalls.sol";
Expand Down
3 changes: 2 additions & 1 deletion src/FloodPlain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity 0.8.23;
// Inheritances
import {IFloodPlain} from "./interfaces/IFloodPlain.sol";
import {EncodedCalls} from "./EncodedCalls.sol";
import {OnChainOrders} from "./OnChainOrders.sol";
import {ReentrancyGuard} from "@openzeppelin/utils/ReentrancyGuard.sol";

// Libraries
Expand All @@ -19,7 +20,7 @@ import {IZone} from "./interfaces/IZone.sol";
import {IERC20} from "@openzeppelin/token/ERC20/IERC20.sol";
import {ISignatureTransfer} from "permit2/src/interfaces/ISignatureTransfer.sol";

contract FloodPlain is IFloodPlain, EncodedCalls, ReentrancyGuard {
contract FloodPlain is IFloodPlain, EncodedCalls, OnChainOrders, ReentrancyGuard {
using SafeERC20 for IERC20;
using Address for address payable;
using OrderHash for Order;
Expand Down
18 changes: 18 additions & 0 deletions src/OnChainOrders.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

// Inheritances
import {IOnChainOrders} from "./interfaces/IOnChainOrders.sol";
import {IFloodPlain} from "./interfaces/IFloodPlain.sol";

// Libraries
import {OrderHash} from "./libraries/OrderHash.sol";

abstract contract OnChainOrders is IOnChainOrders {
using OrderHash for IFloodPlain.Order;

function etchOrder(IFloodPlain.SignedOrder calldata orderWithSignature) external {
bytes32 orderHash = orderWithSignature.order.hash();
emit IOnChainOrders.OrderEtched(orderHash, orderWithSignature);
}
}
15 changes: 15 additions & 0 deletions src/interfaces/IOnChainOrders.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

import {IFloodPlain} from "./IFloodPlain.sol";

interface IOnChainOrders {
event OrderEtched(bytes32 indexed orderHash, IFloodPlain.SignedOrder orderWithSignature);

/**
* @notice Record an order on-chain for ease of use by other contracts.
*
* @param orderWithSignature The order and its signature to record.
*/
function etchOrder(IFloodPlain.SignedOrder calldata orderWithSignature) external;
}

0 comments on commit 3115842

Please sign in to comment.