Skip to content

Commit

Permalink
feat: add getDeploymentBlockNumber function to IInputBox
Browse files Browse the repository at this point in the history
  • Loading branch information
guidanoli committed Dec 13, 2024
1 parent 846a99b commit 7cb08d8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions contracts/inputs/IInputBox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,7 @@ interface IInputBox {
address appContract,
uint256 index
) external view returns (bytes32);

/// @notice Get number of block in which contract was deployed
function getDeploymentBlockNumber() external view returns (uint256);
}
17 changes: 17 additions & 0 deletions contracts/inputs/InputBox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ import {CanonicalMachine} from "../common/CanonicalMachine.sol";
import {Inputs} from "../common/Inputs.sol";

contract InputBox is IInputBox {
/// @notice Deployment block number
uint256 immutable _deploymentBlockNumber;

/// @notice Mapping of application contract addresses to arrays of input hashes.
mapping(address => bytes32[]) private _inputBoxes;

constructor() {
_deploymentBlockNumber = block.number;
}

/// @inheritdoc IInputBox
function addInput(
address appContract,
Expand Down Expand Up @@ -65,4 +72,14 @@ contract InputBox is IInputBox {
) external view override returns (bytes32) {
return _inputBoxes[appContract][index];
}

/// @inheritdoc IInputBox
function getDeploymentBlockNumber()
external
view
override
returns (uint256)
{
return _deploymentBlockNumber;
}
}
6 changes: 6 additions & 0 deletions test/inputs/InputBox.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ contract InputBoxTest is Test {
_inputBox = new InputBox();
}

function testDeploymentBlockNumber(uint256 blockNumber) public {
vm.roll(blockNumber);
_inputBox = new InputBox();
assertEq(_inputBox.getDeploymentBlockNumber(), blockNumber);
}

function testNoInputs(address appContract) public view {
assertEq(_inputBox.getNumberOfInputs(appContract), 0);
}
Expand Down

0 comments on commit 7cb08d8

Please sign in to comment.