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

Commit

Permalink
refactor(contracts): make portals and relays inherit "input relay"
Browse files Browse the repository at this point in the history
* Make portals and relays inherit `InputRelay`
* Make portals and relays interfaces inherit `IInputRelay`
  • Loading branch information
guidanoli committed Jun 2, 2023
1 parent 9bce4c4 commit ce5bc5e
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 30 deletions.
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
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

0 comments on commit ce5bc5e

Please sign in to comment.