Skip to content

Commit

Permalink
Put EVM writer interface into a file
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-CZ committed Oct 24, 2024
1 parent 00f6554 commit 152d0b3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
14 changes: 14 additions & 0 deletions contracts/interfaces/IEVMWriter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

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

function copyCode(address acc, address from) external;

function swapCode(address acc, address where) external;

function setStorage(address acc, bytes32 key, bytes32 value) external;

function incNonce(address acc, uint256 diff) external;
}
17 changes: 3 additions & 14 deletions contracts/sfc/NodeDriver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,11 @@ pragma solidity ^0.8.9;

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

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

function copyCode(address acc, address from) external;

function swapCode(address acc, address where) external;

function setStorage(address acc, bytes32 key, bytes32 value) external;

function incNonce(address acc, uint256 diff) external;
}
import {IEvmWriter} from "../interfaces/IEVMWriter.sol";

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

event UpdatedBackend(address indexed backend);

Expand All @@ -42,7 +31,7 @@ contract NodeDriver is Initializable {
function initialize(address _backend, address _evmWriterAddress) external initializer {
backend = NodeDriverAuth(_backend);
emit UpdatedBackend(_backend);
evmWriter = EVMWriter(_evmWriterAddress);
evmWriter = IEvmWriter(_evmWriterAddress);
}

function setBalance(address acc, uint256 value) external onlyBackend {
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 {EVMWriter} from "../sfc/NodeDriver.sol";
import {IEvmWriter} from "../interfaces/IEVMWriter.sol";

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

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

0 comments on commit 152d0b3

Please sign in to comment.