Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add draft "precrime" contracts #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions contracts/precrime/ILayerZeroClientPrecrime.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import { ILayerZeroClientPrecrimeInternal } from './ILayerZeroClientPrecrimeInternal.sol';

interface ILayerZeroClientPrecrime is ILayerZeroClientPrecrimeInternal {
function precrime() external view returns (address);

function setPrecrime(address precrime) external;
}
7 changes: 7 additions & 0 deletions contracts/precrime/ILayerZeroClientPrecrimeInternal.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface ILayerZeroClientPrecrimeInternal {
event SetPrecrime(address precrime);
}
19 changes: 19 additions & 0 deletions contracts/precrime/LayerZeroClientPrecrime.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import { ILayerZeroClientPrecrime } from './ILayerZeroClientPrecrime.sol';
import { LayerZeroClientPrecrimeInternal } from './LayerZeroClientPrecrimeInternal.sol';

abstract contract LayerZeroClientPrecrime is
ILayerZeroClientPrecrime,
LayerZeroClientPrecrimeInternal
{
function precrime() external view returns (address) {
return _precrime();
}

function setPrecrime(address precrime) external {
return _setPrecrime(precrime);
}
}
20 changes: 20 additions & 0 deletions contracts/precrime/LayerZeroClientPrecrimeInternal.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import { ILayerZeroClientPrecrimeInternal } from './ILayerZeroClientPrecrimeInternal.sol';
import { LayerZeroClientPrecrimeStorage } from './LayerZeroClientPrecrimeStorage.sol';

abstract contract LayerZeroClientPrecrimeInternal is
ILayerZeroClientPrecrimeInternal
{
function _precrime() internal view virtual returns (address) {
return LayerZeroClientPrecrimeStorage.layout().precrime;
}

function _setPrecrime(address precrime) internal virtual {
// TODO: onlyOwner
LayerZeroClientPrecrimeStorage.layout().precrime = precrime;
emit SetPrecrime(precrime);
}
}
19 changes: 19 additions & 0 deletions contracts/precrime/LayerZeroClientPrecrimeStorage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

library LayerZeroClientPrecrimeStorage {
struct Layout {
address precrime;
}

bytes32 internal constant STORAGE_SLOT =
keccak256('solidstate.contracts.storage.LayerZeroClientPrecrime');

function layout() internal pure returns (Layout storage l) {
bytes32 slot = STORAGE_SLOT;
assembly {
l.slot := slot
}
}
}