Skip to content

Commit

Permalink
Move interfaces into separate directory (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-CZ authored Oct 31, 2024
1 parent 0c6a7de commit 975107b
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion contracts/interfaces/IEVMWriter.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

interface IEvmWriter {
interface IEVMWriter {
function setBalance(address acc, uint256 value) external;

function copyCode(address acc, address from) external;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

interface NodeDriverI {
interface INodeDriver {
function setGenesisValidator(
address _auth,
uint256 validatorID,
Expand Down
6 changes: 6 additions & 0 deletions contracts/interfaces/INodeDriverExecutable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

interface INodeDriverExecutable {
function execute() external;
}
2 changes: 1 addition & 1 deletion contracts/sfc/SFCI.sol → contracts/interfaces/ISFC.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

interface SFCI {
interface ISFC {
event CreatedValidator(
uint256 indexed validatorID,
address indexed auth,
Expand Down
4 changes: 2 additions & 2 deletions contracts/sfc/NetworkInitializer.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

import {SFCI} from "./SFCI.sol";
import {ISFC} from "../interfaces/ISFC.sol";
import {NodeDriver, NodeDriverAuth} from "./NodeDriver.sol";
import {ConstantsManager} from "./ConstantsManager.sol";
import {Decimal} from "../common/Decimal.sol";
Expand Down Expand Up @@ -37,6 +37,6 @@ contract NetworkInitializer {
consts.updateGasPriceBalancingCounterweight(3600);
consts.transferOwnership(_owner);

SFCI(_sfc).initialize(sealedEpoch, totalSupply, _auth, _lib, address(consts), _owner);
ISFC(_sfc).initialize(sealedEpoch, totalSupply, _auth, _lib, address(consts), _owner);
}
}
6 changes: 3 additions & 3 deletions contracts/sfc/NodeDriver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ pragma solidity ^0.8.9;

import {Initializable} from "../common/Initializable.sol";
import {NodeDriverAuth} from "./NodeDriverAuth.sol";
import {IEvmWriter} from "../interfaces/IEVMWriter.sol";
import {IEVMWriter} from "../interfaces/IEVMWriter.sol";

contract NodeDriver is Initializable {
NodeDriverAuth internal backend;
IEvmWriter internal evmWriter;
IEVMWriter internal evmWriter;

error NotNode();
error NotBackend();
Expand Down Expand Up @@ -36,7 +36,7 @@ contract NodeDriver is Initializable {
function initialize(address _backend, address _evmWriterAddress) external initializer {
backend = NodeDriverAuth(_backend);
emit UpdatedBackend(_backend);
evmWriter = IEvmWriter(_evmWriterAddress);
evmWriter = IEVMWriter(_evmWriterAddress);
}

function setBalance(address acc, uint256 value) external onlyBackend {
Expand Down
13 changes: 5 additions & 8 deletions contracts/sfc/NodeDriverAuth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ pragma solidity ^0.8.9;

import {Initializable} from "../common/Initializable.sol";
import {Ownable} from "../ownership/Ownable.sol";
import {SFCI} from "./SFCI.sol";
import {ISFC} from "../interfaces/ISFC.sol";
import {NodeDriver} from "./NodeDriver.sol";

interface NodeDriverExecutable {
function execute() external;
}
import {INodeDriverExecutable} from "../interfaces/INodeDriverExecutable.sol";

contract NodeDriverAuth is Initializable, Ownable {
SFCI internal sfc;
ISFC internal sfc;
NodeDriver internal driver;

error NotSFC();
Expand All @@ -25,7 +22,7 @@ contract NodeDriverAuth is Initializable, Ownable {
function initialize(address payable _sfc, address _driver, address _owner) external initializer {
Ownable.initialize(_owner);
driver = NodeDriver(_driver);
sfc = SFCI(_sfc);
sfc = ISFC(_sfc);
}

modifier onlySFC() {
Expand All @@ -48,7 +45,7 @@ contract NodeDriverAuth is Initializable, Ownable {

function _execute(address executable, address newOwner, bytes32 selfCodeHash, bytes32 driverCodeHash) internal {
_transferOwnership(executable);
NodeDriverExecutable(executable).execute();
INodeDriverExecutable(executable).execute();
_transferOwnership(newOwner);
//require(driver.backend() == address(this), "ownership of driver is lost");
if (_getCodeHash(address(this)) != selfCodeHash) {
Expand Down
6 changes: 3 additions & 3 deletions contracts/sfc/Updater.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Decimal} from "../common/Decimal.sol";
import {NodeDriverAuth} from "./NodeDriverAuth.sol";
import {ConstantsManager} from "./ConstantsManager.sol";
import {SFC} from "./SFC.sol";
import {SFCI} from "./SFCI.sol";
import {ISFC} from "../interfaces/ISFC.sol";
import {Version} from "../version/Version.sol";

interface GovI {
Expand Down Expand Up @@ -101,8 +101,8 @@ contract Updater {

NodeDriverAuth nodeAuth = NodeDriverAuth(0xD100ae0000000000000000000000000000000000);
nodeAuth.upgradeCode(sfcTo, sfcFrom);
SFCI(sfcTo).updateConstsAddress(sfcConsts);
SFCI(sfcTo).updateVoteBookAddress(voteBook);
ISFC(sfcTo).updateConstsAddress(sfcConsts);
ISFC(sfcTo).updateVoteBookAddress(voteBook);
SFC(sfcTo).updateLibAddress(sfcLib);

nodeAuth.upgradeCode(govTo, govFrom);
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/StubEvmWriter.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

import {IEvmWriter} from "../interfaces/IEVMWriter.sol";
import {IEVMWriter} from "../interfaces/IEVMWriter.sol";

contract StubEvmWriter is IEvmWriter {
contract StubEvmWriter is IEVMWriter {
function setBalance(address acc, uint256 value) external {}

function copyCode(address acc, address from) external {}
Expand Down

0 comments on commit 975107b

Please sign in to comment.