Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Add input relay base contract #67

Merged
merged 4 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions onchain/rollups/abi/contracts/relays/IRelay.sol/IRelay.json

This file was deleted.

26 changes: 0 additions & 26 deletions onchain/rollups/abi/contracts/relays/Relay.sol/Relay.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

pragma solidity ^0.8.8;

import {IInputBox} from "../inputs/IInputBox.sol";
import {IInputBox} from "./IInputBox.sol";

/// @title Relay interface
interface IRelay {
/// @title Input Relay interface
interface IInputRelay {
// Permissionless functions

/// @notice Get the input box used by this relay.
/// @notice Get the input box used by this input relay.
/// @return The input box
function getInputBox() external view returns (IInputBox);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@

pragma solidity ^0.8.8;

import {IRelay} from "./IRelay.sol";
import {IInputBox} from "../inputs/IInputBox.sol";
import {IInputRelay} from "./IInputRelay.sol";
import {IInputBox} from "./IInputBox.sol";

/// @title Relay
/// @notice This contract serves as a base for all the other relays.
contract Relay is IRelay {
/// @notice The input box used by the relay.
/// @title Input Relay
/// @notice This contract serves as a base for all the other input relays.
contract InputRelay is IInputRelay {
/// @notice The input box used by the input relay.
IInputBox internal immutable inputBox;

/// @notice Constructs the relay.
/// @param _inputBox The input box used by the relay
/// @notice Constructs the input relay.
/// @param _inputBox The input box used by the input relay
constructor(IInputBox _inputBox) {
inputBox = _inputBox;
}
Expand Down
6 changes: 3 additions & 3 deletions onchain/rollups/contracts/portals/ERC1155BatchPortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ pragma solidity ^0.8.8;
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

import {IERC1155BatchPortal} from "./IERC1155BatchPortal.sol";
import {Portal} from "./Portal.sol";
import {InputRelay} from "../inputs/InputRelay.sol";
import {IInputBox} from "../inputs/IInputBox.sol";
import {InputEncoding} from "../common/InputEncoding.sol";

/// @title ERC-1155 Batch Transfer Portal
///
/// @notice This contract allows anyone to perform batch transfers of
/// ERC-1155 tokens to a DApp while informing the off-chain machine.
contract ERC1155BatchPortal is Portal, IERC1155BatchPortal {
contract ERC1155BatchPortal is InputRelay, IERC1155BatchPortal {
/// @notice Constructs the portal.
/// @param _inputBox The input box used by the portal
constructor(IInputBox _inputBox) Portal(_inputBox) {}
constructor(IInputBox _inputBox) InputRelay(_inputBox) {}

function depositBatchERC1155Token(
IERC1155 _token,
Expand Down
6 changes: 3 additions & 3 deletions onchain/rollups/contracts/portals/ERC1155SinglePortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ pragma solidity ^0.8.8;
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

import {IERC1155SinglePortal} from "./IERC1155SinglePortal.sol";
import {Portal} from "./Portal.sol";
import {InputRelay} from "../inputs/InputRelay.sol";
import {IInputBox} from "../inputs/IInputBox.sol";
import {InputEncoding} from "../common/InputEncoding.sol";

/// @title ERC-1155 Single Transfer Portal
///
/// @notice This contract allows anyone to perform single transfers of
/// ERC-1155 tokens to a DApp while informing the off-chain machine.
contract ERC1155SinglePortal is Portal, IERC1155SinglePortal {
contract ERC1155SinglePortal is InputRelay, IERC1155SinglePortal {
/// @notice Constructs the portal.
/// @param _inputBox The input box used by the portal
constructor(IInputBox _inputBox) Portal(_inputBox) {}
constructor(IInputBox _inputBox) InputRelay(_inputBox) {}

function depositSingleERC1155Token(
IERC1155 _token,
Expand Down
6 changes: 3 additions & 3 deletions onchain/rollups/contracts/portals/ERC20Portal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ pragma solidity ^0.8.8;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import {IERC20Portal} from "./IERC20Portal.sol";
import {Portal} from "./Portal.sol";
import {InputRelay} from "../inputs/InputRelay.sol";
import {IInputBox} from "../inputs/IInputBox.sol";
import {InputEncoding} from "../common/InputEncoding.sol";

/// @title ERC-20 Portal
///
/// @notice This contract allows anyone to perform transfers of
/// ERC-20 tokens to a DApp while informing the off-chain machine.
contract ERC20Portal is Portal, IERC20Portal {
contract ERC20Portal is InputRelay, IERC20Portal {
/// @notice Constructs the portal.
/// @param _inputBox The input box used by the portal
constructor(IInputBox _inputBox) Portal(_inputBox) {}
constructor(IInputBox _inputBox) InputRelay(_inputBox) {}

function depositERC20Tokens(
IERC20 _token,
Expand Down
6 changes: 3 additions & 3 deletions onchain/rollups/contracts/portals/ERC721Portal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ pragma solidity ^0.8.8;
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";

import {IERC721Portal} from "./IERC721Portal.sol";
import {Portal} from "./Portal.sol";
import {InputRelay} from "../inputs/InputRelay.sol";
import {IInputBox} from "../inputs/IInputBox.sol";
import {InputEncoding} from "../common/InputEncoding.sol";

/// @title ERC-721 Portal
///
/// @notice This contract allows anyone to perform transfers of
/// ERC-721 tokens to a DApp while informing the off-chain machine.
contract ERC721Portal is Portal, IERC721Portal {
contract ERC721Portal is InputRelay, IERC721Portal {
/// @notice Constructs the portal.
/// @param _inputBox The input box used by the portal
constructor(IInputBox _inputBox) Portal(_inputBox) {}
constructor(IInputBox _inputBox) InputRelay(_inputBox) {}

function depositERC721Token(
IERC721 _token,
Expand Down
6 changes: 3 additions & 3 deletions onchain/rollups/contracts/portals/EtherPortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
pragma solidity ^0.8.8;

import {IEtherPortal} from "./IEtherPortal.sol";
import {Portal} from "./Portal.sol";
import {InputRelay} from "../inputs/InputRelay.sol";
import {IInputBox} from "../inputs/IInputBox.sol";
import {InputEncoding} from "../common/InputEncoding.sol";

/// @title Ether Portal
///
/// @notice This contract allows anyone to perform transfers of
/// Ether to a DApp while informing the off-chain machine.
contract EtherPortal is Portal, IEtherPortal {
contract EtherPortal is InputRelay, IEtherPortal {
/// @notice Raised when the Ether transfer fails.
error EtherTransferFailed();

/// @notice Constructs the portal.
/// @param _inputBox The input box used by the portal
constructor(IInputBox _inputBox) Portal(_inputBox) {}
constructor(IInputBox _inputBox) InputRelay(_inputBox) {}

function depositEther(
address _dapp,
Expand Down
4 changes: 2 additions & 2 deletions onchain/rollups/contracts/portals/IERC1155BatchPortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

pragma solidity ^0.8.8;

import {IPortal} from "./IPortal.sol";
import {IInputRelay} from "../inputs/IInputRelay.sol";
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

/// @title ERC-1155 Batch Transfer Portal interface
interface IERC1155BatchPortal is IPortal {
interface IERC1155BatchPortal is IInputRelay {
// Permissionless functions

/// @notice Transfer a batch of ERC-1155 tokens to a DApp and add an input to
Expand Down
4 changes: 2 additions & 2 deletions onchain/rollups/contracts/portals/IERC1155SinglePortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

pragma solidity ^0.8.8;

import {IPortal} from "./IPortal.sol";
import {IInputRelay} from "../inputs/IInputRelay.sol";
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

/// @title ERC-1155 Single Transfer Portal interface
interface IERC1155SinglePortal is IPortal {
interface IERC1155SinglePortal is IInputRelay {
// Permissionless functions

/// @notice Transfer an ERC-1155 token to a DApp and add an input to
Expand Down
4 changes: 2 additions & 2 deletions onchain/rollups/contracts/portals/IERC20Portal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

pragma solidity ^0.8.8;

import {IPortal} from "./IPortal.sol";
import {IInputRelay} from "../inputs/IInputRelay.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/// @title ERC-20 Portal interface
interface IERC20Portal is IPortal {
interface IERC20Portal is IInputRelay {
// Permissionless functions

/// @notice Transfer ERC-20 tokens to a DApp and add an input to
Expand Down
4 changes: 2 additions & 2 deletions onchain/rollups/contracts/portals/IERC721Portal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

pragma solidity ^0.8.8;

import {IPortal} from "./IPortal.sol";
import {IInputRelay} from "../inputs/IInputRelay.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";

/// @title ERC-721 Portal interface
interface IERC721Portal is IPortal {
interface IERC721Portal is IInputRelay {
// Permissionless functions

/// @notice Transfer an ERC-721 token to a DApp and add an input to
Expand Down
4 changes: 2 additions & 2 deletions onchain/rollups/contracts/portals/IEtherPortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

pragma solidity ^0.8.8;

import {IPortal} from "./IPortal.sol";
import {IInputRelay} from "../inputs/IInputRelay.sol";

/// @title Ether Portal interface
interface IEtherPortal is IPortal {
interface IEtherPortal is IInputRelay {
// Permissionless functions

/// @notice Transfer Ether to a DApp and add an input to
Expand Down
24 changes: 0 additions & 24 deletions onchain/rollups/contracts/portals/IPortal.sol

This file was deleted.

33 changes: 0 additions & 33 deletions onchain/rollups/contracts/portals/Portal.sol

This file was deleted.

6 changes: 3 additions & 3 deletions onchain/rollups/contracts/relays/DAppAddressRelay.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
pragma solidity ^0.8.8;

import {IDAppAddressRelay} from "./IDAppAddressRelay.sol";
import {Relay} from "./Relay.sol";
import {InputRelay} from "../inputs/InputRelay.sol";
import {IInputBox} from "../inputs/IInputBox.sol";
import {InputEncoding} from "../common/InputEncoding.sol";

/// @title DApp Address Relay
///
/// @notice This contract allows anyone to inform the off-chain machine
/// of the address of the DApp contract in a trustless and permissionless way.
contract DAppAddressRelay is Relay, IDAppAddressRelay {
contract DAppAddressRelay is InputRelay, IDAppAddressRelay {
/// @notice Constructs the relay.
/// @param _inputBox The input box used by the relay
constructor(IInputBox _inputBox) Relay(_inputBox) {}
constructor(IInputBox _inputBox) InputRelay(_inputBox) {}

function relayDAppAddress(address _dapp) external override {
bytes memory input = InputEncoding.encodeDAppAddressRelay(_dapp);
Expand Down
4 changes: 2 additions & 2 deletions onchain/rollups/contracts/relays/IDAppAddressRelay.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

pragma solidity ^0.8.8;

import {IRelay} from "./IRelay.sol";
import {IInputRelay} from "../inputs/IInputRelay.sol";

/// @title DApp Address Relay interface
interface IDAppAddressRelay is IRelay {
interface IDAppAddressRelay is IInputRelay {
// Permissionless functions

/// @notice Add an input to a DApp's input box with its address.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contractName": "IPortal",
"sourceName": "contracts/portals/IPortal.sol",
"contractName": "IInputRelay",
"sourceName": "contracts/inputs/IInputRelay.sol",
"abi": [
{
"inputs": [],
Expand Down Expand Up @@ -29,14 +29,14 @@
}
}
},
"title": "Portal interface",
"title": "Input Relay interface",
"version": 1
},
"userdoc": {
"kind": "user",
"methods": {
"getInputBox()": {
"notice": "Get the input box used by this portal."
"notice": "Get the input box used by this input relay."
}
},
"version": 1
Expand Down
Loading
Loading