Commit b05a3b9b authored by Will Cory's avatar Will Cory

add more comments

parent 553f13aa
//SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
/* Testing utilities */
import { Test } from "forge-std/Test.sol";
import { CallRecorder } from "../testing/helpers/CallRecorder.sol";
import { Reverter } from "../testing/helpers/Reverter.sol";
import { Transactor } from "../universal/Transactor.sol";
contract Transactor_Initializer is Test {
address alice = address(128);
address bob = address(256);
Transactor transactor;
Reverter reverter;
CallRecorder callRecorded;
function _setUp() public {
// Deploy Reverter and CallRecorder helper contracts
reverter = new Reverter();
callRecorded = new CallRecorder();
// Deploy Transactor contract
transactor = new Transactor(address(alice));
vm.label(address(transactor), "Transactor");
// Give alice and bob some ETH
vm.deal(alice, 1 ether);
vm.deal(bob, 1 ether);
vm.label(alice, "alice");
vm.label(bob, "bob");
}
}
contract TransactorTest is Transactor_Initializer {
function setUp() public {
super._setUp();
}
// Tests if the owner was set correctly during deploy
function test_constructor() external {
assertEq(address(alice), transactor.owner());
}
// Tests CALL, should do a call to target
function test_CALL() external {
// Initialize call data
bytes memory data = abi.encodeWithSelector(callRecorded.record.selector);
// Run CALL
vm.prank(alice);
vm.expectCall(address(callRecorded), data);
transactor.CALL(address(callRecorded), data, 200_000 wei, 420);
}
// It should revert if called by non-owner
function testFail_CALL() external {
// Initialize call data
bytes memory data = abi.encodeWithSelector(callRecorded.record.selector);
// Run CALL
vm.prank(bob);
transactor.CALL(address(callRecorded), data, 200_000 wei, 420);
vm.expectRevert("UNAUTHORIZED");
}
function test_DELEGATECALL() external {
// Initialize call data
bytes memory data = abi.encodeWithSelector(reverter.doRevert.selector);
// Run CALL
vm.prank(alice);
vm.expectCall(address(reverter), data);
transactor.DELEGATECALL(address(reverter), data, 200_000 wei);
}
// It should revert if called by non-owner
function testFail_DELEGATECALLL() external {
// Initialize call data
bytes memory data = abi.encodeWithSelector(reverter.doRevert.selector);
// Run CALL
vm.prank(bob);
transactor.DELEGATECALL(address(reverter), data, 200_000 wei);
vm.expectRevert("UNAUTHORIZED");
}
}
......@@ -4,15 +4,41 @@ pragma solidity 0.8.15;
import { Semver } from "@eth-optimism/contracts-bedrock/contracts/universal/Semver.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
/**
* @title AttestationStation
* @dev Contract for creating attestations.
* @notice This contract is not yet audited.
*/
contract AttestationStation is Semver {
/**
* @notice Struct representing data that is being attested
*
* @custom:field about Address being attested about (not creator/msg.sender)
* @custom:field key A bytes32 key for the attestation.
* @custom:field val The attestation as arbitrary bytes
*/
struct AttestationData {
address about;
bytes32 key;
bytes val;
}
/**
* @notice Maps addresses to attestations
* @dev addresses map to attestations map of
* `about` addresses to key/values
* key/values are a map of bytes32 to bytes
*/
mapping(address => mapping(address => mapping(bytes32 => bytes))) public attestations;
/**
* @notice Emitted when Attestation is created
*
* @param creator Address that attested.
* @param about Address attestation is about.
* @param key Key of the attestation.
* @param val Value of the attestation.
*/
event AttestationCreated(
address indexed creator,
address indexed about,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment