Skip to content

Commit

Permalink
fix(atst): Up to do contract
Browse files Browse the repository at this point in the history
  • Loading branch information
qbzzt committed Apr 20, 2023
1 parent 48df1bb commit eb93d8e
Show file tree
Hide file tree
Showing 3 changed files with 28,053 additions and 7,990 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,85 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.15;

contract AttestationStation {
mapping(address => mapping(address => mapping(bytes32 => bytes))) public attestations;
import { Semver } from "@eth-optimism/contracts-bedrock/contracts/universal/Semver.sol";

/**
* @title AttestationStation
* @author Optimism Collective
* @author Gitcoin
* @notice Where attestations live.
*/
contract AttestationStation is Semver {
/**
* @notice Struct representing data that is being attested.
*
* @custom:field about Address for which the attestation is about.
* @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. Creator => About => Key => Value.
*/
mapping(address => mapping(address => mapping(bytes32 => bytes))) public attestations;

/**
* @notice Emitted when Attestation is created.
*
* @param creator Address that made the attestation.
* @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,
bytes32 indexed key,
bytes val
);

function attest(AttestationData[] memory _attestations) public {
for (uint256 i = 0; i < _attestations.length; ++i) {
/**
* @custom:semver 1.1.0
*/
constructor() Semver(1, 1, 0) {}

/**
* @notice Allows anyone to create an attestation.
*
* @param _about Address that the attestation is about.
* @param _key A key used to namespace the attestation.
* @param _val An arbitrary value stored as part of the attestation.
*/
function attest(
address _about,
bytes32 _key,
bytes memory _val
) public {
attestations[msg.sender][_about][_key] = _val;

emit AttestationCreated(msg.sender, _about, _key, _val);
}

/**
* @notice Allows anyone to create attestations.
*
* @param _attestations An array of AttestationData structs.
*/
function attest(AttestationData[] calldata _attestations) external {
uint256 length = _attestations.length;
for (uint256 i = 0; i < length; ) {
AttestationData memory attestation = _attestations[i];
attestations[msg.sender][attestation.about][attestation.key] = attestation.val;
emit AttestationCreated(
msg.sender,
attestation.about,
attestation.key,
attestation.val
);

attest(attestation.about, attestation.key, attestation.val);

unchecked {
++i;
}
}
}
}
Loading

0 comments on commit eb93d8e

Please sign in to comment.